/* ============================================================
   Dsquared Hub — Design System Stylesheet
   v1.0  ·  Developer Handoff
   ------------------------------------------------------------
   Drop this file into your project as `hub.css` and import it
   once at the root of the app:

       <link rel="stylesheet" href="/css/hub.css" />

   All components use the `db-` prefix and resolve against the
   custom properties declared on `:root`. To re-skin, override
   the variables on a parent scope — never touch the rules.
   ============================================================ */


/* ────────────────────────────────────────────────────────────
   1. DESIGN TOKENS — MASTER UI KIT (design/UI Kit.dc.html)
   Token naming: surfaces/text/brand/states/tones/radius/shadow.
   Backward-compat aliases keep old code (--surf, --pos, etc.) working
   while new components use the v2 names (--surf-1, --good, etc.).
   ──────────────────────────────────────────────────────────── */
:root {
  /* — Surfaces & neutrals — */
  --bg:        #ffffff;
  --surf-1:    #ffffff;
  --surf-2:    #fbfbfd;
  --surf-3:    #f1f1f4;
  --border:    #ececf0;
  --border-2:  #d8d8de;
  --border-light: #f1f1f4;
  /* alias: legacy code uses --surf (now --surf-1) */
  --surf:      var(--surf-1);

  /* — Text — */
  --text:      #15161c;
  --text-2:    #6b6d79;
  --text-3:    #7f8190;
  --muted:     #7f8190;
  --faint:     #7f8190;
  --faint-2:   #c3c4cf;

  /* — Brand (single primary) — */
  --accent:    #6366f1;
  --accent-50: #eef0ff;
  --accent-100:#dbdfff;
  --accent-700:#4f46e5;
  --ink:       #15161c;   /* dark CTA (redesign: was #18181b) */
  --ink-hover: #2a2c36;   /* dark CTA hover (redesign: was #27272a) */
  --ink-2:     #0d0e15;   /* darkest surfaces — dark panels, the Log work pill (BUILD.md §2) */

  /* — Brand pink — data viz + AI action icons ONLY (rule 6: ink acts, pink
     shows data, indigo links). Never a button colour. — */
  --brand:     #ec0a72;
  --brand-40:  #f4649a;
  --brand-20:  #f9a3c1;

  /* Compatibility only. Local modules keep these names until their Batch G
     migration, but every value now resolves through the canonical palette. */
  --local-label: var(--faint);
  --local-input-border: var(--line-control);
  --local-fill-subtle: var(--surf-2);
  --local-fill-muted: var(--border-light);
  --local-chart-indigo: #5b5fc7;
  --local-chart-blue: #2f7fd4;
  --local-status-success: var(--good);
  --local-status-danger: var(--bad);
  --local-status-warning: var(--warn);
  --local-star: var(--warn);
  --local-warning-border: var(--border);
  --local-danger-ring: var(--bad-50);
  --local-backdrop: rgba(18,18,24,.48);
  --local-skeleton: var(--border-light);
  --local-action-surface: #15161c;
  --local-action-text: #ffffff;
  --local-action-muted: #9a9caa;
  --local-measured-bg: #e6f5eb;
  --local-measured-text: #16723a;
  --local-stale-bg: #fff0df;
  --local-stale-text: #a85a00;
  --local-partial-bg: #eeecff;
  --local-partial-text: #5a52c7;
  --maxw-local-extra: 120px;
  --shadow-local-drawer: var(--shadow-drawer);
  --shadow-local-preview: var(--shadow-modal);
  --shadow-local-segment: none;
  --shadow-local-danger-ring: 0 0 0 5px var(--local-danger-ring);

  /* — Metric tones (one per KPI family) — */
  --tone-users:     var(--brand);
  --tone-sessions:  var(--brand-40);
  --tone-pages:     var(--brand-20);
  --tone-pageviews: var(--brand-20);
  --tone-time:      var(--warn);
  --tone-bounce:    var(--bad);
  --tone-neutral:   var(--faint);

  /* — State (v2 names) — */
  --good:    #1a9c63;  --good-ink: #11774a; --good-50: #e6f6ee;
  --bad:     #b4453f;  --bad-50:  #fdf1f0;
  --warn:    #d98a00;  --warn-ink: #8a5a00; --warn-50: #fbf6e9;
  --info:    #06b6d4;  --info-50: #ecfeff;
  /* aliases — legacy code references --pos / --neg / --neu / --info-bg */
  --pos:     var(--good);  --pos-bg: var(--good-50);
  --neg:     var(--bad);   --neg-bg: var(--bad-50);
  --neu:     var(--warn);  --neu-bg: var(--warn-50);
  --info-bg: var(--info-50);

  /* — Radius — */
  --r-xs:  5px;
  --r-sm:  6px;
  --r-control: 7px;
  --r-md:  8px;
  --r-field: 9px;
  --r-lg:  10px;
  --r-card: 11px;
  --r-xl:  12px;
  --r-panel: 13px;
  --r-2xl: 14px;
  --r-pill: 999px;

  /* — Spacing scale (4px base) — */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-11: 44px;
  --space-13: 52px;

  /* — Interactive control heights — */
  --control-h-compact: 30px;
  --control-h-default: 36px;
  --control-h-touch:   44px;

  /* — Elevation (v2 names: shadow-1/2/3/modal) — */
  --shadow-1:     none;
  --shadow-2:     none;
  --shadow-3:     none;
  --shadow-modal: 0 24px 60px -20px rgba(15,15,25,0.35);
  /* aliases — legacy code references --shadow-sm / -md / -lg */
  --shadow-sm: var(--shadow-1);
  --shadow-md: var(--shadow-2);
  --shadow-lg: var(--shadow-3);
  /* the only two things that carry a shadow — drawer + dropdown (UI Kit) */
  --shadow-drawer:   -20px 0 60px -20px rgba(18,19,30,.28);
  --shadow-dropdown: 0 18px 48px -16px rgba(20,22,30,.24), 0 2px 6px rgba(20,22,30,.05);

  /* — Motion (referenced by UI Rules — never use raw ms) — */
  --motion-fast:       120ms;
  --motion-standard:   180ms;
  --motion-modal:      200ms;
  --motion-phone-cue:  250ms;
  --motion-slow:       260ms;
  --motion-deliberate: 380ms;
  --motion-crawl-pulse: 1200ms;
  --motion-theme:      160ms;
  --scrim-drawer:      rgba(18, 19, 28, .32);
  --scrim-modal:       rgba(18, 19, 28, .34);

  /* — Easing — */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in:     cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* — Typography — */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  /* ── Home v2 / Snapshots reference tokens ─────────────────
     Added to keep the imported Home v2 design files working
     unmodified. Most map to existing v2 tokens above; a few
     are net-new (--page, --card-2, --line-2, --tint-ring,
     --shadow-pop, --maxw, --card-pad, --row-gap, --grid-gap,
     --topnav-h, --field-* family). Do NOT duplicate these
     elsewhere — change them here.
     ────────────────────────────────────────────────────── */
  --blue:        #4b6cf7;
  --indigo:      var(--accent);
  --indigo-press:var(--accent-700);
  --violet:      #8b7cf6;
  --tint-1:      var(--accent-50);
  --tint-2:      var(--accent-100);
  --tint-ring:   #eceafe;
  --rose:        var(--bad);
  --green:       var(--good);
  --amber:       var(--tone-time);
  --cyan:        #0bb5d4;
  --danger:      var(--bad);
  --danger-bg:   var(--bad-50);
  --ok:          var(--good);
  --ok-bg:       var(--good-50);
  --body:        var(--text-2);
  --label:       #4f515d;
  /* — Redesign additions (2026-07-29, design_handoff_hub_redesign/TOKENS.md) — */
  --line-row:     #f4f4f7;   /* row divider — lighter than --border */
  --line-control: #d4d5de;   /* unchecked control border */
  --page:        #ffffff;
  --card:        var(--surf-1);
  --card-2:      #fbfbfd;
  --line:        var(--border);
  --line-2:      #eceef3;
  --field-border:   #cdcfdb;
  --field-border-h: #b3b6c6;
  --field-bg:       var(--surf-1);
  --field-empty-bg: #fbfbfd;
  --field-ink:      var(--text);
  --field-place:    #a4a6b4;
  --ring:           rgba(21,22,28,.18);
  --radius:    var(--r-lg);
  --radius-sm: var(--r-md);
  --radius-lg: var(--r-2xl);
  --shadow-pop: var(--shadow-dropdown);
  --maxw:      1080px;   /* redesign: narrower report column (was 1320px) */
  --topnav-h:  56px;     /* UI Kit spec — was 60px (bug) */
  --card-pad:  26px;
  --row-gap:   18px;
  --grid-gap:  18px;
  --field-pad-y: 11px;
  --field-pad-x: 13px;
  --field-fs: 14.5px;

  /* Shared type scale. Product surfaces may compose these values but may not
     redefine them per module. */
  --text-xs: 11px;
  --text-sm: 12.5px;
  --text-base: 14px;
  --text-lg: 14.5px;
  --text-xl: 19px;
  --text-2xl: 27px;
  --text-3xl: 32px;

  /* — Overlay widths (UI Kit "Viewports"). Drawers are always a min(), never a
     percentage — a % drawer swallowed a laptop screen. — */
  --drawer-w:      620px;
  --drawer-narrow: 440px;
  --drawer-form:   520px;
  --drawer-wide:   720px;
  --help-w:        480px;
  --wizard-w:      640px;
  --window-w:      880px;

  /* ── Compatibility aliases — legacy and module-scoped tokens ────────────────
     These are aliases only. Do not use them in new code — use the canonical
     token on the right-hand side. They exist so old code doesn't silently
     resolve to empty / transparent.
     ──────────────────────────────────────────────────────────────────────── */

  /* Motion easing */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);   /* alias of --ease-in-out */

  /* AI Visibility module tokens (used in geo-readiness-app.js, dashboard.html) */
  --aiv-accent:      var(--accent);
  --aiv-accent-tint: var(--accent-50);
  --aiv-text:        var(--ink);
  --aiv-text-2:      var(--text-2);
  --aiv-text-3:      var(--faint);
  --aiv-text-muted:  var(--faint);
  --aiv-text-faint:  var(--faint-2);
  --aiv-bad:         var(--bad);
  --aiv-border:      var(--border);
  --aiv-divider-2:   var(--border);

  /* Generic surface / border aliases used across JS templates */
  --accent-bg:    var(--accent-50);   /* accent-tinted card background */
  --bg-surface:   var(--surf-1);      /* generic surface — e.g. input backgrounds */
  --border-color: var(--border);      /* custom-property alias for border shorthand */

  /* Legacy text/surface aliases — used extensively in dashboard.html JS templates.
     These all chain to canonical tokens so dark-mode overrides propagate correctly. */
  --text-primary:   var(--ink);      /* headings, labels, primary readable text */
  --text-muted:     var(--text-2);   /* secondary/helper text */
  --text-secondary: var(--text-2);   /* secondary text — same tier as --text-muted */
  --surface:        var(--surf-1);   /* primary surface background */
  --surface-hover:  var(--surf-2);   /* hover surface */
  --surface-alt:    var(--surf-2);   /* slightly receded surface */
  --bg-muted:       var(--surf-2);   /* muted background (sidebar headers, table headers) */
  --bg-card:        var(--surf-1);   /* card background */
  --card-bg:        var(--surf-1);   /* card background — alternate spelling */
  --hub-mono-ink:   var(--ink);      /* monospace-context ink */

  /* Legacy state aliases */
  --positive:       var(--good);
  --positive-light: var(--good-50);
  --success:        var(--good);
  --success-light:  var(--good-50);
  --negative:       var(--bad);
  --error:          var(--bad);
  --error-light:    var(--bad-50);
  --danger-light:   var(--bad-50);
  --warning:        var(--warn);
  --warning-light:  var(--warn-50);
  --info-light:     var(--info-50);

  /* Legacy brand aliases. These remain compatibility-only and resolve through
     Master Kit tokens so downstream files do not become competing authorities. */
  --accent-hover:      var(--accent-700);
  --accent-dark:       var(--accent-700);
  --accent-light:      var(--accent-50);
  --accent-text:       #ffffff;
  --accent-badge:      var(--accent-100);
  --accent-fill:       var(--accent-100);
  --accent-fill-light: var(--accent-50);
  --pink:              var(--brand);
  --pink-light:        color-mix(in srgb, var(--brand) 10%, var(--surf-1));

  /* Grandfathered module aliases. Their removal is gated by the corresponding
     migration batch in PR #908; new work must use the canonical tokens above. */
  --pastel-blue:             var(--accent);
  --pastel-blue-light:       var(--accent-50);
  --pastel-indigo:           var(--accent);
  --pastel-indigo-light:     var(--accent-50);
  --pastel-purple:           var(--violet);
  --pastel-purple-light:     color-mix(in srgb, var(--violet) 10%, var(--surf-1));
  --pastel-rose:             var(--bad);
  --pastel-rose-light:       var(--bad-50);
  --pastel-slate:            var(--faint);
  --pastel-slate-light:      var(--surf-2);
  --pastel-lavender:         var(--violet);
  --pastel-lavender-light:   color-mix(in srgb, var(--violet) 10%, var(--surf-1));
  --pastel-sky:              var(--info);
  --pastel-sky-light:        var(--info-50);
  --pastel-warm-gray:        var(--faint);
  --pastel-warm-gray-light:  var(--surf-2);

  /* Legacy shell aliases retained until the old sidebar is deleted. */
  --sidebar-bg:          var(--surf-1);
  --sidebar-text:        var(--text-2);
  --sidebar-text-active: var(--ink);
  --sidebar-border:      var(--border);
  --sidebar-width:       256px;
  --topbar-height:       72px;
  --rail-width:          340px;
  --radius-xs:           var(--r-sm);
  --radius-sm:           var(--r-md);
  --radius-lg:           var(--r-2xl);
  --shadow-focus-brand:  0 0 0 2px color-mix(in srgb, var(--brand) 42%, transparent);
  --transition:          var(--motion-standard) var(--ease-in-out);
  --font:                var(--font-sans);
  --font-display:        var(--font-sans);
  --sp-1:                var(--space-1);
  --sp-2:                var(--space-2);
  --sp-3:                var(--space-3);
  --sp-4:                var(--space-4);
  --sp-5:                var(--space-6);
  --sp-6:                var(--space-8);
}

/* ═══════════════════════════════════════════════════════════════
   Dark theme — authored, not computed (UI Kit / Dark Mode.dc.html).
   Applied via [data-theme="dark"] on <html> (set pre-paint by the
   inline guard in dashboard.html). Only background-color + border-color
   transition on toggle; type/spacing/radius/motion are identical.
   ═══════════════════════════════════════════════════════════════ */
[data-theme="dark"],
.dark-mode {
  color-scheme: dark;

  --bg:            #0e0f14;   /* not pure black — hairlines vanish on #000 */
  --surf-1:        #14151b;
  --surf-2:        #1a1c23;
  --surf-3:        #1a1c23;
  --card-2:        #1a1c23;
  --page:          #0e0f14;
  --card:          #14151b;

  --ink:           #f2f3f6;   /* not #fff — pure white vibrates */
  --ink-hover:     #ffffff;
  --text:          #f2f3f6;
  --text-2:        #a8abb8;
  --text-3:        #a8abb8;
  --faint:         #7b7e8c;   /* the one token that goes DARKER */
  --faint-2:       #565a68;

  --border:        #24262f;   /* load-bearing — the system is hairlines */
  --border-2:      #363944;
  --border-light:  #20222a;
  --line:          #24262f;
  --line-2:        #1c1e26;
  --line-row:      #1c1e26;
  --line-control:  #363944;

  --brand:         #fa3d90;   /* #ec0a72 goes muddy on near-black */
  --brand-40:      #f97bb0;
  --brand-20:      #bd6b8b;
  --accent:        #8b8dff;
  --accent-700:    #8b8dff;
  --violet:        #a79bff;

  --good:          #2ec27e;   --good-ink: #78d9aa; --good-50: rgba(46,194,126,.16);
  --bad:           #e5645c;   --bad-50:  rgba(229,100,92,.16);
  --warn:          #e5a020;   --warn-ink: #f0bd58; --warn-50: rgba(229,160,32,.16);
  --pos: var(--good); --pos-bg: var(--good-50);
  --neg: var(--bad);  --neg-bg: var(--bad-50);
  --neu: var(--warn); --neu-bg: var(--warn-50);

  --field-bg:       #14151b;
  --field-empty-bg: #1a1c23;
  --field-border:   #363944;
  --field-border-h: #4a4d5a;

  --shadow-1:     none;
  --shadow-2:     none;
  --shadow-3:     none;
  --shadow-pop:   0 20px 52px -14px rgba(0,0,0,.66);
  --shadow-modal: 0 28px 80px -20px rgba(0,0,0,.72);
}

/* Primary action is always the highest-contrast object — in dark it inverts to
   a near-white fill with dark text (rule from Dark Mode.dc.html). */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-dark,
[data-theme="dark"] .topnav-pinned,
.dark-mode .btn-primary,
.dark-mode .btn-dark,
.dark-mode .topnav-pinned { color: #101116; }
[data-theme="dark"] .btn-primary svg,
[data-theme="dark"] .btn-dark svg,
.dark-mode .btn-primary svg,
.dark-mode .btn-dark svg { stroke: #101116; }

/* Screenshots/embedded images need a hairline frame or they punch through as
   glowing rectangles on the dark surface. */
[data-theme="dark"] img.screenshot,
[data-theme="dark"] .screenshot img,
.dark-mode img.screenshot,
.dark-mode .screenshot img { border: 1px solid var(--border); }

/* Theme change animates surfaces only — never `transition: all`. */
body, .section, .card, .drawer, .crumbs, .topnav, .topnav-dropdown,
.kpi-card, .stat-card, .data-table td, .data-table th {
  transition: background-color var(--motion-theme) var(--ease-in-out), border-color var(--motion-theme) var(--ease-in-out);
}
@media (prefers-reduced-motion: reduce) {
  body, .section, .card, .drawer, .crumbs, .topnav, .topnav-dropdown,
  .kpi-card, .stat-card, .data-table td, .data-table th { transition: none; }
}


/* ────────────────────────────────────────────────────────────
   2. RESET / BASE
   NOTE: hub.css loads BEFORE dashboard.css so its tokens
   become the foundation. Body-level rules here are intentionally
   light — dashboard.css already manages box-sizing, body bg,
   text color, etc. for the legacy app shell, and we don't want
   to fight it. The font variables on :root (above) are what
   most rules pick up via var(--font-sans).
   ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  font-size: var(--text-base);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

/* Canonical page frame. Existing sections adopt this primitive batch by batch;
   the migrated-section adapter already routes its .shell through the same
   measurements. Wide data/map workspaces require an explicit Kit exception. */
.hub-page-frame,
.page-frame {
  width: 100%;
  max-width: calc(var(--maxw) + (2 * var(--space-8)));
  margin-inline: auto;
  padding: var(--space-11) var(--space-8) calc(var(--space-13) + var(--space-8));
}

.hub-page-header,
.page-header {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.hub-eyebrow,
.page-eyebrow {
  margin: 0;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  line-height: 1.35;
  text-transform: uppercase;
}

.hub-page-title,
.page-title {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: 1.14;
  text-wrap: balance;
}

.hub-page-deck,
.page-deck {
  max-width: 66ch;
  margin: 0;
  color: var(--text-2);
  font-size: var(--text-lg);
  line-height: 1.6;
  text-wrap: pretty;
}

@media (max-width: 900px) {
  .hub-page-frame,
  .page-frame { padding-inline: var(--space-6); }
}

@media (max-width: 600px) {
  .hub-page-frame,
  .page-frame {
    padding: var(--space-6) var(--space-4) calc(var(--space-13) + var(--space-4));
  }
  .hub-page-title,
  .page-title { font-size: var(--text-2xl); }
}


/* ────────────────────────────────────────────────────────────
   3. TYPOGRAPHY
   ──────────────────────────────────────────────────────────── */
.db-h1 {
  font-size: var(--text-3xl); font-weight: 600;
  letter-spacing: -0.03em; line-height: 1.14;
  margin: 0;
}
.db-h2 {
  font-size: var(--text-xl); font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.2;
  margin: 0;
}
.db-card-title {
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em;
}
.db-metric-value {
  font-size: 24px; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.1;
}
.db-body { font-size: 13.5px; color: var(--text-2); }
.db-eyebrow {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint);
}
.db-caption { font-size: 11.5px; color: var(--text-3); }


/* ────────────────────────────────────────────────────────────
   4. BUTTONS
   ──────────────────────────────────────────────────────────── */

/* Primary — highest-contrast ink action. White text is forced because
   ancestor selectors elsewhere in product CSS sometimes
   override the color. Keep the !important. */
.db-btn-primary,
.db-btn-primary * {
  background: var(--ink);
  color: #fff !important;
  border: 1px solid var(--ink);
  height: var(--control-h-default);
  padding: 0 var(--space-3);
  border-radius: var(--r-md);
  font: 500 13px/1 var(--font-sans);
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.db-btn-primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }

/* Dark — high-priority secondary action (e.g. Run Audit). */
.db-btn-runaudit,
.db-btn-runaudit * {
  background: var(--ink) !important;
  color: #fff !important;
  border: 1px solid var(--ink);
  height: var(--control-h-default);
  padding: 0 var(--space-3);
  border-radius: var(--r-md);
  font: 500 12.5px/1 var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out);
}
.db-btn-runaudit:hover { background: var(--ink-hover) !important; border-color: var(--ink-hover); }

/* Soft — tertiary action. */
.db-btn-soft {
  background: var(--surf);
  border: 1px solid var(--border);
  color: var(--text-2);
  height: var(--control-h-default);
  padding: 0 var(--space-3);
  border-radius: var(--r-md);
  font: 500 12.5px/1 var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out);
}
.db-btn-soft:hover {
  background: var(--surf-2);
  border-color: var(--border-2);
}


/* ────────────────────────────────────────────────────────────
   5. BADGES
   ──────────────────────────────────────────────────────────── */
.db-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.db-badge-pos  { background: var(--pos-bg);  color: var(--pos);  }
.db-badge-neg  { background: var(--neg-bg);  color: var(--neg);  }
.db-badge-neu  { background: var(--neu-bg);  color: var(--neu);  }
.db-badge-info { background: var(--info-bg); color: var(--info); }


/* ────────────────────────────────────────────────────────────
   6. CARD
   ──────────────────────────────────────────────────────────── */
.db-card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}


/* ────────────────────────────────────────────────────────────
   7. KPI CARD
   ──────────────────────────────────────────────────────────── */
.db-kpi {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}
.db-kpi-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.db-kpi-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent-50);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* tone variants — apply alongside .db-kpi-icon */
.db-kpi-icon-users     { background: #ecfeff; color: var(--tone-users);     }
.db-kpi-icon-pageviews { background: #f3eaff; color: var(--tone-pageviews); }
.db-kpi-icon-time      { background: #fef3c7; color: var(--tone-time);      }
.db-kpi-icon-bounce    { background: var(--neg-bg); color: var(--tone-bounce); }

.db-kpi-label {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.db-kpi-v {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}


/* ────────────────────────────────────────────────────────────
   8. NAV ITEM + CARET
   ──────────────────────────────────────────────────────────── */
.db-nav-wrap { position: relative; }
.db-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.db-nav-item:hover { background: var(--surf-2); color: var(--text); }
.db-nav-item.is-open,
.db-nav-open       { background: var(--accent-50); color: var(--accent); }

.db-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  margin-left: 2px;
  color: var(--text-2);
  transition: transform .15s, color .15s;
}
.db-caret svg {
  width: 12px;
  height: 12px;
  stroke-width: 1.75;
}
.db-nav-item.is-open .db-caret,
.db-nav-open .db-caret {
  color: var(--accent);
  transform: rotate(180deg);
}


/* ────────────────────────────────────────────────────────────
   9. DROPDOWN MENU (single-column)
   ──────────────────────────────────────────────────────────── */
.db-simplemenu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 240px;
  max-width: 320px;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: dbFadeIn .14s ease-out;
}
.db-simplemenu-right {
  left: auto;
  right: 0;
  min-width: 280px;
}

.db-simplemenu-head {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 8px 10px 6px;
}

.db-simplemenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background .12s;
}
.db-simplemenu-item:hover { background: var(--surf-2); }

.db-simplemenu-active {
  background: color-mix(in oklab, var(--accent) 8%, transparent);
}
.db-simplemenu-active:hover {
  background: color-mix(in oklab, var(--accent) 12%, transparent);
}

.db-simplemenu-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surf-2);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.db-simplemenu-icon svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.5;
  fill: none;
  stroke: currentColor;
}

.db-simplemenu-label { flex: 1; font-weight: 500; }
.db-simplemenu-body  {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.db-simplemenu-body .db-simplemenu-label {
  font-weight: 500;
  line-height: 1.2;
}
.db-simplemenu-sub  { font-size: 11.5px; color: var(--text-3); }
.db-simplemenu-check { color: var(--accent); font-weight: 600; }
.db-simplemenu-div   {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}


/* ────────────────────────────────────────────────────────────
   10. TOAST NOTIFICATIONS
   Canonical class names per docs/STYLE_GUIDE.html line 2585:
     .toast + .toast-good / .toast-info / .toast-warn / .toast-bad
   Legacy hub-v2 names (.db-toast / .db-toast-success / -info / -warn /
   -error) stay aliased so existing renderers keep working. New code
   should reach for the unprefixed canonical classes.
   ──────────────────────────────────────────────────────────── */

/* Stack — fixed bottom-right, vertical, never overlaps cards. */
.toast-stack,
.db-toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

/* Toast surface */
.toast,
.db-toast {
  pointer-events: auto;
  width: 360px;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 12px 14px;
  align-items: flex-start;
  animation: dbToastIn .26s cubic-bezier(.2,.9,.3,1.1);
  position: relative;
  overflow: hidden;
}
@media (max-width: 383px) {
  .toast,
  .db-toast {
    max-width: calc(100vw - 48px);
  }
}
.toast-leaving,
.db-toast-leaving { animation: dbToastOut .22s ease-in forwards; }

/* Icon chip */
.toast-icon,
.db-toast-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-icon svg, .db-toast-icon svg { width: 16px; height: 16px; }

/* Variant tones — both canonical and legacy class chains.
   Maps:
     .toast-good  ↔ .db-toast-success → --good
     .toast-info  ↔ .db-toast-info    → --info
     .toast-warn  ↔ .db-toast-warn    → --warn
     .toast-bad   ↔ .db-toast-error   → --bad
*/
.toast-good .toast-icon, .db-toast-success .db-toast-icon { background: var(--good-50); color: var(--good); }
.toast-info .toast-icon, .db-toast-info    .db-toast-icon { background: var(--info-50); color: var(--info); }
.toast-warn .toast-icon, .db-toast-warn    .db-toast-icon { background: var(--warn-50); color: var(--warn); }
.toast-bad  .toast-icon, .db-toast-error   .db-toast-icon { background: var(--bad-50);  color: var(--bad);  }

/* Body */
.toast-body,
.db-toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.toast-title,
.db-toast-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.toast-msg,
.db-toast-msg {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.45;
}

/* Actions — 0-2 buttons. Canonical demo (style guide line 2596) shows
   the warn variant with both Retry + Dismiss; we keep multi-button
   support but Phase A flagged that the user-brief said "1 CTA max" —
   the spec wins. */
.toast-actions,
.db-toast-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.toast-btn,
.db-toast-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surf);
  color: var(--text);
  cursor: pointer;
}
.toast-btn-primary,
.toast-btn-primary *,
.db-toast-btn-primary,
.db-toast-btn-primary * {
  background: var(--accent);
  color: #fff !important;
  border-color: var(--accent);
}
.toast-btn:hover,
.db-toast-btn:hover { filter: brightness(1.05); }

/* Close button — uses .modal-x in canonical spec, .toast-close /
   .db-toast-close in legacy. All map to the same X. */
.toast-close,
.db-toast-close,
.toast .modal-x {
  background: none;
  border: 0;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  margin: -6px -8px -6px 0;
  padding: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.toast-close:hover,
.db-toast-close:hover,
.toast .modal-x:hover { background: var(--surf-2); color: var(--text); }

/* 2px progress drainer along the bottom — drains over 5s linear. */
.toast-progress,
.db-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: var(--info);
  animation: dbToastProgress 5s linear forwards;
  transform-origin: left;
}
.toast-good .toast-progress, .db-toast-success .db-toast-progress { background: var(--good); }
.toast-warn .toast-progress, .db-toast-warn    .db-toast-progress { background: var(--warn); }
.toast-bad  .toast-progress, .db-toast-error   .db-toast-progress { background: var(--bad);  }


/* ────────────────────────────────────────────────────────────
   10b. POPOVER (canonical dropdown surface)
   Per docs/STYLE_GUIDE.html line 714. Used wherever a click reveals
   a list — profile menus, action menus, kebab menus, etc.
   The user's brief said 240px default width; spec says min-width 220
   — going with 240 so titles like "Account settings" don't wrap.
   ──────────────────────────────────────────────────────────── */
.popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surf-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  min-width: 240px;
  padding: 6px;
  z-index: 100;
  animation: dbFadeIn 0.15s ease-out;
}
.popover-right { right: 0; left: auto; }
.popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--motion-fast) var(--ease-out);
}
.popover-item:hover { background: var(--surf-2); }
.popover-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.popover-item-icon {
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.popover-item.is-active { color: var(--accent); }
.popover-item.is-danger { color: var(--bad); }
.popover-divider {
  height: 1px;
  background: var(--border);
  margin: 4px -6px;
}

/* Keyword Research Report — source-backed data truth, issue 913. */
.kwr-truth-strip {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--warn-50);
  color: var(--warn-ink);
  padding: 13px 15px;
  margin-bottom: 16px;
}
.kwr-truth-measured { background: var(--surf-2); color: var(--text-2); }
.kwr-truth-unavailable,
.kwr-truth-estimate-only { background: var(--surf-1); color: var(--text-2); }
.kwr-truth-title { color: var(--ink); font-size: 13px; font-weight: 600; }
.kwr-truth-copy { font-size: 12.5px; line-height: 1.55; margin-top: 3px; }
.kwr-domain-metric-grid,
.kwr-primary-metric-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.kwr-domain-metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kwr-primary-metric-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kwr-metric-value {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.kwr-domain-metric-grid .kwr-metric-value { font-size: 26px; }
.kwr-unavailable { color: var(--text-2); font-size: 13px; font-weight: 600; }
.kwr-source-caption {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.35;
  margin-top: 4px;
}

@media (max-width: 900px) {
  .kwr-domain-metric-grid,
  .kwr-primary-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kwr-keyword-table button { min-height: 44px; }
  .kwr-keyword-table,
  .kwr-keyword-table tbody,
  .kwr-keyword-table tr,
  .kwr-keyword-table td {
    box-sizing: border-box;
    display: block;
    max-width: 100% !important;
    min-width: 0;
    width: 100% !important;
  }
  .kwr-keyword-table { table-layout: fixed; }
  .kwr-keyword-table thead { display: none; }
  .kwr-keyword-table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .kwr-keyword-table td {
    display: grid;
    grid-template-columns: minmax(88px, .7fr) minmax(0, 1fr);
    gap: 12px;
    max-width: none !important;
    padding: 8px 0 !important;
    text-align: left !important;
    white-space: normal !important;
  }
  .kwr-keyword-table td::before {
    color: var(--faint);
    content: attr(data-label);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
}

@media (max-width: 600px) {
  .kwr-domain-metric-grid,
  .kwr-primary-metric-grid { grid-template-columns: minmax(0, 1fr); }
}
.popover-section {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 6px 10px;
}


/* ────────────────────────────────────────────────────────────
   11. ANIMATIONS
   ──────────────────────────────────────────────────────────── */
@keyframes dbFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dbToastIn {
  from { transform: translateX(120%) scale(.96); opacity: 0; }
  to   { transform: translateX(0)    scale(1);   opacity: 1; }
}
@keyframes dbToastOut {
  to { transform: translateX(120%); opacity: 0; }
}
@keyframes dbToastProgress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}


/* ────────────────────────────────────────────────────────────
   12. ACCESSIBILITY
   ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
