/* bb-ui.css — design system chung app BB. Nguon: BB Upsell (/opt/bb-upsell/design/mockups/assets) 2026-12-01. tokens+base+shell+kpi-header+components. */
/* BB Upsell dashboard design tokens: light palette with a dark variant via [data-theme=dark],
 * Inter Tight + Inter type, cobalt accent (hue 262). */

:root {
  /* ---------- paper / ink (light) ---------- */
  --color-paper:      oklch(99% 0.003 250);   /* app background */
  --color-paper-2:    oklch(97% 0.005 250);   /* sidebar, table header, hover */
  --color-paper-3:    oklch(94.5% 0.007 250); /* pressed, code bg */
  --color-surface:    oklch(100% 0 0);        /* cards, inputs, popovers */
  --color-ink:        oklch(20% 0.02 262);    /* primary text */
  --color-ink-2:      oklch(42% 0.02 262);    /* secondary text */
  --color-muted:      oklch(58% 0.015 262);   /* placeholders, tertiary */
  --color-rule:       oklch(91% 0.008 250);   /* borders */
  --color-rule-2:     oklch(86% 0.01 250);    /* input borders, stronger rules */

  /* ---------- accent: cobalt ---------- */
  --color-accent:     oklch(53% 0.215 262);
  --color-accent-2:   oklch(46% 0.215 262);   /* hover */
  --color-accent-3:   oklch(40% 0.2 262);     /* active */
  --color-accent-soft:oklch(95% 0.03 262);    /* tinted bg */
  --color-accent-ink: oklch(100% 0 0);        /* text on accent */
  --color-focus:      oklch(60% 0.2 262);

  /* ---------- semantic ---------- */
  --color-success:    oklch(58% 0.16 150);
  --color-success-soft: oklch(95% 0.05 150);
  --color-warning:    oklch(70% 0.16 70);
  --color-warning-soft: oklch(96% 0.06 80);
  --color-danger:     oklch(55% 0.2 25);
  --color-danger-soft: oklch(95% 0.04 25);
  --color-info:       oklch(58% 0.14 230);
  --color-info-soft:  oklch(95% 0.035 230);
  --color-revenue:    oklch(66% 0.17 60);     /* amber for money series */
  --color-series-2:   oklch(62% 0.14 200);
  --color-series-3:   oklch(64% 0.15 320);
  --color-warning-ink:  oklch(45% 0.12 70);          /* text on warning-soft (badge) */
  --color-warning-icon: oklch(50% 0.13 70);          /* icon on warning-soft (banner) */
  --color-danger-ink:   oklch(100% 0 0);             /* text on danger (btn-danger) */
  --color-scrim:        oklch(20% 0.02 262 / 0.45);  /* overlay backdrop */
  --color-inverse:      oklch(20% 0.02 262);         /* toast / tooltip surface (= ink) */
  --color-inverse-ink:  oklch(99% 0.003 250);        /* text on inverse (= paper) */
  --icon-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  /* ---------- type ---------- */
  --font-display: "Inter Tight", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body:    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;   /* 12 */
  --text-sm: 0.8125rem; /* 13 */
  --text-md: 0.875rem;  /* 14 — app default */
  --text-lg: 1rem;      /* 16 */
  --text-xl: 1.25rem;   /* 20 */
  --text-2xl: 1.5rem;   /* 24 */
  --text-3xl: 1.875rem; /* 30 */
  --text-display: clamp(1.75rem, 1.2rem + 1.2vw, 2.25rem);
  --leading-tight: 1.2;
  --leading-body: 1.5;
  --tracking-display: -0.02em;

  /* ---------- space (4pt) ---------- */
  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;

  /* ---------- shape / depth ---------- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px oklch(20% 0.02 262 / 0.06), 0 1px 1px oklch(20% 0.02 262 / 0.04);
  --shadow-md: 0 4px 12px oklch(20% 0.02 262 / 0.08), 0 1px 3px oklch(20% 0.02 262 / 0.06);
  --shadow-lg: 0 16px 40px oklch(20% 0.02 262 / 0.14), 0 2px 6px oklch(20% 0.02 262 / 0.08);

  /* ---------- motion ---------- */
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 260ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in:  cubic-bezier(0.5, 0, 0.9, 0.4);
  --ease-in-out: cubic-bezier(0.45, 0, 0.2, 1);

  /* ---------- layout ---------- */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 52px;
  --content-max: 1440px;

  color-scheme: light;
}

/* ---------- dark theme ---------- */
:root[data-theme="dark"] {
  --color-paper:      oklch(17% 0.015 262);
  --color-paper-2:    oklch(20% 0.015 262);
  --color-paper-3:    oklch(24% 0.017 262);
  --color-surface:    oklch(21.5% 0.016 262);
  --color-ink:        oklch(95% 0.005 262);
  --color-ink-2:      oklch(76% 0.01 262);
  --color-muted:      oklch(60% 0.012 262);
  --color-rule:       oklch(28% 0.015 262);
  --color-rule-2:     oklch(34% 0.017 262);

  --color-accent:     oklch(70% 0.17 262);
  --color-accent-2:   oklch(76% 0.15 262);
  --color-accent-3:   oklch(64% 0.18 262);
  --color-accent-soft:oklch(28% 0.06 262);
  --color-accent-ink: oklch(15% 0.03 262);
  --color-focus:      oklch(75% 0.16 262);

  --color-success:    oklch(72% 0.15 150);
  --color-success-soft: oklch(26% 0.05 150);
  --color-warning:    oklch(78% 0.15 75);
  --color-warning-soft: oklch(28% 0.05 80);
  --color-danger:     oklch(68% 0.18 25);
  --color-danger-soft: oklch(27% 0.05 25);
  --color-info:       oklch(72% 0.13 230);
  --color-info-soft:  oklch(26% 0.04 230);
  --color-revenue:    oklch(76% 0.15 65);
  --color-series-2:   oklch(74% 0.13 200);
  --color-series-3:   oklch(76% 0.14 320);
  --color-warning-ink:  oklch(78% 0.15 75);
  --color-warning-icon: oklch(78% 0.15 75);
  --color-danger-ink:   oklch(15% 0.03 25);
  --color-scrim:        oklch(5% 0.01 262 / 0.6);
  --color-inverse:      oklch(96% 0 0);
  --color-inverse-ink:  oklch(18% 0 0);
  --icon-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a9aa3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.4);
  --shadow-md: 0 4px 12px oklch(0% 0 0 / 0.45), 0 1px 3px oklch(0% 0 0 / 0.4);
  --shadow-lg: 0 16px 40px oklch(0% 0 0 / 0.6), 0 2px 6px oklch(0% 0 0 / 0.5);

  color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur-base: 0ms; --dur-slow: 0ms; }
}
/* base.css — resets, typography, utilities. Imports tokens. */

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--font-body); font-size: var(--text-md); line-height: var(--leading-body);
  color: var(--color-ink); background: var(--color-paper);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01", "tnum";
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-style: normal; line-height: var(--leading-tight); letter-spacing: var(--tracking-display); overflow-wrap: anywhere; min-width: 0; }
h1 { font-size: var(--text-2xl); font-weight: 600; }
h2 { font-size: var(--text-xl); font-weight: 600; }
h3 { font-size: var(--text-lg); font-weight: 600; }
h4 { font-size: var(--text-md); font-weight: 600; }
p { margin: 0; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 0.92em; }
pre { margin: 0; padding: var(--space-sm) var(--space-md); background: var(--color-paper-3); border-radius: var(--radius-md); overflow-x: auto; font-size: var(--text-sm); line-height: 1.55; }
code:not(pre code) { padding: 1px 5px; background: var(--color-paper-3); border-radius: var(--radius-xs); }
kbd { display: inline-block; padding: 0 5px; min-width: 1.4em; text-align: center; font-size: var(--text-xs); line-height: 1.5; color: var(--color-ink-2); background: var(--color-paper-2); border: 1px solid var(--color-rule-2); border-bottom-width: 2px; border-radius: var(--radius-xs); }
img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--color-rule); margin: var(--space-lg) 0; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--color-accent-soft); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- text utilities ---------- */
.t-xs { font-size: var(--text-xs); } .t-sm { font-size: var(--text-sm); } .t-lg { font-size: var(--text-lg); } .t-xl { font-size: var(--text-xl); }
.t-muted { color: var(--color-muted); } .t-ink2 { color: var(--color-ink-2); } .t-accent { color: var(--color-accent); }
.t-success { color: var(--color-success); } .t-danger { color: var(--color-danger); } .t-warning { color: var(--color-warning); }
.t-medium { font-weight: 500; } .t-semibold { font-weight: 600; } .t-num { font-variant-numeric: tabular-nums; }
.t-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-right { text-align: right; } .t-center { text-align: center; }

/* ---------- layout utilities ---------- */
.row { display: flex; align-items: center; gap: var(--space-xs); min-width: 0; }
.row-sm { display: flex; align-items: center; gap: var(--space-2xs); min-width: 0; }
.row-md { display: flex; align-items: center; gap: var(--space-md); min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.stack-md { display: flex; flex-direction: column; gap: var(--space-md); min-width: 0; }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-lg); min-width: 0; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.shrink0 { flex-shrink: 0; }
.grid { display: grid; gap: var(--space-md); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.mt-xs { margin-top: var(--space-xs); } .mt-sm { margin-top: var(--space-sm); } .mt-md { margin-top: var(--space-md); } .mt-lg { margin-top: var(--space-lg); } .mt-xl { margin-top: var(--space-xl); }
.mb-xs { margin-bottom: var(--space-xs); } .mb-sm { margin-bottom: var(--space-sm); } .mb-md { margin-bottom: var(--space-md); } .mb-lg { margin-bottom: var(--space-lg); }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.hide-mobile { display: initial; } @media (max-width: 900px) { .hide-mobile { display: none !important; } }
.only-mobile { display: none; } @media (min-width: 901px) { .only-mobile { display: none !important; } } @media (max-width: 900px) { .only-mobile { display: initial; } } /* !important above 900 so .btn{display:inline-flex} cannot resurrect the hamburger on desktop */

/* ---------- icon ---------- */
.icon { display: inline-block; vertical-align: -0.2em; width: 16px; height: 16px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
h1 .icon, h2 .icon, h3 .icon { vertical-align: -0.15em; margin-right: 4px; }
.icon-sm { width: 14px; height: 14px; } .icon-lg { width: 20px; height: 20px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
/* shell.css — app frame: sidebar, topbar, page header, content. Navigation: a collapsible side rail. */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns var(--dur-slow) var(--ease-out); }
.app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* ---------- sidebar ---------- */
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--color-paper-2); border-right: 1px solid var(--color-rule); overflow: hidden; }
.sidebar-top { display: flex; align-items: center; gap: var(--space-xs); height: var(--topbar-h); padding: 0 var(--space-sm) 0 var(--space-md); border-bottom: 1px solid var(--color-rule); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--color-ink); }
.brand:hover { text-decoration: none; }
.brand .brand-mark { width: 26px; height: 26px; flex: 0 0 auto; }
.brand .brand-name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); letter-spacing: -0.01em; white-space: nowrap; }
.brand .brand-name b { color: var(--color-accent); font-weight: 600; }
.sidebar-collapse { margin-left: auto; }
.store-switcher { margin: var(--space-sm) var(--space-sm) 0; }
.store-switcher .store-btn { width: 100%; display: flex; align-items: center; gap: var(--space-xs); padding: 6px 8px; border: 1px solid var(--color-rule); background: var(--color-surface); border-radius: var(--radius-md); text-align: left; box-shadow: var(--shadow-sm); }
@media (hover: hover) { .store-switcher .store-btn:hover { border-color: var(--color-rule-2); } }
.store-btn .store-name { font-weight: 500; font-size: var(--text-sm); line-height: 1.2; }
.store-btn .store-domain { font-size: var(--text-xs); color: var(--color-muted); }
.store-btn .icon { margin-left: auto; color: var(--color-muted); }
.store-switcher .menu { width: 100%; }
.nav { padding: var(--space-sm) var(--space-xs); display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1 1 auto; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-muted); padding: var(--space-sm) var(--space-xs) var(--space-2xs); white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 var(--space-xs); border-radius: var(--radius-sm); color: var(--color-ink-2); text-decoration: none; font-size: var(--text-sm); font-weight: 500; white-space: nowrap; position: relative; }
.nav-item .icon { color: var(--color-muted); }
@media (hover: hover) { .nav-item:hover { background: var(--color-paper-3); color: var(--color-ink); text-decoration: none; } }
.nav-item[aria-current="page"] { background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-sm); }
.nav-item[aria-current="page"] .icon { color: var(--color-accent); }
.nav-item .nav-badge { margin-left: auto; font-size: 10px; padding: 1px 6px; border-radius: var(--radius-pill); background: var(--color-paper-3); color: var(--color-ink-2); }
.sidebar-bottom { padding: var(--space-sm) var(--space-xs); border-top: 1px solid var(--color-rule); display: flex; flex-direction: column; gap: 1px; }
.user-chip { display: flex; align-items: center; gap: var(--space-xs); padding: 6px var(--space-xs); border-radius: var(--radius-sm); border: 0; background: transparent; width: 100%; text-align: left; }
@media (hover: hover) { .user-chip:hover { background: var(--color-paper-3); } }
.user-chip .user-name { font-size: var(--text-sm); font-weight: 500; line-height: 1.2; }
.user-chip .user-role { font-size: var(--text-xs); color: var(--color-muted); }

/* collapsed */
.is-collapsed .brand-name, .is-collapsed .nav-group, .is-collapsed .nav-item span, .is-collapsed .nav-badge, .is-collapsed .store-btn .stack, .is-collapsed .store-btn .icon, .is-collapsed .user-chip .stack { display: none; }
.is-collapsed .sidebar-top { padding: 0; justify-content: center; }
.is-collapsed .sidebar-collapse { margin: 0; position: absolute; top: calc(var(--topbar-h) + var(--space-sm) + 36px + 6px); left: 50%; transform: translateX(-50%); } /* collapsed rail: below the store switcher (12px margin + 36px button), in the nav top padding — over the switcher it was unclickable */
.is-collapsed .nav { padding-top: var(--space-2xl); }
.is-collapsed .nav-item { justify-content: center; padding: 0; }
.is-collapsed .store-switcher .store-btn { justify-content: center; padding: 6px; } .is-collapsed .sidebar { z-index: 50; } .is-collapsed .store-switcher .menu { position: fixed; top: calc(var(--topbar-h) + var(--space-sm)); left: calc(var(--sidebar-w-collapsed) + var(--space-2xs)); width: calc(var(--sidebar-w) - var(--space-md)); } /* collapsed rail: menu escapes the 64px column at full width */
.is-collapsed .brand { justify-content: center; }

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-sm); padding: 0 var(--space-lg); background: color-mix(in oklab, var(--color-paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--color-rule); }
.breadcrumbs { display: flex; align-items: center; gap: var(--space-2xs); font-size: var(--text-sm); color: var(--color-muted); min-width: 0; }
.breadcrumbs a { color: var(--color-ink-2); }
.breadcrumbs .sep { color: var(--color-rule-2); }
.breadcrumbs .current { color: var(--color-ink); font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2xs); }
.cmdk-btn { display: inline-flex; align-items: center; gap: var(--space-xs); height: 30px; padding: 0 8px 0 10px; border: 1px solid var(--color-rule); background: var(--color-surface); border-radius: var(--radius-md); color: var(--color-muted); font-size: var(--text-sm); min-width: 220px; }
@media (hover: hover) { .cmdk-btn:hover { border-color: var(--color-rule-2); color: var(--color-ink-2); } }
.cmdk-btn kbd { margin-left: auto; }
.content { padding: var(--space-lg); max-width: var(--content-max); width: 100%; margin: 0 auto; flex: 1 1 auto; }
.content-wide { max-width: 1680px; }
.content-narrow { max-width: 840px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-lg); flex-wrap: wrap; }
.page-header h1 { font-size: var(--text-display); }
.page-header .page-sub { color: var(--color-ink-2); font-size: var(--text-sm); margin-top: var(--space-2xs); max-width: 640px; }
.page-actions { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); margin: var(--space-lg) 0 var(--space-sm); }
.section-title h2 { font-size: var(--text-lg); }
.toolbar { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; padding: var(--space-sm); border-bottom: 1px solid var(--color-rule); background: var(--color-surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.toolbar + .table-wrap { border-top: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table-card { border: 1px solid var(--color-rule); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-card .toolbar { border-radius: 0; }
.table-card .table-wrap { border: 0; border-radius: 0; }
.table-card .table-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-xs) var(--space-sm); border-top: 1px solid var(--color-rule); font-size: var(--text-xs); color: var(--color-muted); flex-wrap: wrap; }
.bulk-bar { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-xs) var(--space-sm); background: var(--color-accent-soft); border-bottom: 1px solid var(--color-rule); font-size: var(--text-sm); }

/* ---------- editor layout (funnel editor) ---------- */
.editor-head { position: sticky; top: var(--topbar-h); z-index: 20; background: var(--color-paper); border-bottom: 1px solid var(--color-rule); padding: var(--space-sm) var(--space-lg); display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; }
.editor-head .stepper { flex: 1 1 320px; max-width: 560px; }
.editor-body { padding: var(--space-lg); max-width: var(--content-max); margin: 0 auto; width: 100%; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-lg); align-items: start; }
.split-rev { grid-template-columns: 360px minmax(0, 1fr); }
@media (max-width: 1100px) { .split, .split-rev { grid-template-columns: minmax(0, 1fr); } }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 72px); }

/* ---------- command palette ---------- */
.cmdk { width: min(640px, 100%); background: var(--color-surface); border: 1px solid var(--color-rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; align-self: start; margin-top: 10vh; animation: rise var(--dur-base) var(--ease-out); }
.cmdk .cmdk-input { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--color-rule); }
.cmdk .cmdk-input input { flex: 1; border: 0; background: transparent; font-size: var(--text-lg); outline: none; }
.cmdk .cmdk-list { max-height: 360px; overflow: auto; padding: var(--space-2xs); }
.cmdk .menu-item { padding: 9px var(--space-sm); }
.cmdk .menu-item.is-active { background: var(--color-paper-2); }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 90; width: var(--sidebar-w); transform: translateX(-100%); transition: transform var(--dur-slow) var(--ease-out); }
  .app.is-nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); z-index: 90; } /* above the drawer scrim (80) even with `.is-collapsed` (50) on the root */
  .content, .editor-body { padding: var(--space-md); }
  .topbar { padding: 0 var(--space-md); }
  .cmdk-btn { min-width: 0; }
  .cmdk-btn span { display: none; }
  .breadcrumbs { flex: 1 1 auto; }
  .breadcrumbs a, .breadcrumbs .sep { display: none; }
  .breadcrumbs .current { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page-header h1 { font-size: var(--text-2xl); }
}
/* KPI header: the five store-wide tiles
 * and the "By page" card. index.html + analytics.html draw the row and the card, funnels.html the row only.
 * Loaded after components.css; apps/dashboard/src/styles/kpi-header.css is a byte copy (styles-parity test). */

/* Tiles 2 + 3: "$5.00 +5.0% AOV lift" and "$100.00 → $105.00" on one baseline. */
.kpi-header .aov-flow { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.kpi-header .aov-flow .from { font-family: var(--font-display); font-size: var(--text-lg); color: var(--color-muted); font-weight: 500; }
.kpi-header .aov-flow .to { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; letter-spacing: var(--tracking-display); }
.kpi-header .aov-flow .lift { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; color: var(--color-success); }
.kpi-header .aov-flow .arrow { color: var(--color-muted); }
/* Tile 4: "2,600 of 4,000" — the denominator smaller and muted beside the count. */
.kpi-header .stat-value .of { font-size: var(--text-lg); font-weight: 500; color: var(--color-muted); }
/* The small print under a tile's figure. */
.sub-line { display: block; font-size: var(--text-xs); color: var(--color-muted); margin-top: 4px; }

/* By page: one column per page, one metric per row, the formula under each row heading. */
.bypage { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.bypage th, .bypage td { padding: 10px var(--space-md); border-bottom: 1px solid var(--color-rule); vertical-align: top; }
.bypage thead th { font-size: var(--text-xs); color: var(--color-muted); font-weight: 500; text-align: right; }
.bypage thead th:first-child { text-align: left; }
.bypage tbody th { text-align: left; font-weight: 500; }
.bypage tbody th .formula { display: block; font-size: var(--text-xs); color: var(--color-muted); font-weight: 400; margin-top: 2px; }
.bypage td { text-align: right; font-variant-numeric: tabular-nums; }
.bypage td .num { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-display); }
.bypage td .sub { display: block; font-size: var(--text-xs); color: var(--color-muted); margin-top: 2px; }
.bypage tr:last-child td, .bypage tr:last-child th { border-bottom: 0; }
.bypage .col-page { width: 26%; }
.bypage .page-head { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--color-ink); }
.bypage .delta { font-size: var(--text-xs); font-weight: 500; display: inline-flex; align-items: center; gap: 2px; }
.bypage .delta.up { color: var(--color-success); } .bypage .delta.down { color: var(--color-danger); }

/* The pages' colours: the share bar and legend above the table, the swatch in each column head.
 * Scoped to the two places that draw them: a bare `.swatch` would also size the component
 * gallery's colour chips (`.s-components .swatch`) and the settings token cards. */
.bypage .swatch, .share-legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; vertical-align: middle; }
.sw-ppu { background: var(--color-accent); }
.sw-typ { background: oklch(62% 0.17 300); }
.sw-order_status { background: var(--color-series-2); }
.share-bar { display: flex; height: 8px; border-radius: var(--radius-pill); overflow: hidden; background: var(--color-paper-3); margin: var(--space-sm) var(--space-md) 0; }
.share-bar > span { display: block; height: 100%; }
.share-legend { display: flex; gap: var(--space-md); font-size: var(--text-xs); color: var(--color-muted); padding: 6px var(--space-md) var(--space-sm); flex-wrap: wrap; }
.share-legend .swatch { width: 8px; height: 8px; margin-right: 4px; }

/* Phone: one tile per row; the table becomes two (or, with the order-status page, three) labelled cells under each metric heading. */
@media (max-width: 760px) {
  .kpi-header { grid-template-columns: minmax(0, 1fr); }
  .bypage thead { display: none; }
  .bypage tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bypage tr:has(> td:nth-of-type(3)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bypage tbody th { grid-column: 1 / -1; padding-bottom: 0; border-bottom: 0; }
  .bypage td { padding-top: 4px; text-align: left; }
  .bypage td::before { content: attr(data-page); display: block; font-size: var(--text-xs); color: var(--color-muted); font-weight: 500; }
  .bypage .col-page { width: auto; }
}
/* components.css — buttons, inputs, badges, cards, tables, overlays. Every interactive element ships 8 states.
 * Forced-state helper classes (.is-hover .is-focus .is-active) exist so the components gallery can render all states at once. */

/* ================= BUTTONS ================= */
.btn {
  --btn-bg: var(--color-surface); --btn-fg: var(--color-ink); --btn-bd: var(--color-rule-2);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  height: 34px; padding: 0 var(--space-sm); min-width: 34px; white-space: nowrap;
  font-weight: 500; font-size: var(--text-sm); line-height: 1;
  color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-bd); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); position: relative; user-select: none;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.btn::before { content: ""; position: absolute; inset: -5px; } /* 44px hit target */ .btn-group .btn::before, .row-actions .btn::before, .segmented .btn::before, .pagination .btn::before { content: none; } /* no hit-area overlap between tight neighbours */
@media (hover: hover) { .btn:hover { --btn-bg: var(--color-paper-2); } }
.btn.is-hover { --btn-bg: var(--color-paper-2); }
.btn:focus-visible, .btn.is-focus { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.btn:active, .btn.is-active { --btn-bg: var(--color-paper-3); transform: translateY(1px); box-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; box-shadow: none; }
.btn[data-state="loading"] { color: transparent; pointer-events: none; }
.btn[data-state="loading"]::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--btn-fg); border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn-primary[data-state="loading"]::after { border-color: var(--color-accent-ink); border-right-color: transparent; }
.btn[data-state="success"] { --btn-bg: var(--color-success-soft); --btn-fg: var(--color-success); --btn-bd: var(--color-success); }
.btn[data-state="error"] { --btn-bg: var(--color-danger-soft); --btn-fg: var(--color-danger); --btn-bd: var(--color-danger); }

.btn-primary { --btn-bg: var(--color-accent); --btn-fg: var(--color-accent-ink); --btn-bd: var(--color-accent); }
@media (hover: hover) { .btn-primary:hover { --btn-bg: var(--color-accent-2); --btn-bd: var(--color-accent-2); } }
.btn-primary.is-hover { --btn-bg: var(--color-accent-2); --btn-bd: var(--color-accent-2); }
.btn-primary:active, .btn-primary.is-active { --btn-bg: var(--color-accent-3); --btn-bd: var(--color-accent-3); }

.btn-danger { --btn-bg: var(--color-danger); --btn-fg: var(--color-danger-ink); --btn-bd: var(--color-danger); }
@media (hover: hover) { .btn-danger:hover { filter: brightness(0.92); } }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--color-ink-2); }
@media (hover: hover) { .btn-ghost:hover { --btn-bg: var(--color-paper-2); color: var(--color-ink); } }
.btn-ghost.is-hover { --btn-bg: var(--color-paper-2); color: var(--color-ink); }
.btn-link { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--color-accent); padding: 0; height: auto; }
@media (hover: hover) { .btn-link:hover { text-decoration: underline; } }
.btn-sm { height: 28px; padding: 0 var(--space-xs); font-size: var(--text-xs); min-width: 28px; border-radius: var(--radius-sm); }
.btn-lg { height: 40px; padding: 0 var(--space-md); font-size: var(--text-md); }
.btn-icon { padding: 0; width: 34px; }
.btn-icon.btn-sm { width: 28px; }
.btn-pill { border-radius: var(--radius-pill); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= INPUTS ================= */
.field { display: flex; flex-direction: column; gap: var(--space-2xs); min-width: 0; }
.label { font-size: var(--text-sm); font-weight: 500; color: var(--color-ink); display: flex; align-items: center; gap: var(--space-2xs); }
.label .req { color: var(--color-danger); }
.label .opt { color: var(--color-muted); font-weight: 400; }
.help { font-size: var(--text-xs); color: var(--color-muted); line-height: 1.45; }
.help.is-error { color: var(--color-danger); }
.help.is-success { color: var(--color-success); }
.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 var(--space-sm); font-size: var(--text-sm);
  color: var(--color-ink); background: var(--color-surface);
  border: 1px solid var(--color-rule-2); border-radius: var(--radius-md);
  outline: 2px solid transparent; outline-offset: 1px;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.textarea { height: auto; min-height: 84px; padding: var(--space-xs) var(--space-sm); resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--color-muted); }
@media (hover: hover) { .input:hover, .select:hover, .textarea:hover { background: var(--color-paper-2); } }
.input.is-hover { background: var(--color-paper-2); }
.input:focus, .select:focus, .textarea:focus, .input.is-focus { outline-color: var(--color-focus); border-color: var(--color-ink-2); background: var(--color-surface); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--color-danger); }
.input[aria-invalid="true"]:focus { outline-color: var(--color-danger); }
.input.is-success { border-color: var(--color-success); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; background: var(--color-paper-2); }
.input:read-only { background: var(--color-paper-2); color: var(--color-ink-2); }
.input-sm { height: 28px; font-size: var(--text-xs); }
.input-group { display: flex; align-items: center; position: relative; }
.input-group .input { padding-left: 32px; }
.input-group > .icon { position: absolute; left: 10px; color: var(--color-muted); pointer-events: none; }
.input-group .addon { position: absolute; right: 8px; font-size: var(--text-xs); color: var(--color-muted); }
.input-group .addon-l { position: static; height: 34px; display: flex; align-items: center; padding: 0 var(--space-sm); background: var(--color-paper-2); border: 1px solid var(--color-rule-2); border-right: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); font-size: var(--text-sm); color: var(--color-ink-2); }
.input-group .addon-l + .input { border-radius: 0 var(--radius-md) var(--radius-md) 0; padding-left: var(--space-sm); }
.select { appearance: none; padding-right: 30px; background-image: var(--icon-select-chevron); background-repeat: no-repeat; background-position: right 10px center; }
.select-sm { height: 28px; font-size: var(--text-xs); }

/* check / radio / switch */
.check, .radio { display: inline-flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); cursor: pointer; min-height: 24px; }
.check input, .radio input { appearance: none; width: 16px; height: 16px; margin: 0; border: 1px solid var(--color-rule-2); border-radius: var(--radius-xs); background: var(--color-surface); display: grid; place-content: center; transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); flex: 0 0 auto; }
.radio input { border-radius: 50%; }
.check input::before { content: ""; width: 10px; height: 10px; transform: scale(0); background: var(--color-accent-ink); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); transition: transform var(--dur-fast) var(--ease-out); }
.radio input::before { content: ""; width: 8px; height: 8px; border-radius: 50%; transform: scale(0); background: var(--color-accent-ink); transition: transform var(--dur-fast) var(--ease-out); }
.check input:checked, .radio input:checked { background: var(--color-accent); border-color: var(--color-accent); }
.check input:checked::before, .radio input:checked::before { transform: scale(1); }
.check input:indeterminate { background: var(--color-accent); border-color: var(--color-accent); }
.check input:indeterminate::before { transform: scale(1); clip-path: inset(40% 15% 40% 15%); }
.check input:disabled, .radio input:disabled { opacity: 0.5; cursor: not-allowed; }
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--space-xs); cursor: pointer; font-size: var(--text-sm); }
.switch input { appearance: none; margin: 0; width: 34px; height: 20px; border-radius: var(--radius-pill); background: var(--color-rule-2); position: relative; transition: background var(--dur-base) var(--ease-out); flex: 0 0 auto; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--color-surface); box-shadow: var(--shadow-sm); transition: transform var(--dur-base) var(--ease-out); }
.switch input:checked { background: var(--color-accent); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:disabled { opacity: 0.5; cursor: not-allowed; }
.switch-sm input { width: 28px; height: 16px; } .switch-sm input::after { width: 12px; height: 12px; } .switch-sm input:checked::after { transform: translateX(12px); }

/* segmented */
.segmented { display: inline-flex; padding: 3px; background: var(--color-paper-2); border-radius: var(--radius-md); border: 1px solid var(--color-rule); }
.segmented button { height: 26px; padding: 0 var(--space-sm); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--color-ink-2); font-size: var(--text-sm); font-weight: 500; display: inline-flex; align-items: center; gap: var(--space-2xs); }
.segmented button[aria-pressed="true"], .segmented button[data-active], .segmented button[aria-checked="true"], .segmented button.is-on { background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-sm); }
@media (hover: hover) { .segmented button:hover:not([aria-pressed="true"]):not([data-active]):not([aria-checked="true"]) { color: var(--color-ink); } }

/* ================= BADGES / TAGS ================= */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 500; line-height: 1; white-space: nowrap; background: var(--color-paper-3); color: var(--color-ink-2); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning-ink); }
/* warning text/icon inks are dark-aware tokens (--color-warning-ink / --color-warning-icon) — no per-theme overrides needed */
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }
.badge-accent { background: var(--color-accent-soft); color: var(--color-accent); }
.badge-outline { background: transparent; border: 1px solid var(--color-rule-2); }
.badge-sq { border-radius: var(--radius-xs); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--color-rule-2); background: var(--color-surface); font-size: var(--text-xs); }
.tag button { border: 0; background: transparent; padding: 2px; border-radius: var(--radius-xs); color: var(--color-muted); display: grid; place-items: center; }
@media (hover: hover) { .tag button:hover { background: var(--color-paper-3); color: var(--color-ink); } }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: var(--text-xs); font-weight: 600; background: var(--color-accent-soft); color: var(--color-accent); flex: 0 0 auto; }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; } .avatar-lg { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar-sq { border-radius: var(--radius-sm); }

/* ================= CARDS ================= */
.card { background: var(--color-surface); border: 1px solid var(--color-rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-body { padding: var(--space-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--color-rule); min-height: 48px; }
.card-footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-xs); padding: var(--space-sm) var(--space-md); border-top: 1px solid var(--color-rule); }
.card-flat { box-shadow: none; }
.card-clickable { cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
@media (hover: hover) { .card-clickable:hover { border-color: var(--color-rule-2); transform: translateY(-1px); box-shadow: var(--shadow-md); } }
.card-selected { border-color: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent); }
.stat { padding: var(--space-md); }
.stat .stat-label { font-size: var(--text-xs); color: var(--color-muted); font-weight: 500; text-transform: none; }
.stat .stat-value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; letter-spacing: var(--tracking-display); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .stat-delta { font-size: var(--text-xs); font-weight: 500; display: inline-flex; align-items: center; gap: 2px; }
.stat .stat-delta.up { color: var(--color-success); } .stat .stat-delta.down { color: var(--color-danger); }

/* ================= TABLE ================= */
.table-wrap { overflow-x: auto; position: relative; border: 1px solid var(--color-rule); border-radius: var(--radius-lg); background: var(--color-surface); } /* relative: an `.sr-only` cell label is absolutely positioned and must scroll with the table, not widen the page */
.table { font-size: var(--text-sm); }
.table th { text-align: left; font-weight: 500; color: var(--color-ink-2); font-size: var(--text-xs); padding: 10px var(--space-sm); background: var(--color-paper-2); border-bottom: 1px solid var(--color-rule); white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; } .table th.sortable button.sort { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; text-align: inherit; border-radius: var(--radius-xs); } .table th[aria-sort="none"] .sort .icon { display: none; }
.table th .sort { display: inline-flex; align-items: center; gap: 3px; }
.table td { padding: 12px var(--space-md); border-bottom: 1px solid var(--color-rule); vertical-align: middle; line-height: 1.45; }
.table th { padding-left: var(--space-md); padding-right: var(--space-md); }
.table tr:last-child td { border-bottom: 0; }
@media (hover: hover) { .table tbody tr:hover td { background: var(--color-paper-2); } }
.table tr.is-selected td { background: var(--color-accent-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-actions { display: inline-flex; gap: 2px; opacity: 0.55; }
@media (hover: hover) { .table tbody tr:hover .row-actions { opacity: 1; } } .table tbody tr:focus-within .row-actions, .row-actions:focus-within { opacity: 1; }
.table-dense td, .table-dense th { padding: 6px var(--space-xs); }
.drag-handle { color: var(--color-muted); cursor: grab; }
/* repeater items — one row of an editable list (FAQ, testimonials, copy variants, thank-you branches) */
.rep-item { padding: var(--space-sm); border: 1px solid var(--color-rule); border-radius: var(--radius-md); display: flex; flex-direction: column; gap: var(--space-xs); }
.rep-item .rep-head { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--color-muted); }

/* ================= TABS ================= */
.tabs { display: flex; gap: var(--space-2xs); border-bottom: 1px solid var(--color-rule); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"], .tabs .tab-link { text-decoration: none; height: 38px; padding: 0 var(--space-sm); border: 0; background: transparent; color: var(--color-ink-2); font-size: var(--text-sm); font-weight: 500; position: relative; white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-2xs); }
.tabs [role="tab"]::after, .tabs .tab-link::after { content: ""; position: absolute; left: var(--space-xs); right: var(--space-xs); bottom: -1px; height: 2px; background: transparent; border-radius: 2px 2px 0 0; }
.tabs [role="tab"][aria-selected="true"], .tabs .tab-link[aria-current="page"] { color: var(--color-ink); }
.tabs [role="tab"][aria-selected="true"]::after, .tabs .tab-link[aria-current="page"]::after { background: var(--color-accent); }
@media (hover: hover) { .tabs [role="tab"]:hover, .tabs .tab-link:hover { color: var(--color-ink); } }
.tabs .count { font-size: var(--text-xs); padding: 1px 6px; border-radius: var(--radius-pill); background: var(--color-paper-3); color: var(--color-ink-2); }
.tab-panel[hidden] { display: none; }

/* ================= MENUS / POPOVERS ================= */
.menu { position: absolute; z-index: 40; min-width: 200px; padding: var(--space-2xs); background: var(--color-surface); border: 1px solid var(--color-rule); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); animation: pop var(--dur-fast) var(--ease-out); }
.menu[hidden] { display: none; }
.menu .menu-item { display: flex; align-items: center; gap: var(--space-xs); width: 100%; padding: 7px var(--space-xs); border: 0; background: transparent; border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--color-ink); text-align: left; }
@media (hover: hover) { .menu .menu-item:hover { background: var(--color-paper-2); } }
.menu .menu-item .icon { color: var(--color-muted); }
.menu .menu-item.is-danger { color: var(--color-danger); }
.menu .menu-item.is-danger .icon { color: inherit; }
.menu .menu-item[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.menu .menu-sep { height: 1px; margin: var(--space-2xs) 0; background: var(--color-rule); }
.menu .menu-head { padding: 6px var(--space-xs) 4px; font-size: var(--text-xs); color: var(--color-muted); font-weight: 500; }
.menu .menu-item .shortcut { margin-left: auto; color: var(--color-muted); font-size: var(--text-xs); }
.menu-rich .menu-item { align-items: flex-start; padding: var(--space-xs); }
.menu-rich .menu-item .desc { display: block; font-size: var(--text-xs); color: var(--color-muted); margin-top: 1px; }
.menu-anchor { position: relative; display: inline-block; }
.menu-anchor > .menu { top: calc(100% + 4px); left: 0; }
.menu-anchor.menu-right > .menu { left: auto; right: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.tooltip { position: absolute; z-index: 50; padding: 4px 8px; font-size: var(--text-xs); background: var(--color-inverse); color: var(--color-inverse-ink); border-radius: var(--radius-sm); white-space: nowrap; pointer-events: none; }
/* inverse surface tokens (--color-inverse / --color-inverse-ink) flip per theme in tokens.css */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%) translateY(2px); padding: 4px 8px; font-size: var(--text-xs); font-weight: 400; background: var(--color-inverse); color: var(--color-inverse-ink); border-radius: var(--radius-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--dur-fast) var(--ease-out) 800ms, transform var(--dur-fast) var(--ease-out) 800ms; z-index: 50; }
@media (hover: hover) { [data-tip]:hover::after { opacity: 1; transform: translateX(-50%); } }
[data-tip]:focus-visible::after { opacity: 1; transform: translateX(-50%); transition-delay: 0ms; }
/* [data-tip] text is mirrored into a hidden element referenced by aria-describedby (app.js BBU.describeTip) so screen readers get it */

/* ================= MODAL / DRAWER ================= */
.overlay { position: fixed; inset: 0; z-index: 100; background: var(--color-scrim); display: grid; place-items: center; padding: var(--space-md); animation: fade var(--dur-base) var(--ease-out); }
.overlay[hidden] { display: none; }
.overlay.is-drawer { place-items: stretch end; padding: 0; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 2 * var(--space-md)); overflow: auto; background: var(--color-surface); border: 1px solid var(--color-rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: rise var(--dur-base) var(--ease-out); }
.modal-lg { width: min(860px, 100%); } .modal-sm { width: min(420px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-md) var(--space-lg) var(--space-sm); }
.modal-body { padding: 0 var(--space-lg) var(--space-md); }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-xs); padding: var(--space-sm) var(--space-lg); border-top: 1px solid var(--color-rule); background: var(--color-paper-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.drawer { width: min(520px, 100vw); height: 100vh; overflow: auto; background: var(--color-surface); border-left: 1px solid var(--color-rule); box-shadow: var(--shadow-lg); animation: slide var(--dur-slow) var(--ease-out); display: flex; flex-direction: column; }
.drawer-lg { width: min(760px, 100vw); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--color-rule); }
.drawer-body { padding: var(--space-lg); flex: 1 1 auto; }
.drawer-footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-xs); padding: var(--space-sm) var(--space-lg); border-top: 1px solid var(--color-rule); background: var(--color-paper-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }

/* ================= TOAST / BANNER ================= */
.toast-stack { position: fixed; right: var(--space-md); bottom: var(--space-md); z-index: 120; display: flex; flex-direction: column; gap: var(--space-xs); width: min(380px, calc(100vw - 2 * var(--space-md))); }
.toast { display: flex; align-items: flex-start; gap: var(--space-xs); padding: var(--space-sm) var(--space-md); background: var(--color-inverse); color: var(--color-inverse-ink); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: var(--text-sm); animation: rise var(--dur-base) var(--ease-out); }
/* toast surface uses the inverse tokens; max 4 visible, per-tone auto-dismiss, hover pauses (app.js) */
.toast .icon { margin-top: 2px; }
.toast.is-success .icon { color: var(--color-success); } .toast.is-error .icon { color: var(--color-danger); } .toast.is-warning .icon { color: var(--color-warning); }
.toast .toast-action { margin-left: auto; background: transparent; border: 0; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; padding: 0; }
.banner { display: flex; align-items: flex-start; gap: var(--space-xs); padding: var(--space-sm) var(--space-md); border: 1px solid var(--color-rule); border-radius: var(--radius-md); background: var(--color-paper-2); font-size: var(--text-sm); }
.banner .icon { margin-top: 2px; flex: 0 0 auto; }
.banner-info { background: var(--color-info-soft); border-color: transparent; color: var(--color-ink); } .banner-info .icon { color: var(--color-info); }
.banner-success { background: var(--color-success-soft); border-color: transparent; } .banner-success .icon { color: var(--color-success); }
.banner-warning { background: var(--color-warning-soft); border-color: transparent; } .banner-warning .icon { color: var(--color-warning-icon); }
.banner-danger { background: var(--color-danger-soft); border-color: transparent; } .banner-danger .icon { color: var(--color-danger); }
.banner .banner-close { margin-left: auto; }

/* ================= MISC ================= */
.skeleton { background: linear-gradient(90deg, var(--color-paper-2) 25%, var(--color-paper-3) 50%, var(--color-paper-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--radius-sm); min-height: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-xs); padding: var(--space-2xl) var(--space-lg); color: var(--color-ink-2); }
.empty .empty-icon { width: 44px; height: 44px; border-radius: var(--radius-lg); background: var(--color-paper-2); display: grid; place-items: center; color: var(--color-muted); }
.empty h2, .empty h3 { color: var(--color-ink); font-size: var(--text-lg); }
.empty p { max-width: 380px; font-size: var(--text-sm); color: var(--color-muted); }
.progress { height: 6px; background: var(--color-paper-3); border-radius: var(--radius-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--color-accent); border-radius: inherit; }
.progress.is-success > span { background: var(--color-success); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--color-rule-2); border-top-color: var(--color-accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
.pagination { display: flex; align-items: center; gap: var(--space-2xs); }
.pagination .page { min-width: 28px; height: 28px; padding: 0 6px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; font-size: var(--text-sm); color: var(--color-ink-2); }
.pagination .page[aria-current="page"] { background: var(--color-surface); border-color: var(--color-rule-2); color: var(--color-ink); font-weight: 500; }
@media (hover: hover) { .pagination .page:hover { background: var(--color-paper-2); } }
.stepper { display: flex; gap: var(--space-md); }
.stepper .step { flex: 1; display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.stepper .step .bar { height: 3px; border-radius: 2px; background: var(--color-rule); }
.stepper .step.is-done .bar { background: var(--color-success); } .stepper .step.is-current .bar { background: var(--color-accent); }
.stepper .step .step-name { font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-2); display: flex; align-items: center; gap: var(--space-2xs); }
.stepper .step.is-current .step-name { color: var(--color-ink); }
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-md); } .kpi-row--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1024px) { .kpi-row, .kpi-row--5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.divider-v { width: 1px; align-self: stretch; background: var(--color-rule); }
.code-block { position: relative; }
.code-block .copy { position: absolute; top: 6px; right: 6px; }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2xs) var(--space-md); font-size: var(--text-sm); margin: 0; }
.dl dt { color: var(--color-muted); } .dl dd { margin: 0; }
.chart { width: 100%; height: auto; }
/* Big charts: fixed pixel height, drawing stretches to the box, strokes stay 2px, labels live in HTML (never scale). */
.chart-box { position: relative; width: 100%; }
.chart-box > .chart { display: block; width: 100%; height: 240px; }
.chart-box .chart path, .chart-box .chart line, .chart-box .chart polyline, .chart-box .chart circle { vector-effect: non-scaling-stroke; }
.chart-box.has-y { padding-left: 44px; }
.chart-box .chart-y { position: absolute; left: 0; top: 0; height: 240px; width: 40px; font-size: var(--text-xs); color: var(--color-muted); }
.chart-box .chart-y span { position: absolute; right: 0; transform: translateY(-50%); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-box .chart-x { position: relative; height: 18px; margin-top: 6px; font-size: var(--text-xs); color: var(--color-muted); }
.chart-box .chart-x span { position: absolute; top: 0; white-space: nowrap; }
.chart-box.chart-sm > .chart, .chart-box.chart-sm .chart-y { height: 120px; }
.chart .axis { stroke: var(--color-rule-2); stroke-width: 1; }
.chart .grid-line { stroke: var(--color-rule); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .line-1 { fill: none; stroke: var(--color-accent); stroke-width: 2; }
.chart .line-2 { fill: none; stroke: var(--color-revenue); stroke-width: 2; } .chart .line-3 { fill: none; stroke: var(--color-series-3); stroke-width: 2; }
.chart .area-1 { fill: var(--color-accent); opacity: 0.08; }
.chart .bar-1 { fill: var(--color-accent); } .chart .bar-2 { fill: var(--color-revenue); } .chart .bar-muted { fill: var(--color-rule-2); }
.chart text { font-family: var(--font-body); font-size: 11px; fill: var(--color-muted); }
.spark { width: 96px; height: 28px; }
.legend { display: flex; gap: var(--space-md); font-size: var(--text-xs); color: var(--color-ink-2); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--c, var(--color-accent)); vertical-align: middle; }
