/* ==========================================================================
   Paradigm admin shell + the bridge that re-themes the existing Ant pages.

   Loaded by app/Views/header.php after antd-*.css and paradigm.css.

   1. Bridge: the old pages style themselves through --ant-* variables (and
      antd-*.css reads the same ones). Pointing those at the Paradigm tokens
      re-themes every existing page without touching its markup. Pages are
      moved to the p-* components one by one (task-4.x); when the last one is
      done, the bridge and antd-*.css go.
   2. Shell: sidebar, mobile top bar, customer search.

   The admin is forced to the light theme (data-theme="light" in header.php):
   the old pages carry ~900 inline styles with hard-coded light colours, so a
   dark shell around them would be unreadable. Lift it when they're gone.
   ========================================================================== */

/* ---------- 1. Bridge ---------- */
:root.p-root {
  --ant-primary-color: var(--accent);
  --ant-primary-color-hover: var(--accent-hover);
  --ant-primary-color-active: var(--accent-ink);
  --ant-color-primary: var(--accent);
  --ant-color-link: var(--p-accent-text);
  --ant-color-text: var(--p-ink);
  --ant-color-text-secondary: var(--p-muted);
  --ant-color-text-tertiary: var(--p-muted);
  --ant-color-text-quaternary: var(--p-border-strong);
  --ant-color-bg-base: var(--p-bg);
  --ant-color-bg-layout: var(--p-bg);
  --ant-color-bg-container: var(--p-surface);
  --ant-color-bg-elevated: var(--p-surface);
  --ant-color-border: var(--p-border);
  --ant-color-border-secondary: var(--p-border);
  --ant-color-split: var(--p-border);
  --ant-color-fill-quaternary: var(--p-surface-sunken);
  --ant-error-color: var(--p-danger);
  --ant-color-error: var(--p-danger);
  --ant-success-color: var(--p-success);
  --ant-warning-color: var(--p-warning);
  --ant-info-color: var(--p-info);
  --ant-font-family: var(--p-font-ui);
  --ant-border-radius-xs: var(--p-radius-sm);
  --ant-border-radius-sm: var(--p-radius-sm);
  --ant-border-radius: var(--p-radius-lg);
  --ant-border-radius-lg: var(--p-radius-lg);
  --ant-border-radius-xl: var(--p-radius-lg);
  --ant-box-shadow: var(--p-shadow-sm);
  --ant-box-shadow-secondary: var(--p-shadow-md);
  --ant-box-shadow-lg: var(--p-shadow-md);
}

.p-root body {
  font-family: var(--p-font-ui);
  color: var(--p-body);
  background: var(--p-bg);
  font-size: var(--p-text-md);
  line-height: var(--p-leading);
  -webkit-font-smoothing: antialiased;
}

/* paradigm.css zeroes p margins under .p-root; the old pages rely on them. */
.p-legacy p { margin: 0 0 0.75em; }
.p-legacy p:last-child { margin-bottom: 0; }
.p-legacy h1, .p-legacy h2, .p-legacy h3 { margin: 0 0 0.6em; }
.p-legacy h1 { font-family: var(--p-font-display); font-weight: 400; font-size: var(--p-text-2xl); letter-spacing: -0.01em; }
.p-legacy h2 { font-family: var(--p-font-display); font-weight: 400; font-size: var(--p-text-xl); }
.p-legacy h3 { font-size: var(--p-text-lg); font-weight: var(--p-weight-semibold); }

/* Their containers had their own max width and gutters; the shell owns those now. */
.p-legacy .ant-container,
.p-legacy .container,
.p-legacy .container-fluid { max-width: none; padding-left: 0; padding-right: 0; margin: 0; width: auto; }

/* Cards: hairline, no shadow — the Aednan way. */
.p-legacy .ant-card { border: 1px solid var(--p-border); box-shadow: none; border-radius: var(--p-radius-lg); background: var(--p-surface); }
.p-legacy .ant-card-head {
  border-bottom: 1px solid var(--p-border);
  min-height: 52px;
  padding: var(--p-space-3) var(--p-space-5);
  display: flex;
  align-items: center;
}
.p-legacy .ant-card-head > .ant-card-head-wrapper { flex: 1; min-width: 0; }
.p-legacy .ant-card-body { padding: var(--p-space-5); }
/* Cards stacked in a column (customer page, dashboards) had no space between
   them: the old layout relied on a margin the shell's reset removed. */
.p-legacy .ant-card ~ .ant-card { margin-top: var(--p-space-4); } /* ~ not +: each card is preceded by its own <style> */
.p-legacy .ant-col { min-width: 0; }
@media (max-width: 640px) {
  .p-legacy .ant-card-head { padding: var(--p-space-3) var(--p-space-4); }
  .p-legacy .ant-card-body { padding: var(--p-space-4); }
}
.p-legacy .ant-card-head-title { font-size: var(--p-text-lg); font-weight: var(--p-weight-semibold); color: var(--p-ink); }

/* Buttons */
.p-legacy .ant-btn {
  font-family: var(--p-font-ui);
  font-weight: var(--p-weight-medium);
  border-radius: var(--p-radius);
  box-shadow: none;
  transition: background var(--p-duration), border-color var(--p-duration), color var(--p-duration);
}
.p-legacy .ant-btn:not(.ant-btn-primary):not(.ant-btn-dangerous):not(.ant-btn-danger):not(.ant-btn-link):not(.ant-btn-text) {
  border-color: var(--p-border-strong);
  color: var(--p-ink);
  background: var(--p-surface);
}
.p-legacy .ant-btn:not(.ant-btn-primary):not(.ant-btn-dangerous):not(.ant-btn-danger):not(.ant-btn-link):not(.ant-btn-text):hover {
  border-color: var(--p-ink);
  background: var(--p-surface-sunken);
}
.p-legacy .ant-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.p-legacy .ant-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

/* Fields */
.p-legacy .ant-input,
.p-legacy .ant-select,
.p-legacy .ant-input-number,
.p-legacy textarea.ant-input,
.p-legacy .form-control,
.p-legacy .form-select {
  border-color: var(--p-border-strong);
  border-radius: var(--p-radius);
  background: var(--p-field-bg);
  color: var(--p-ink);
  font-family: var(--p-font-ui);
}
.p-legacy .ant-input:focus,
.p-legacy .ant-select:focus,
.p-legacy .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--p-accent-soft, rgba(0, 0, 0, 0.08));
  outline: none;
}

/* Tables */
.p-legacy .ant-table,
.p-legacy table.ant-table { font-variant-numeric: tabular-nums; }
.p-legacy .ant-table thead th,
.p-legacy .ant-table-thead > tr > th {
  background: var(--p-surface-sunken);
  color: var(--p-muted);
  font-size: var(--p-text-xs);
  font-weight: var(--p-weight-semibold);
  letter-spacing: var(--p-tracking-caps);
  text-transform: uppercase;
  border-bottom: 1px solid var(--p-border);
}
/* Tables never clip. antd_table.php sets overflow-x: hidden on its wrapper,
   which cut the last column off (half a "Refund" button) whenever a table was
   wider than its card. Scroll inside the card instead, and let row actions
   wrap onto a second line before it comes to that. */
.p-legacy .ant-table-wrapper { overflow-x: auto !important; } /* beats antd-overrides.css */
.p-legacy .ant-table td > .ant-flex { flex-wrap: wrap; row-gap: 6px; }
.p-legacy .ant-table .ant-btn-sm { white-space: nowrap; }
.p-legacy .ant-table tbody tr:hover > td { background: color-mix(in srgb, var(--p-surface-sunken) 60%, transparent); }

/* Tags and alerts keep their semantic colours but lose the candy look. */
.p-legacy .ant-tag { border-radius: var(--p-radius-pill); font-weight: var(--p-weight-medium); }
.p-legacy .ant-alert { border-radius: var(--p-radius-lg); }

/* ---------- Stat tiles (dashboards) ----------
   One neutral look for key figures: surface, hairline, muted caps label,
   big tabular number. Replaces the pastel Ant tiles (green/blue/purple/
   orange) the old dashboards coloured by hand. */
.p-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--p-space-3); }
.p-root .p-stat {
  background: var(--p-surface-sunken);
  border: 1px solid transparent;
  border-radius: var(--p-radius-lg);
  padding: var(--p-space-4) var(--p-space-5);
  min-width: 0;
}
.p-stat__label { font-size: 11px; font-weight: var(--p-weight-medium); letter-spacing: 0.06em; text-transform: uppercase; color: var(--p-muted); margin-bottom: var(--p-space-1); }
.p-stat__value { font-family: var(--p-font-display); font-size: 2rem; font-weight: var(--p-weight-regular); color: var(--p-ink); line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; letter-spacing: -0.015em; margin-top: var(--p-space-1); }
.p-stat__value--empty { font-size: var(--p-text-md); font-weight: var(--p-weight-regular); color: var(--p-muted); }
.p-stat__sub { font-size: var(--p-text-sm); color: var(--p-muted); margin-top: 2px; }
.p-stat__note { font-size: var(--p-text-xs); color: var(--p-muted); margin-top: var(--p-space-2); line-height: 1.4; }

/* Targets of the Home sub-items in the sidebar: land a little below the top
   (and below the sticky top bar on phones). */
.p-anchor, .p-anchor-target { scroll-margin-top: var(--p-space-5); }
.p-anchor { display: block; height: 0; }
@media (max-width: 960px) { .p-anchor, .p-anchor-target { scroll-margin-top: 68px; } }
html.p-root { scroll-behavior: smooth; }
/* "View as" banner (shell_open.php, StaffImpersonation) */
.p-viewas {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: var(--p-space-4); flex-wrap: wrap;
  margin: 0 0 var(--p-space-5); padding: var(--p-space-3) var(--p-space-5);
  background: #fff4d6; border: 1px solid #e9c46a; border-radius: var(--p-radius-lg);
  color: #5a4300; font-size: var(--p-text-sm);
}

/* Passkey nudge (shell_open.php) */
.p-passkey-nudge {
  display: flex; align-items: center; gap: var(--p-space-4);
  margin-bottom: var(--p-space-5); padding: var(--p-space-4) var(--p-space-5);
  background: var(--p-surface); border: 1px solid var(--p-border); border-left: 3px solid var(--accent);
  border-radius: var(--p-radius-lg); color: var(--p-ink);
}
.p-passkey-nudge > svg { flex: none; color: var(--accent-ink, var(--accent)); }
.p-passkey-nudge__text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; font-size: var(--p-text-sm); }
.p-passkey-nudge__text span { color: var(--p-muted); }
.p-passkey-nudge__error:empty { display: none; }
.p-passkey-nudge__error { color: var(--p-danger) !important; }
.p-passkey-nudge__actions { display: flex; gap: var(--p-space-2); flex: none; }
.p-passkey-nudge.is-done { border-left-color: var(--p-success); }
@media (max-width: 640px) {
  .p-passkey-nudge { flex-wrap: wrap; }
  .p-passkey-nudge__actions { width: 100%; }
  .p-passkey-nudge__actions .p-btn { flex: 1; }
}

/* ---------- 5. Subscribers (Campaigns → Subscribers) ---------- */
.p-sub__layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: var(--p-space-5); align-items: start; }
@media (max-width: 1100px) { .p-sub__layout { grid-template-columns: minmax(0, 1fr); } }
.p-sub__dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--p-space-2) var(--p-space-4); margin: 0; font-size: var(--p-text-sm); }
.p-sub__dl dt { color: var(--p-muted); }
.p-sub__dl dd { margin: 0; color: var(--p-ink); overflow-wrap: anywhere; }
.p-root a.p-sub__tag {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border: 1px solid var(--p-border); border-radius: var(--p-radius-pill);
  background: var(--p-surface-sunken); color: var(--p-body);
  font-size: var(--p-text-xs); text-decoration: none;
}
.p-sub__timeline { list-style: none; margin: 0; padding: 0; max-height: 440px; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--p-border); }
.p-sub__event { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--p-space-3); padding: 9px var(--p-space-5); border-bottom: 1px solid var(--p-border); font-size: var(--p-text-sm); color: var(--p-ink); }
.p-sub__event:last-child { border-bottom: 0; }
.p-sub__event time { color: var(--p-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-sub__event time span { margin-left: 6px; font-size: var(--p-text-xs); }
.p-sub__event.is-mail, .p-sub__event.is-mail a { color: var(--p-muted); }
.p-sub__what { overflow-wrap: anywhere; }
.p-sub__count { margin-left: 6px; font-size: var(--p-text-xs); color: var(--p-muted); }
@media (max-width: 600px) { .p-sub__event { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 9px var(--p-space-4); } }
.p-tags__layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: var(--p-space-5); align-items: start; }
@media (max-width: 1000px) { .p-tags__layout { grid-template-columns: minmax(0, 1fr); } }
.p-tags__search { padding: var(--p-space-3) var(--p-space-4); border-bottom: 1px solid var(--p-border); }
.p-tags__search .p-input { flex: 1; min-width: 0; max-width: 360px; height: var(--p-control-h-sm); }
.p-tags__emails { min-height: 96px; height: auto; padding: 8px 12px; font-family: inherit; resize: vertical; }
.p-tags__pager { padding: var(--p-space-3) var(--p-space-4); }
.p-contacts__filters { padding: var(--p-space-4); display: flex; flex-direction: column; gap: var(--p-space-3); }
.p-contacts__search { display: flex; gap: var(--p-space-2); }
.p-contacts__search .p-input { flex: 1; min-width: 0; }
.p-contacts__selects { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--p-space-3); }
.p-contacts__select { display: flex; flex-direction: column; gap: 4px; min-width: 150px; font-size: var(--p-text-xs); color: var(--p-muted); }
.p-contacts__select--wide { flex: 1; min-width: 200px; max-width: 360px; }
.p-contacts__select .p-select { width: 100%; }
.p-contacts__clear { margin-left: auto; }
.p-contacts__email { overflow-wrap: anywhere; }
.p-contacts__kinds { gap: 4px; }
.p-sub__kind { display: inline-block; padding: 1px 8px; border-radius: var(--p-radius-pill); background: var(--p-surface-sunken); font-size: var(--p-text-xs); color: var(--p-body); white-space: nowrap; }
.p-root a.p-sub__tag:hover { border-color: var(--accent); color: var(--p-ink); }

@media (prefers-reduced-motion: reduce) { html.p-root { scroll-behavior: auto; } }

/* Dashboard "Worth noting" rows. */
.p-root .p-noting-row { display: flex; align-items: center; gap: var(--p-space-3); padding: var(--p-space-2) var(--p-space-3); background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius); flex-wrap: wrap; }
.p-noting-row .p-badge { margin-right: var(--p-space-1); }

/* Toolbar: filters on the left, secondary actions on the right. */
.p-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--p-space-2) var(--p-space-3); margin-bottom: var(--p-space-5); }
.p-toolbar__actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--p-space-2); }
.p-root .p-toolbar .p-select { width: auto; min-width: 160px; max-width: 260px; height: var(--p-control-h-sm); }

/* ---------- 2. Shell ---------- */
.p-shell {
  --p-sidebar-w: 248px;
  min-height: 100vh;
}

.p-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--p-sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--p-surface);
  border-right: 1px solid var(--p-border);
  z-index: 200;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.p-sidebar__head {
  display: flex;
  flex-direction: column;
  gap: var(--p-space-3);
  padding: var(--p-space-4) var(--p-space-4) var(--p-space-3);
}

.p-company {
  display: flex;
  align-items: center;
  gap: var(--p-space-3);
  text-decoration: none;
  color: var(--p-ink);
  min-width: 0;
}
.p-root a.p-company { color: var(--p-ink); text-decoration: none; }
.p-company__logo {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--p-radius-lg);
  background: var(--accent);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.p-company__logo img { width: 22px; height: 22px; object-fit: contain; filter: brightness(0) invert(1); }
.p-company__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.p-company__name { font-family: var(--p-font-display); font-size: var(--p-text-lg); color: var(--p-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-company__product { font-size: var(--p-text-xs); letter-spacing: var(--p-tracking-caps); text-transform: uppercase; color: var(--p-muted); }

/* Company switcher: a disclosure, no JS */
.p-switch { position: relative; }
.p-switch__current {
  display: flex; align-items: center; gap: var(--p-space-2);
  height: var(--p-control-h-sm); padding: 0 var(--p-space-3);
  border: 1px solid var(--p-border); border-radius: var(--p-radius);
  background: var(--p-surface); color: var(--p-ink);
  font-size: var(--p-text-sm); font-weight: var(--p-weight-medium);
  cursor: pointer; list-style: none; user-select: none;
  transition: border-color .15s, background .15s;
}
.p-switch__current::-webkit-details-marker { display: none; }
.p-switch__current:hover { border-color: var(--p-border-strong); }
.p-switch__current:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--p-accent-soft, rgba(0,0,0,.08)); }
.p-switch__hint { margin-left: auto; font-size: var(--p-text-xs); font-weight: var(--p-weight-regular); color: var(--p-muted); }
.p-switch__chevron { color: var(--p-muted); transition: transform .15s; }
.p-switch[open] .p-switch__chevron { transform: rotate(180deg); }
.p-switch__dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--p-border-strong); }
.p-switch__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-switch__menu {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  display: flex; flex-direction: column; padding: 4px;
  background: var(--p-surface); border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg); box-shadow: 0 8px 24px rgba(20, 20, 20, .10);
}
.p-switch__option {
  display: flex; align-items: center; gap: var(--p-space-2); width: 100%;
  padding: 7px var(--p-space-3); border: 0; border-radius: var(--p-radius);
  background: none; color: var(--p-ink); font: inherit; font-size: var(--p-text-sm);
  text-align: left; cursor: pointer;
}
button.p-switch__option:hover, button.p-switch__option:focus-visible { background: var(--p-surface-sunken); outline: none; }
.p-switch__option.is-current { font-weight: var(--p-weight-medium); cursor: default; }
.p-switch__option.is-current svg { margin-left: auto; color: var(--accent-ink, var(--accent)); }
.p-switch__option.is-disabled { color: var(--p-muted); cursor: not-allowed; }

/* Customer search */
.p-search { position: relative; }
.p-search__input {
  width: 100%;
  height: var(--p-control-h-sm);
  padding: 0 var(--p-space-3) 0 30px;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  background: var(--p-bg);
  color: var(--p-ink);
  font: inherit;
  font-size: var(--p-text-sm);
}
.p-search__input::placeholder { color: var(--p-muted); }
.p-search__input:focus { outline: none; border-color: var(--accent); background: var(--p-field-bg); box-shadow: 0 0 0 3px var(--p-accent-soft, rgba(0,0,0,.08)); }
.p-search__icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--p-muted); pointer-events: none; }
.p-search__results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: max(100%, 300px);
  max-height: 60vh;
  overflow-y: auto;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-md);
  z-index: 300;
}
.p-search__results[hidden] { display: none; }
.p-search__result {
  display: block;
  padding: var(--p-space-2) var(--p-space-3);
  border-bottom: 1px solid var(--p-border);
  color: var(--p-ink);
  text-decoration: none;
}
.p-root a.p-search__result { color: var(--p-ink); text-decoration: none; }
.p-search__result:last-child { border-bottom: 0; }
.p-search__result:hover,
.p-search__result[aria-selected="true"] { background: var(--p-surface-sunken); }
.p-search__result-name { font-weight: var(--p-weight-medium); display: block; }
.p-search__result-meta { font-size: var(--p-text-xs); color: var(--p-muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-search__empty { padding: var(--p-space-3); font-size: var(--p-text-sm); color: var(--p-muted); }

/* Nav */
.p-nav { flex: 1; padding: var(--p-space-2) var(--p-space-3) var(--p-space-4); display: flex; flex-direction: column; gap: var(--p-space-4); }
.p-nav__group { display: flex; flex-direction: column; gap: 2px; }
.p-nav__label {
  padding: 0 var(--p-space-2) var(--p-space-1);
  font-size: 0.6875rem;
  font-weight: var(--p-weight-semibold);
  letter-spacing: var(--p-tracking-caps);
  text-transform: uppercase;
  color: var(--p-muted);
}
.p-nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--p-space-3);
  min-height: 34px;
  padding: 0 var(--p-space-2);
  border-radius: var(--p-radius);
  color: var(--p-body);
  font-size: var(--p-text-md);
  text-decoration: none;
  transition: background var(--p-duration), color var(--p-duration);
}
.p-root a.p-nav__item { color: var(--p-body); text-decoration: none; }
.p-nav__item svg { flex: none; color: var(--p-muted); transition: color var(--p-duration); }
.p-root a.p-nav__item:hover { background: var(--p-surface-sunken); color: var(--p-ink); }
.p-nav__item:hover svg { color: var(--p-ink); }
.p-root a.p-nav__item[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--p-ink);
  font-weight: var(--p-weight-medium);
}
.p-nav__item[aria-current="page"] svg { color: var(--accent-ink); }
.p-nav__item[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}

/* Sub-items (Venues under Programs, Event tag pages under Events): indented
   under the parent's label, a hairline guide on the left. */
.p-root a.p-nav__item--child {
  min-height: 30px;
  margin-left: calc(var(--p-space-2) + 18px + var(--p-space-3) - var(--p-space-2));
  padding-left: var(--p-space-3);
  border-left: 1px solid var(--p-border);
  border-radius: 0 var(--p-radius) var(--p-radius) 0;
  font-size: var(--p-text-sm);
  color: var(--p-muted);
}
.p-root a.p-nav__item--child[aria-current="page"] { color: var(--p-ink); border-left-color: var(--accent); }
.p-nav__item--child[aria-current="page"]::before { display: none; }
.p-root a.p-nav__item.is-open:not([aria-current="page"]) { color: var(--p-ink); }

.p-sidebar__foot {
  border-top: 1px solid var(--p-border);
  padding: var(--p-space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.p-user { display: flex; align-items: center; gap: var(--p-space-3); padding: var(--p-space-2); margin-bottom: var(--p-space-1); min-width: 0; }
.p-user__avatar {
  width: 28px; height: 28px; flex: none;
  border-radius: 50%;
  background: var(--p-surface-sunken);
  border: 1px solid var(--p-border);
  display: grid; place-items: center;
  font-size: var(--p-text-xs); font-weight: var(--p-weight-semibold); color: var(--p-ink);
  text-transform: uppercase;
}
.p-user__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.p-user__name { color: var(--p-ink); font-weight: var(--p-weight-medium); font-size: var(--p-text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-user__role { color: var(--p-muted); font-size: var(--p-text-xs); }

/* Main */
/* `main.p-main` outranks antd-overrides.css's bare `main` rule (a white,
   shadowed, 24px-inset box — the old layout's page frame). */
.p-root main.p-main {
  margin: 0 0 0 var(--p-sidebar-w);
  min-width: 0;
  min-height: 100vh;
  padding: var(--p-space-6) var(--p-space-6) var(--p-space-8);
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.p-main__inner { max-width: 1280px; margin: 0 auto; }
.p-flash { margin-bottom: var(--p-space-4); }

.p-env {
  margin-top: var(--p-space-8);
  font-size: var(--p-text-xs);
  color: var(--p-muted);
  display: flex;
  gap: var(--p-space-4);
}
.p-env p { margin: 0; }

/* Mobile top bar (hidden on desktop) */
.p-topbar { display: none; }

.p-skip {
  position: absolute; left: -9999px; top: 8px; z-index: 400;
  background: var(--p-surface); color: var(--p-ink); padding: var(--p-space-2) var(--p-space-3);
  border: 1px solid var(--p-border-strong); border-radius: var(--p-radius);
}
.p-skip:focus { left: 8px; }

.p-scrim { display: none; }

@media (max-width: 960px) {
  .p-topbar {
    position: sticky;
    top: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: var(--p-space-3);
    height: 52px;
    padding: 0 var(--p-gutter);
    background: var(--p-surface);
    border-bottom: 1px solid var(--p-border);
  }
  .p-topbar__menu {
    display: grid; place-items: center;
    width: 36px; height: 36px; margin-left: -8px;
    border: 0; background: transparent; color: var(--p-ink);
    border-radius: var(--p-radius); cursor: pointer;
  }
  .p-topbar__menu:hover { background: var(--p-surface-sunken); }
  .p-topbar .p-company__logo { width: 26px; height: 26px; }
  .p-topbar .p-company__logo img { width: 18px; height: 18px; }

  .p-sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: none;
  }
  .p-shell.is-open .p-sidebar { transform: none; box-shadow: var(--p-shadow-md); }
  .p-shell.is-open .p-scrim {
    display: block;
    position: fixed; inset: 0; z-index: 190;
    background: rgb(17 12 10 / 0.35);
  }
  .p-root main.p-main { margin: 0; min-height: 0; padding: var(--p-space-4) var(--p-gutter) var(--p-space-7); }
  .p-legacy { overflow-x: hidden; }
  .p-legacy .table-responsive,
  .p-legacy .ant-table-wrapper { overflow-x: auto; }
}

/* ---------- 3. Staff login and other Shield pages (auth/layout.php) ---------- */
.p-root body.p-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--p-space-6) var(--p-gutter);
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--p-bg);
}
.p-auth__frame { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--p-space-5); }
.p-auth__brand { display: flex; align-items: center; gap: var(--p-space-3); justify-content: center; }
.p-auth__card,
.p-auth__main > .container {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  padding: var(--p-space-6);
  box-shadow: var(--p-shadow-sm);
}
.p-auth__card { display: flex; flex-direction: column; gap: var(--p-space-4); }
.p-auth__title { font-family: var(--p-font-display); font-weight: 400; font-size: var(--p-text-2xl); color: var(--p-ink); letter-spacing: -0.01em; }
.p-auth__lead { color: var(--p-muted); margin-top: calc(var(--p-space-3) * -1); }
.p-auth__divider { display: flex; align-items: center; gap: var(--p-space-3); color: var(--p-muted); font-size: var(--p-text-sm); }
.p-auth__divider::before, .p-auth__divider::after { content: ''; flex: 1; height: 1px; background: var(--p-border); }
.p-auth__divider[hidden] { display: none; }
.p-auth__passkey { display: flex; flex-direction: column; gap: var(--p-space-2); }
.p-auth__passkey[hidden] { display: none; }
.p-auth__hint { text-align: center; font-size: var(--p-text-sm); color: var(--p-muted); }
.p-auth__members { text-align: center; font-size: var(--p-text-sm); color: var(--p-muted); }

/* Shield's stock views (magic link etc.) are Bootstrap: frame them the same way. */
.p-auth__main > .container { max-width: none; margin: 0; }
.p-auth__main > .container > .card { border: 0; box-shadow: none !important; width: 100%; max-width: none; flex: 1 1 auto; background: transparent; }
.p-auth__main > .container.p-5 { padding: var(--p-space-6) !important; }
.p-auth__main .card-body { padding: 0; }
.p-auth__main .card-title { font-family: var(--p-font-display); font-weight: 400; font-size: var(--p-text-xl); color: var(--p-ink); margin-bottom: var(--p-space-4) !important; }
.p-auth__main .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); border-radius: var(--p-radius); }
.p-auth__main .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.p-auth__main .form-control { border-color: var(--p-border-strong); border-radius: var(--p-radius); }
.p-auth__main .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--p-accent-soft); }
.p-auth__main a { color: var(--p-accent-text); }

/* ---------- 4. Campaign editor (/cms/campaigns/{id}) ---------- */
.p-campaign__layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: var(--p-space-5); align-items: start; }
.p-campaign__side { position: sticky; top: var(--p-space-5); }
.p-campaign__fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--p-space-4); }
.p-campaign__wide { grid-column: 1 / -1; }
.p-campaign__fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--p-space-2); min-width: 0; }
.p-campaign__fieldset[disabled] { opacity: 0.7; }
.p-campaign__checks {
  max-height: 220px; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 6px;
  padding: var(--p-space-2) var(--p-space-3);
  border: 1px solid var(--p-border); border-radius: var(--p-radius); background: var(--p-field-bg);
}
.p-campaign__checks .p-check[hidden] { display: none; }
.p-campaign__filter { height: var(--p-control-h-sm); }
.p-campaign__statuses { display: flex; flex-direction: column; gap: var(--p-space-2); }
.p-campaign__count { font-size: var(--p-text-sm); color: var(--p-muted); white-space: nowrap; }
.p-campaign__count strong { font-size: var(--p-text-xl); color: var(--p-ink); font-variant-numeric: tabular-nums; margin-right: 4px; }
.p-campaign__preview { background: #f4f1ec; padding: var(--p-space-3); display: flex; justify-content: center; overflow-x: auto; }
.p-campaign__preview iframe { width: 640px; max-width: none; height: 70vh; min-height: 480px; border: 0; background: #f4f1ec; transition: width 160ms ease; }
.p-campaign__problems { margin: 0; padding-left: 1.1em; color: var(--p-warning); font-size: var(--p-text-sm); display: flex; flex-direction: column; gap: 4px; }
.p-campaign__savebar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; justify-content: flex-end; align-items: center; gap: var(--p-space-3);
  padding: var(--p-space-3) 0; background: linear-gradient(to top, var(--p-bg) 70%, transparent);
}
.p-campaign__savebar [hidden] { display: none; }

.p-blocks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--p-space-3); }
.p-blocks__item { border: 1px solid var(--p-border); border-radius: var(--p-radius-lg); background: var(--p-bg); }
.p-blocks__head { display: flex; align-items: center; justify-content: space-between; gap: var(--p-space-2); padding: var(--p-space-1) var(--p-space-2) var(--p-space-1) var(--p-space-4); border-bottom: 1px solid var(--p-border); }
.p-blocks__type { font-size: var(--p-text-xs); font-weight: var(--p-weight-semibold); letter-spacing: var(--p-tracking-caps); text-transform: uppercase; color: var(--p-muted); }
.p-blocks__tools { display: flex; gap: 2px; }
.p-blocks__fields { padding: var(--p-space-4); display: flex; flex-direction: column; gap: var(--p-space-3); }
.p-blocks__empty { padding: var(--p-space-4); border: 1px dashed var(--p-border-strong); border-radius: var(--p-radius-lg); text-align: center; }

@media (max-width: 1180px) {
  .p-campaign__layout { grid-template-columns: minmax(0, 1fr); }
  .p-campaign__side { position: static; }
  .p-campaign__preview iframe { height: 560px; }
}
@media (max-width: 640px) {
  .p-campaign__fields { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .p-sidebar, .p-nav__item, .p-legacy .ant-btn { transition: none; }
}

@media print {
  .p-sidebar, .p-topbar, .p-env { display: none !important; }
  .p-root main.p-main { margin: 0; padding: 0; }
}
