/**
 * EasyBuild Design System — Kartra-parity tokens.
 * Primary #2E88DC · canvas #FBFCFF · text #595F65 · Roboto 14px
 * Light is default; dark is optional under [data-theme=dark].
 */

/* The light palette declares on :root ONLY. It used to co-declare on
   `:root, [data-theme="light"]`, so a bare `:root { --eb-... }` author override was shadowed by the
   equal-specificity [data-theme="light"] arm on any page that stamps data-theme="light" — the override
   silently did nothing. Light is :root's default; the explicit-light toggle simply removes the
   [data-theme="dark"] match and falls back to :root. So dropping the arm makes :root overrides take,
   and the light toggle still works. */
:root {
  --eb-primary: #2E88DC;
  --eb-primary-hover: #1f66ab; /* Was #2476c4 — as TEXT it was 4.23:1 on --eb-surface-3 and
                                  4.195:1 on --eb-primary-soft (fails AA); #1f66ab is >=5.0:1 on every light
                                  tint AND lifts white-on-it (the button-hover fill) from 4.70 to 5.92. */
  /* The hover text pairs with the INVERTING --eb-primary-hover so the pair stays legible in
     both palettes — white on the darker light-hover (#2476c4 → 4.70:1), navy on the lighter dark-hover
     (#5aa3e3 → 6.56:1). It moves WITH the background, so no side is pinned. */
  --eb-btn-hover-text: #ffffff;
  --eb-navy: #041A2A;
  --eb-cta: #08CF65;
  --eb-cta-hover: #07b85a;
  --eb-purple: #6938EF;
  --eb-grey-100: #E8ECF1;
  --eb-grey-50: #F4F6F9;
  --eb-text: #595F65;
  /* The UN-OVERRIDABLE palette-text alias. Bands override --eb-text at section
     scope (their ground changed); a component BACKGROUND pick creates its OWN ground under that
     override, so its paired text must reach the PALETTE value regardless of band — that is this
     token, which no section-scope style ever overrides. MUST stay byte-equal to --eb-text in each
     palette (suite-locked: test-p95-bg-pairs asserts equality per palette). */
  --eb-text-base: #595F65;
  /* SWATCH-TEXT tokens — the colour-swatch resolutions against the DEFAULT ground
     (the page surface), per palette. The falsifier put invisible text on a plain section with ONE
     click: swatch 'surface' = 1.0000 both themes, 'navy' 1.03 dark, 'cta' 2.02 light — the default
     ground was the row the pair system never had. The PALETTE owns theme divergence (no [data-theme]
     selectors in sheets): each token is the legible resolution of its swatch on this palette's
     surface. navy stays navy in light; in dark, dark-on-dark is impossible, so it resolves to the
     palette's legible blue cousin (primary-hover's value). cta needs a DARK green on the light
     surface (#067c3e = 5.1:1; the brand green itself is 2.02) and is itself legible in dark.
     surface-as-text is same-colour-on-same-ground by definition — it resolves to the palette text
     in both (recorded cost: the surface swatch never renders surface-coloured on the default
     ground; on bands/bg-picks the neutralise rules own it anyway). Bands and bg-picks are
     untouched — their higher-specificity pair rules still win. */
  --eb-navy-text: #041A2A;
  --eb-cta-text: #067c3e;
  --eb-surface-text: #595F65;
  /* The BAND EDGE — the light-band separation hairline. --eb-border (#e4e8ee)
     measured 1.10:1 against the fills it was supposed to separate (WCAG 1.4.11 wants 3:1 for a
     non-text boundary — a user saw a tone step, not a line). This value clears 3:1 against EVERY
     ground it borders in its palette (white 3.68, surface 3.59, surface-3 3.31). */
  --eb-band-edge: #7f868f;
  /* Pure ink — the darkest pair-system anchor (the same literal the contrast
     escalation returns). Used where no palette colour clears a bar (field borders on the green
     band: navy is 2.8542, ink is 10.8). Identical in both palettes by definition. */
  --eb-ink: #000000;
  /* Caught in the live drive: the un-overridable MUTED alias — bands override
     --eb-text-muted at section scope, and that override rode INTO the form field's
     placeholder (white placeholder on the white field = 1.0000, measured). Same pattern as
     --eb-text-base: the field is its own ground; its placeholder reaches the PALETTE muted value.
     MUST stay byte-equal to --eb-text-muted per palette (suite-locked). */
  --eb-text-muted-base: #5f6b7a;
  --eb-text-heading: #3d4349;
  --eb-text-muted: #5f6b7a; /* Was #8a9199 = 3.19:1 on white (fails AA as text). #5f6b7a is
                               4.87:1 even on the dimmest light surface (--eb-surface-3), still visibly muted
                               vs --eb-text. Dark --eb-text-muted (#98a2b3 on the dark surface) already passes. */
  --eb-surface: #FBFCFF;
  --eb-surface-2: #FFFFFF;
  --eb-surface-3: #F0F3F7;
  --eb-border: #e4e8ee;
  --eb-danger: #d92d20;
  --eb-danger-text: #a01d17; /* Danger as TEXT on the danger-soft tint — a darker red than
                                the --eb-danger fill (which is 3.90:1 on the tint). #a01d17 = 6.32:1. */
  --eb-warning: #f79009;
  --eb-success: #08CF65;
  --eb-chart-bar: #FFC107;
  --eb-chart-line: #7EC8F0;
  --eb-on-primary: #ffffff;
  --eb-on-navy: #ffffff;
  --eb-on-navy-faint: rgba(255, 255, 255, 0.06);
  --eb-on-navy-soft: rgba(255, 255, 255, 0.08);
  --eb-on-navy-soft-2: rgba(255, 255, 255, 0.1);
  --eb-on-navy-border: rgba(255, 255, 255, 0.12);
  --eb-on-navy-border-strong: rgba(255, 255, 255, 0.15);
  --eb-on-navy-muted: rgba(255, 255, 255, 0.55);
  --eb-on-navy-dim: rgba(255, 255, 255, 0.72);
  --eb-primary-soft: rgba(46, 136, 220, 0.12);
  --eb-primary-soft-2: rgba(46, 136, 220, 0.1);
  --eb-primary-soft-3: rgba(46, 136, 220, 0.15);
  --eb-primary-soft-4: rgba(46, 136, 220, 0.2);
  --eb-danger-soft: rgba(217, 45, 32, 0.1);
  /* The OPAQUE error-badge ground — danger-soft is translucent (ground-dependent,
     unpairable). The badge gives error text its OWN ground on any band: --eb-danger-text on this
     = 6.67:1 light / 5.90:1 dark; the badge's boundary rides --eb-field-edge (per ground). */
  --eb-danger-surface: #fde8e8;
  --eb-success-soft: rgba(8, 207, 101, 0.15);
  --eb-info: #2E88DC;
  /* Amber and blue status pills. Like --eb-danger-text, the *-text value is a DARKER shade
     than the fill: --eb-warning (#f79009) on its own tint is 2.2:1, #b54708 is 5.9:1;
     --eb-info on its tint is 3.4:1, #175cd3 is 6.5:1. Both clear AA. */
  --eb-warning-soft: rgba(247, 144, 9, 0.14);
  --eb-warning-text: #b54708;
  --eb-info-soft: rgba(46, 136, 220, 0.14);
  --eb-info-text: #175cd3;
  --eb-canvas: #FBFCFF;
  --eb-canvas-dark: #0a121c;
  --eb-elevated-dark: #152233;
  --eb-text-inverse: #e8eef6;
  --eb-badge-success-text: #067647;
  --eb-shadow-sm: 0 0 10px rgba(0, 0, 0, 0.07);
  --eb-shadow-md: 0 0 10px rgba(0, 0, 0, 0.07);
  --eb-shadow-lg: 0 12px 32px rgba(4, 26, 42, 0.12);
  --eb-scrim: rgba(4, 26, 42, 0.35);
  --eb-shadow-menu: 0 12px 40px rgba(15, 28, 46, 0.16);
  --eb-shadow-menu-lg: 0 12px 40px rgba(15, 28, 46, 0.18), 0 2px 8px rgba(15, 28, 46, 0.08);
  --eb-shadow-menu-dark: 0 16px 48px rgba(0, 0, 0, 0.45);
  --eb-card-shadow: 0 0 10px rgba(0, 0, 0, 0.07);
  --eb-radius-sm: 6px;
  --eb-radius: 10px;
  --eb-radius-lg: 10px;
  --eb-radius-pill: 999px;
  --eb-space-1: 4px;
  --eb-space-2: 8px;
  --eb-space-3: 12px;
  --eb-space-4: 16px;
  --eb-space-5: 24px;
  --eb-space-6: 32px;
  --eb-space-7: 48px;
  --eb-font: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  --eb-font-mono: "JetBrains Mono", ui-monospace, monospace;
  --eb-font-size: 14px;
  --eb-sidebar-w: 240px;
  --eb-topbar-h: 60px;
  --eb-nav-row-h: 30px;
  /* The old single translucent ring (rgba(46,136,220,.35)) composited to
     1.25-2.04:1 against every measured ground — invisible where it mattered. The DOUBLE ring
     (inner white gap + solid dark-blue outer) is visible on any ground by construction: on light
     grounds the #1f66ab outer clears 3:1; on dark fills the white inner clears it. */
  --eb-focus: 0 0 0 2px #ffffff, 0 0 0 4px #1f66ab;
  color-scheme: light;
}

/* Optional dark — retain navy set */
[data-theme="dark"] {
  --eb-primary: #3b8fd9;
  --eb-primary-hover: #5aa3e3;
  --eb-btn-hover-text: #041A2A;
  --eb-navy: #041A2A;
  --eb-cta: #08CF65;
  --eb-cta-hover: #2adb7a;
  --eb-purple: #7c3aed; /* Was #8b5cf6 — white on it is 4.23:1 (fails AA); #7c3aed = 5.70:1. The purple pills (.eb-auto-and / .eb-filter-or) carry white, so the dark token must be dark enough for it. */
  --eb-grey-100: #2a3544;
  --eb-grey-50: #0f1b28;
  --eb-text: #E3E8EF;
  --eb-text-base: #E3E8EF; /* un-overridable alias — see the light-palette note. */
  --eb-navy-text: #5aa3e3; /* dark-on-dark impossible — the legible blue cousin. */
  --eb-cta-text: #08CF65; /* the brand green is legible on the dark surface. */
  --eb-surface-text: #E3E8EF; /* surface-as-text resolves to palette text. */
  --eb-band-edge: #697d96; /* 3:1+ against every dark ground (3.42-4.32). */
  --eb-ink: #000000; /* ink is ink in both palettes. */
  --eb-text-muted-base: #98a2b3; /* un-overridable muted alias — see light note. */
  --eb-text-heading: #f0f4f8;
  --eb-text-muted: #98a2b3;
  --eb-surface: #0b1622;
  --eb-surface-2: #112031;
  --eb-surface-3: #1a2b3d;
  --eb-border: #2a3a4d;
  --eb-chart-bar: #FFC107;
  --eb-chart-line: #7EC8F0;
  --eb-on-primary: #ffffff;
  --eb-on-navy: #ffffff;
  --eb-on-navy-faint: rgba(255, 255, 255, 0.06);
  --eb-on-navy-soft: rgba(255, 255, 255, 0.08);
  --eb-on-navy-soft-2: rgba(255, 255, 255, 0.1);
  --eb-on-navy-border: rgba(255, 255, 255, 0.12);
  --eb-on-navy-border-strong: rgba(255, 255, 255, 0.15);
  --eb-on-navy-muted: rgba(255, 255, 255, 0.55);
  --eb-on-navy-dim: rgba(255, 255, 255, 0.72);
  --eb-primary-soft: rgba(59, 143, 217, 0.18);
  --eb-primary-soft-2: rgba(59, 143, 217, 0.12);
  --eb-primary-soft-3: rgba(59, 143, 217, 0.2);
  --eb-primary-soft-4: rgba(59, 143, 217, 0.28);
  /* Dark danger. #d92d20 (the :root value) as TEXT on the dark surface is 3.41-3.77:1
     (fails); #f97066 is 5.9-6.5:1. The danger FILL pairs with --eb-btn-hover-text (navy in dark) = 6.35:1,
     so a lighter dark red serves both text and fill. */
  --eb-danger: #f97066;
  --eb-danger-text: #f97066; /* dark: the lighter red is legible on the dark danger-soft (6.49:1). */
  --eb-danger-soft: rgba(217, 45, 32, 0.18);
  --eb-danger-surface: #3b1216; /* dark badge ground — see light note. */
  --eb-success-soft: rgba(8, 207, 101, 0.18);
  --eb-info: #3b8fd9;
  /* dark: the lighter amber/blue are the legible ones on their dark tints (7.9:1 / 7.5:1). */
  --eb-warning-soft: rgba(247, 144, 9, 0.20);
  --eb-warning-text: #fdb022;
  --eb-info-soft: rgba(46, 136, 220, 0.22);
  --eb-info-text: #84caff;
  --eb-canvas: #0a121c;
  --eb-canvas-dark: #0a121c;
  --eb-elevated-dark: #152233;
  --eb-text-inverse: #e8eef6;
  --eb-badge-success-text: #08CF65;
  --eb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --eb-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --eb-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --eb-scrim: rgba(0, 0, 0, 0.55);
  --eb-shadow-menu: 0 12px 40px rgba(0, 0, 0, 0.4);
  --eb-shadow-menu-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --eb-shadow-menu-dark: 0 16px 48px rgba(0, 0, 0, 0.45);
  --eb-card-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
  --eb-focus: 0 0 0 2px #0b1622, 0 0 0 4px #7EC8F0; /* dark double ring — dark gap + light-blue outer, visible on any dark-palette ground. */
  color-scheme: dark;
}

.eb-root,
.eb-theme {
  font-family: var(--eb-font);
  font-size: var(--eb-font-size);
  color: var(--eb-text);
  background: var(--eb-surface);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.eb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--eb-space-2);
  padding: 10px 18px;
  border-radius: var(--eb-radius-pill);
  border: none;
  font-weight: 600;
  font-size: var(--eb-font-size);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  text-decoration: none;
  font-family: inherit;
}
.eb-btn:focus-visible { outline: none; box-shadow: var(--eb-focus); }
/* The SINGLE source of truth for these button classes — the theme.css duplicates are
   removed, so the painted pair is identical on admin, public and portal (design-tokens.css loads on all
   three). Two invariants enforced by the matrix test:
   (1) primary/secondary carry NAVY text (the old white-on-#2E88DC was 3.70:1 — it shipped on admin, where
       theme.css never loaded to correct it); primary is GREEN (navy on cta = 8.53:1), the Kartra CTA colour.
   (2) EVERY state selector that sets `background` also sets `color` — the classic bug shape is a `:hover`
       (etc.) that moves the background out from under a colour it no longer matches. Hover keeps navy on the
       green primary (cta-hover), and pairs the inverting --eb-primary-hover with --eb-btn-hover-text so the
       secondary hover clears AA in both palettes. */
.eb-btn-primary { background: var(--eb-cta); color: var(--eb-navy); }
.eb-btn-primary:hover { background: var(--eb-cta-hover); color: var(--eb-navy); }
.eb-btn-secondary { background: var(--eb-primary); color: var(--eb-navy); }
.eb-btn-secondary:hover { background: var(--eb-primary-hover); color: var(--eb-btn-hover-text); }
.eb-btn-ghost { background: transparent; color: var(--eb-text); border: 1px solid var(--eb-border); }
.eb-btn-ghost:hover { background: var(--eb-surface-3); color: var(--eb-text); }
.eb-btn-sm { padding: 6px 12px; font-size: 13px; }
.eb-btn-cta { background: var(--eb-cta); color: var(--eb-navy); }
.eb-btn-cta:hover { background: var(--eb-cta-hover); color: var(--eb-navy); }

.eb-input, .eb-select, .eb-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--eb-border);
  border-radius: var(--eb-radius);
  background: var(--eb-surface-2);
  color: var(--eb-text);
  font: inherit;
}
.eb-input:focus, .eb-select:focus, .eb-textarea:focus {
  outline: none;
  box-shadow: var(--eb-focus);
  border-color: var(--eb-primary);
}

.eb-card {
  background: var(--eb-surface-2);
  border: none;
  border-radius: var(--eb-radius);
  box-shadow: var(--eb-card-shadow);
  padding: var(--eb-space-5);
}

.eb-badge {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: var(--eb-radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--eb-grey-100);
  color: var(--eb-text);
}
.eb-badge-success { background: var(--eb-success-soft); color: var(--eb-badge-success-text); }
/* --eb-primary text on --eb-primary-soft was 3.22/3.72. --eb-primary-soft INVERTS (a light
   tint in light, a dark tint in dark), so the text must invert with it — --eb-text (dark on light, light on
   dark, the body-text token) clears AA in both; --eb-primary-hover only reaches 4.195 on the light tint. */
.eb-badge-info { background: var(--eb-primary-soft); color: var(--eb-text); }

.eb-progress {
  height: 8px;
  background: var(--eb-surface-3);
  border-radius: var(--eb-radius-pill);
  overflow: hidden;
}
.eb-progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--eb-primary), var(--eb-cta));
  border-radius: inherit;
}

.eb-ring {
  --p: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--eb-cta) calc(var(--p) * 1%), var(--eb-surface-3) 0);
  display: grid;
  place-items: center;
}
.eb-ring::before {
  content: attr(data-label);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--eb-surface-2);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
