/* ══════════════════════════════════════════════════════════════════════════
   sf-final-admin.css — Core Chain Labs · the operator console, on brand.

   WHY THIS FILE EXISTS. admin.html links exactly two stylesheets — the font
   faces and the minified Tailwind build (`/admin.css`). It links NO theme.css,
   NO sf-base.css and NO sf-refresh.css, so not one of the client's --cc-*
   values, none of its solved chrome and neither half of its type pair has ever
   reached the panel. It rendered in the engine's stock shadcn-neutral skin:
   #fafafa / #0a0a0a greys, a #2563ef blue that belongs to no client, and a body
   face ('Public Sans') that appears nowhere else on this site.

   THE FIX IS NOT "LINK THE STOREFRONT SHEETS". theme.css and sf-base.css carry
   the storefront's layout grammar (grids, section rhythm, .sf-* components) and
   dropping them onto a fixed-sidebar dashboard drags that layout in. So this
   sheet re-declares the client's ramp LOCALLY and re-points the panel's own
   shadcn token contract at it. Nothing structural is imported; every rule below
   is a colour, a font or a contrast repair.

   CONTRAST IS ARITHMETIC HERE, NOT TASTE. Every pair below was measured with
   the WCAG relative-luminance formula against the composited ground and is
   recorded beside the token. Floors: 4.5:1 body, 3:1 large text and UI edges.
   Two rules from BUILD-DEFAULTS travel with them: de-emphasis is a SOLVED
   second colour, never an alpha fade (a faded ink walks back toward its own
   ground and no gate can measure it), and the chrome is OPAQUE.

   ORDER. The runner links this sheet LAST in <head> — after fonts.css and
   after the Tailwind build — so an ordinary selector wins on equal
   specificity. `!important` appears in exactly one place: the [style*=]
   remaps at the bottom, which have to beat an inline attribute. That block is
   an idempotent CSS repair on purpose — the alternative was 400+ string edits
   inside a 616 KB document.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1. The client's own ramp, declared locally ────────────────────────────
   Copied from sf-refresh.css (the brand mark's own navy + cyan). Kept as the
   --cc-* names so a reader can diff the two files and see they agree. */
:root {
  --cc-navy-900: #071A33;
  --cc-navy-800: #0C2440;
  --cc-navy-700: #10294A;
  --cc-navy-600: #17406B;
  --cc-blue-600: #1C5E96;
  --cc-teal-700: #135C6E;
  --cc-teal-600: #1B7C8C;
  --cc-cyan-400: #16BFD1;
  --cc-cyan-300: #57D6E4;
  --cc-cyan-100: #C9F0F6;
  --cc-silver-500: #7E93A6;
  --cc-silver-200: #CBD9E4;
  --cc-ice-100: #E4F1F9;
  --cc-ice-50:  #F1F8FC;
  --cc-metal-100: #F0F6FA;
  --cc-metal-300: #A6BACB;
  --cc-bg:       #060E1A;
  --cc-surface:  #0C1726;
  --cc-elevated: #142235;
  --cc-accent:   #3FB6C9;

  /* Type. The panel already asks for var(--sf-font-display) on every heading
     and var(--sf-font-body) on <body>; neither was ever defined here, so the
     hard-coded fallbacks decided the panel's face. These are the client's real
     pair — the same two families theme.css hands the storefront. */
  /* THE PAIR IS NOT DECLARED HERE ANY MORE (2026-08-20). It was, and it went
     stale the first time somebody moved the sitewide pair: this sheet is linked
     on the storefront too, so a bare :root pin here was a second source of truth
     racing the first. sf-final-typography.css now resolves the pair the way a
     browser does — theme.css then sf-refresh.css, last :root declaration wins —
     and is linked on all 26 pages including this one. One source, and it
     follows whoever changes the faces next. */

  /* The brand-mark filters build.mjs injects flatten a two-colour lockup to a
     single silhouette. The chrome below is navy in BOTH themes, so the on-dark
     artwork is correct as drawn and needs no filter at all. */
  --sf-admin-logo-filter: none;
  --sf-admin-logo-filter-dark: none;
}

/* ── 2. LIGHT — white page, brand ink ──────────────────────────────────────
   Measured on this ground:
     foreground  #071A33 on #FFFFFF        17.53:1
     muted ink   #4E6377 on #FFFFFF         6.22 · on --muted #F1F8FC  5.80
     pos         #046B4E on #FFFFFF         6.53 · on --muted          6.08
     info        #175A8F on #FFFFFF         7.25 · on --muted          6.76
     warn        #A3480B on #FFFFFF         6.02 · on --muted          5.61
     neg         #B91C1C on #FFFFFF         6.47 · on --muted          6.03
     primary fill #10294A with #F0F6FA ink 13.40 */
:root {
  --background: #FFFFFF;
  --foreground: #071A33;
  --card: #FFFFFF;
  --card-foreground: #071A33;
  --popover: #FFFFFF;
  --popover-foreground: #071A33;
  --muted: var(--cc-ice-50);
  --muted-foreground: #4E6377;
  --secondary: var(--cc-ice-50);
  --secondary-foreground: #071A33;
  --accent: var(--cc-ice-100);
  --accent-foreground: #071A33;
  --border: var(--cc-silver-200);
  --input: var(--cc-silver-200);
  --ring: #175A8F;
  --primary: var(--cc-navy-700);
  --primary-foreground: var(--cc-metal-100);
  --destructive: #B91C1C;
  --destructive-foreground: #FFFFFF;

  /* Semantic INK. Separate from the FILL tokens below on purpose: the same
     idea needs a dark value when it is type on the page and a mid value when
     it is a plate carrying white type, and collapsing the two is how a panel
     ends up with #34d399 text on white (1.92:1, measured). */
  --pos:  #046B4E;
  --info: #175A8F;
  --warn: #A3480B;
  --neg:  #B91C1C;

  /* Semantic FILL — a plate that always carries WHITE type, so each of these
     clears 4.5:1 against #FFFFFF and is IDENTICAL in both themes. */
  --pos-fill:  #046B4E;   /* white on it 6.53 */
  --info-fill: #175A8F;   /* white on it 7.25 */
  --warn-fill: #A3480B;   /* white on it 6.02 */
  --neg-fill:  #B91C1C;   /* white on it 6.47 */
  --ink-fill:  #10294A;   /* white on it 14.4  */

  /* A second ink one step below --foreground, for the sub-labels the panel
     writes as #374151. Solved, not faded. */
  --ink-2: #2A3D52;       /* on #FFFFFF 11.13 · on --muted 10.37 */
  --border-strong: #93A9BC;

  /* Charts. --chart-1 is used as a PLATE behind dark type in Finance, so it is
     kept light in both themes; the rest are the brand ramp in depth order. */
  --chart-1: #A8D3F5;
  --chart-2: var(--cc-blue-600);
  --chart-3: #175A8F;
  --chart-4: var(--cc-teal-700);
  --chart-5: var(--cc-navy-700);
  --cc-chart-tick: #4E6377;
  --cc-chart-grid: rgb(78 99 119 / 0.18);
}

/* ── 3. DARK — the storefront's own deep navy, not near-neutral black ───────
   Measured on --background #060E1A / --card #0C1726 / --accent #142235:
     foreground   #F0F6FA   17.75 · 14.60 · 12.28
     muted ink    #A6BACB    9.68 ·  9.01 ·  8.02
     pos          #34D399   10.06 ·  9.37 ·  8.34
     info         #57D6E4   11.19 · 10.41 ·  9.27
     warn         #FBBF24   11.59 · 10.79 ·  9.60
     neg          #F87171    6.99 ·  6.51 ·  5.80
     primary fill #3FB6C9 with #04141A ink 7.81 */
.dark {
  --background: var(--cc-bg);
  --foreground: var(--cc-metal-100);
  --card: var(--cc-surface);
  --card-foreground: var(--cc-metal-100);
  --popover: var(--cc-surface);
  --popover-foreground: var(--cc-metal-100);
  --muted: var(--cc-elevated);
  /* The stock sheet writes `--muted-foreground: var(--muted-foreground)` here.
     A self-referential custom property is a CYCLE: it computes to the
     guaranteed-invalid value, so every `var(--muted-foreground)` downstream
     falls back to the INHERITED colour instead of a muted one. That is why a
     .tab-count measured 1.09:1 — white on #f5f5f5. Pinned to a real hex. */
  --muted-foreground: var(--cc-metal-300);
  --secondary: var(--cc-elevated);
  --secondary-foreground: var(--cc-metal-100);
  --accent: var(--cc-elevated);
  --accent-foreground: var(--cc-metal-100);
  --border: #24384F;
  --input: #2C4259;
  --ring: var(--cc-cyan-300);
  --primary: var(--cc-accent);
  --primary-foreground: #04141A;
  --destructive: #B91C1C;
  --destructive-foreground: #FFFFFF;

  --pos:  #34D399;
  --info: var(--cc-cyan-300);
  --warn: #FBBF24;
  --neg:  #F87171;

  --ink-2: #D6E3EC;       /* on --background 14.4 · on --card 11.9 */
  --border-strong: #43607D;

  --chart-1: #A8D3F5;
  --chart-2: #6FC3FF;
  --chart-3: var(--cc-cyan-300);
  --chart-4: #4A9BD4;
  --chart-5: var(--cc-silver-200);
  --cc-chart-tick: var(--cc-metal-300);
  --cc-chart-grid: rgb(166 186 203 / 0.18);
}

/* ── 4. CHROME — the sidebar is BRAND-COLOURED in both themes ──────────────
   Two things are fixed at once here. The panel painted the sidebar --sidebar
   (#fafafa light / #0a0a0a dark) and put LOGO-ONDARK.webp on it unconditionally
   — light artwork on a near-white bar, i.e. an invisible logo for the twelve
   daylight hours the theme script chooses light. Making the bar navy in both
   themes makes the on-dark lockup correct as drawn, and gives the console the
   same brand chrome the storefront carries.
     ink       #F0F6FA on #071A33  16.00
     dim ink   #A6BACB on #071A33   8.72   (SOLVED, not an opacity fade)
     active bg #142235, ink #F0F6FA 14.71
     accent    #57D6E4 on #071A33  10.08 */
:root, .dark {
  --sidebar: var(--cc-navy-900);
  --sidebar-foreground: var(--cc-metal-100);
  --sidebar-border: #16324F;
  --sidebar-accent: var(--cc-elevated);
  --sidebar-accent-foreground: var(--cc-metal-100);
  --sidebar-primary: var(--cc-cyan-300);
  --sidebar-primary-foreground: #04141A;
  --sidebar-ring: var(--cc-cyan-300);
}

#admin-sidebar,
#mobile-header { background: var(--cc-navy-900); border-color: #16324F; }

/* .sidebar-link resolves var(--muted-foreground), which is now a PAGE ink and
   measures 2.0:1 on navy. Scoped to its own solved pair instead. */
#admin-sidebar .sidebar-link { color: var(--cc-metal-300); }               /* 8.72 */
#admin-sidebar .sidebar-link:hover,
#admin-sidebar .sidebar-link.active {
  background: var(--cc-elevated); color: var(--cc-metal-100);              /* 14.71 */
}
#admin-sidebar .sidebar-link.active { box-shadow: inset 2px 0 0 var(--cc-cyan-300); }
#admin-sidebar .sidebar-link:focus-visible,
#admin-sidebar .theme-toggle:focus-visible { outline: 2px solid var(--cc-cyan-300); outline-offset: 2px; }

/* The group headings were a muted ink at opacity .62 — a fade on a bar the
   page scrolls under. Solved silver at full opacity instead. */
#admin-sidebar .nav-group { color: #9FB3C4 !important; opacity: 1 !important; }   /* 8.07 */
/* "Admin Dashboard" under the lockup carries an INLINE var(--muted-foreground),
   which is a page ink and measures 2.80:1 on the navy bar. */
#admin-sidebar > div:first-child > div:last-child { color: var(--cc-metal-300) !important; }
#admin-sidebar .theme-toggle { color: var(--cc-metal-300); border-color: #16324F; }
#admin-sidebar .theme-toggle:hover { background: var(--cc-elevated); color: var(--cc-metal-100); }
#mobile-header #hamburger-btn { background: var(--cc-elevated); border-color: #16324F; color: var(--cc-metal-100); }

/* The logo is the client's own two-colour artwork now — no silhouette filter. */
#admin-sidebar .brand-logo,
#mobile-header .brand-logo,
.dark #admin-sidebar .brand-logo,
.dark #mobile-header .brand-logo { filter: none; }

/* ── 5. Type ───────────────────────────────────────────────────────────────
   body already reads var(--sf-font-body) and every heading var(--sf-font-display);
   §1 defines both, so this only carries the numerals rule. Tabular figures make
   a money column line up — every table in Orders, Stock and Finance is money. */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) table td, :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) table th,
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) .stat-card p, :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) input[type="number"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ── 6. Components ─────────────────────────────────────────────────────────*/
.btn-teal { background: var(--info-fill); color: #FFFFFF; }               /* 7.25 */
.btn-red  { background: var(--neg-fill);  color: #FFFFFF; }               /* 6.47 */
.btn-dark { background: var(--primary);   color: var(--primary-foreground); }
.btn:focus-visible, .test-email-pill:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px rgb(23 90 143 / 0.22); }
.dark .input:focus { box-shadow: 0 0 0 3px rgb(87 214 228 / 0.22); }

/* Status badges. The stock pairs were tuned for a neutral panel and several
   measured under 3:1 on this ground; each pair below is solved. */
.badge-pending_payment { background: rgb(163 72 11 / 0.12); color: var(--warn); }
.badge-processing      { background: rgb(23 90 143 / 0.12); color: var(--info); }
.badge-shipped         { background: rgb(23 90 143 / 0.12); color: var(--info); }
.badge-delivered       { background: rgb(4 107 78 / 0.12);  color: var(--pos); }
.badge-refunded        { background: var(--muted);          color: var(--muted-foreground); }
.badge-cancelled       { background: var(--muted);          color: var(--muted-foreground); }
.dark .badge-pending_payment { background: rgb(251 191 36 / 0.16); color: var(--warn); }
.dark .badge-processing,
.dark .badge-shipped         { background: rgb(87 214 228 / 0.14); color: var(--info); }
.dark .badge-delivered       { background: rgb(52 211 153 / 0.14); color: var(--pos); }
.dark .badge-refunded,
.dark .badge-cancelled       { background: var(--muted);           color: var(--muted-foreground); }

/* Payments re-declares all of these at id specificity FROM A <style> BLOCK IN
   THE BODY — which sits after this sheet in document order, so "linked last"
   does not win here and the selectors have to out-specify it. Two ids do. */
.pill-matched,   #admin-main #section-payments .pill-matched   { background: rgb(4 107 78 / 0.12);  color: var(--pos); }
.pill-partial,   #admin-main #section-payments .pill-partial   { background: rgb(163 72 11 / 0.14); color: var(--warn); }
.pill-ambiguous, #admin-main #section-payments .pill-ambiguous,
#admin-main #section-payments .pill-unmatched                  { background: rgb(185 28 28 / 0.12); color: var(--neg); }
.dark .pill-matched,   .dark #admin-main #section-payments .pill-matched   { background: rgb(52 211 153 / 0.14); color: var(--pos); }
.dark .pill-partial,   .dark #admin-main #section-payments .pill-partial   { background: rgb(251 191 36 / 0.16); color: var(--warn); }
.dark .pill-ambiguous, .dark #admin-main #section-payments .pill-ambiguous,
.dark #admin-main #section-payments .pill-unmatched                        { background: rgb(248 113 113 / 0.16); color: var(--neg); }

/* --chart-3 is text-safe in both themes (#175A8F light, #57D6E4 dark), which
   is right for the eleven places that use it as a link or a border and WRONG
   for the five that use it as a PLATE under white type — white on #57D6E4 is
   1.73:1. Every plate is re-pointed at the fill token; the inline ones are
   covered by the attribute remap in §7. */
.btn-teal,
.studio-progress > div,
#admin-main #section-affiliates .aff-filter-tab.active,
#admin-main #section-affiliates .aff-act-btn.pay,
#admin-main #section-payments .mini-btn.primary {
  background: var(--info-fill);
  border-color: var(--info-fill);
  color: #FFFFFF;                                   /* on #175A8F 7.25 */
}

/* .tab-count inherits its colour when --muted-foreground is a cycle (§3). Pin
   both halves so it can never composite to white-on-white again. */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) .tab-count { background: var(--muted); color: var(--muted-foreground); }

.stat-card { background: var(--card); border-color: var(--border); }
.table-row:hover { background: var(--muted); }
.studio-tab.active { border-bottom-color: var(--ring); color: var(--foreground); }
.studio-drop:hover, .studio-drop.is-over { border-color: var(--ring); }
.studio-drop-link { color: var(--info); }
.studio-drop-file, .studio-drop.is-done { color: var(--pos); border-color: var(--pos); }
.test-email-pill.success { background: rgb(4 107 78 / 0.12); border-color: var(--pos); color: var(--pos); }
.test-email-pill.fail    { background: rgb(185 28 28 / 0.12); border-color: var(--neg); color: var(--neg); }
.dark .test-email-pill.success { background: rgb(52 211 153 / 0.14); color: var(--pos); }
.dark .test-email-pill.fail    { background: rgb(248 113 113 / 0.16); color: var(--neg); }
.test-email-pill.active, .test-email-pill:hover { border-color: var(--ring); color: var(--info); background: rgb(23 90 143 / 0.10); }
.dark .test-email-pill.active, .dark .test-email-pill:hover { background: rgb(87 214 228 / 0.12); }

/* The SPA's own re-auth screen (shown when a session expires under the app,
   not the server-rendered /admin gate) picks up the brand ground + mark. */
#login-screen { background: var(--cc-navy-900); }
#login-screen > div { border: 1px solid var(--cc-silver-200); }
#login-error { color: var(--neg-fill); }

/* ── 7. Inline-literal repair ──────────────────────────────────────────────
   Everything below re-points a hard-coded hex that lives in a style="" attribute
   on the panel's own markup. Scoped to :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) so the two modals that sit
   OUTSIDE the shell — the email preview (a white paper surface by design) and
   the delete confirm — keep their own literals. `!important` is required: an
   attribute beats a stylesheet at every specificity.

   Each group is one idea, and each maps to a token that is solved in BOTH
   themes, which is what makes the panel actually follow its own toggle. */

/* ink */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#111827"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #111827"] { color: var(--foreground) !important; }
/* #0A1428 is the brand's own navy, used as an INK on the order modal's cards —
   which are --card, so in dark mode it is navy type on a navy plate (1.02:1). */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#0A1428"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #0A1428"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#374151"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #374151"] { color: var(--ink-2) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#6B7280"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#6b7280"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #6b7280"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#4b5563"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#4B5563"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#6B7280"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#9CA3AF"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#9ca3af"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#94a3b8"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#737373"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #737373"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#525252"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #525252"] { color: var(--muted-foreground) !important; }

/* positive / money */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#059669"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#047857"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#10b981"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#16a34a"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#16A34A"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#22c55e"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#2dd4bf"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#0d9488"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#0f766e"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#14b8a6"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#34d399"] { color: var(--pos) !important; }

/* informational / links */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#2563ef"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #2563ef"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#2563eb"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#1d4ed8"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #1d4ed8"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#3a81f6"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#60a5fa"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #60a5fa"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#91c5ff"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#93C5FD"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#93c5fd"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#bfdbfe"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#7c3aed"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#4f46e5"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color: #bfdbfe"] { color: var(--info) !important; }

/* warning */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#f59e0b"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#fbbf24"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#fcd34d"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#d97706"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#D97706"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#F59E0B"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#b45309"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#B45309"] { color: var(--warn) !important; }

/* negative */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#dc2626"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#DC2626"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#ef4444"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:#f87171"] { color: var(--neg) !important; }

/* Two Finance plates carry type at rgba(0,0,0,.5) — a fade over a tint, which
   composited to 3.47:1. Solid navy on a light plate instead: 12.6:1. */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:rgba(0,0,0,0.5)"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="color:rgba(0,0,0,0.55)"] { color: #071A33 !important; }

/* surfaces.
   EVERY background rule below matches the `;`-terminated form or the end of the
   attribute, NEVER a bare prefix. The panel emits pill tints as an EIGHT-digit
   hex (`background:#16a34a1f`), and a prefix match swallows the alpha suffix
   and repaints the tint as a solid plate — which is exactly how a pill ends up
   the same colour as its own label (measured 1.00:1 before this was tightened). */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#fff;"],  :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#fff"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#ffffff;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#ffffff"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#FFFFFF;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#FFFFFF"] { background: var(--card) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#F9FAFB;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#F9FAFB"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#F3F4F6;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#F3F4F6"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#f5f5f5;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#f5f5f5"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#F0F2F5;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#F0F2F5"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#EEF1F4;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#EEF1F4"] { background: var(--muted) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#0A1428;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#0A1428"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#111C2E;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#111C2E"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#0D1B3E;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#0D1B3E"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#111827;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#111827"] { background: var(--ink-fill) !important; }

/* plates that carry white type */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#2563ef;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#2563ef"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#1d4ed8;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#1d4ed8"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:var(--chart-3);"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:var(--chart-3)"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background: var(--chart-3);"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background: var(--chart-3)"] { background: var(--info-fill) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#059669;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#059669"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#16a34a;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#16a34a"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#10b981;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#10b981"] { background: var(--pos-fill) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#ef4444;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#ef4444"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#dc2626;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#dc2626"] { background: var(--neg-fill) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#9ca3af;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#9ca3af"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#525252;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#525252"] { background: var(--border-strong) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="background:#91c5ff;"], :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style$="background:#91c5ff"] { background: var(--chart-1) !important; }

/* A plate keeps white type only when the plate is dark. Two places write
   `color:#fff` onto a TABLE CELL whose row is --card — white on white in light
   mode, and invisible either way if the theme flips. Cells and the count chip
   take the surface's own ink; buttons on a coloured plate are left alone. */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) td[style*="color:#fff"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) th[style*="color:#fff"] { color: var(--foreground) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) .tab-count[style*="color:#fff"] { color: var(--muted-foreground) !important; }

/* hairlines */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="#E5E7EB"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="#D1D5DB"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="#e5e7eb"] { border-color: var(--border) !important; }

/* form controls the panel styles by hand */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="accent-color:#111827"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="accent-color:#2563ef"],
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="accent-color:#14b8a6"] { accent-color: var(--ring) !important; }
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="accent-color:#f59e0b"] { accent-color: var(--warn-fill) !important; }

/* The Marketing panel pins its own inputs to #fff/#111827 from the page's
   <style> block, which the remap above cannot reach (it is a rule, not an
   attribute). Re-point it here so the panel follows the theme like the rest. */
#section-marketing #mkt-panel-settings input,
#section-marketing #mkt-test-email {
  background: var(--background) !important;
  color: var(--foreground) !important;
  border-color: var(--input) !important;
}

/* ── 7b. DARK ISLANDS ──────────────────────────────────────────────────────
   Three surfaces are deliberately dark plates in BOTH themes — the System
   Status cards, the order modal, the payment-notification rows — and each says
   so by re-declaring --foreground/--muted-foreground on itself. The semantic
   inks have to follow: a status pill remapped to the page's --pos is a DARK
   green on a navy plate in light mode (measured 1.74:1). Matching on the
   island's own declaration means a new island is covered the day it is written,
   with no list to keep. */
:is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) [style*="--foreground:#f1f5f9"] {
  /* The island declares the VARIABLE but never sets its own `color`, so its
     children inherited the PAGE ink — navy type on a navy plate in light mode.
     One line closes it, and closes it for anything added to the plate later. */
  color: var(--foreground);
  --pos:  #34D399;   /* on #10294A  8.32 */
  --info: #6FC3FF;   /* on #10294A  8.33 */
  --warn: #FBBF24;   /* on #10294A  9.58 */
  --neg:  #F87171;   /* on #10294A  5.78 */
  --ink-2: #D6E3EC;
  --muted-foreground: #A6BACB;
  --border: rgb(255 255 255 / 0.14);
}

/* The Status pills carry a dot drawn with `background:currentColor`, so the
   ink fix above carries the dot with it — nothing extra to set. */

/* ── 8. Print — the operator prints packing slips and invoices from here ────*/
@media print {
  #admin-sidebar, #mobile-header, #sidebar-overlay, .theme-toggle { display: none !important; }
  #admin-main { margin-left: 0 !important; padding: 0 !important; }
  :is(#admin-shell,#order-modal,#manual-order-modal,#delete-modal,#contact-drawer) { background: #fff !important; color: #000 !important; }
}
