/*
 * UltraFrontend components — the "New" design of the Ultrafast Search platform (October 2026).
 * Needs ultra-tokens.css (and ultra-fonts.css). Values are the platform's own (public/ui/v2/app.css,
 * components.css, electric.css, console.css), merged into one file without the design switch.
 *
 * Look in one line: a dark navigation rail beside a cool light canvas; every page opens with a tinted
 * header card; white cards with a soft long shadow and 22 px corners; pill buttons, the primary one with
 * the indigo→violet gradient; dark "night" cards for the one big number or chart; light and dark themes.
 */

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font-sans); font-size: 14px; line-height: 1.55;
  color: var(--text-primary); background: var(--bg-page); -webkit-font-smoothing: antialiased;
}
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--text-primary); text-wrap: balance; }
h2 { font-size: var(--text-lg); font-weight: 600; }
h3 { font-size: var(--text-base); font-weight: 600; }
p { margin: 0; }
code, kbd, .mono { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.num, .kpi-v, .stat-value, .table .num { font-variant-numeric: tabular-nums; }

/* ── Shell: dark rail + canvas ────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--rail) var(--rail-width), transparent var(--rail-width)); }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 24px 28px 96px; display: flex; flex-direction: column; gap: 20px; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px;
  padding: 20px 14px 16px; background: var(--rail); color: var(--rail-ink);
  overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--rail-3) transparent;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; color: var(--rail-strong); font: 800 16.5px/1.1 var(--font-display); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; background: var(--color-gradient); color: var(--text-on-brand); display: grid; place-items: center; flex: none; box-shadow: 0 8px 18px -8px var(--brand-glow); }
.brand-mark svg { width: 18px; height: 18px; }

/* "Find anything" in the rail (opens the palette; Ctrl K) */
.rail-find {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--rail-3); background: var(--rail-2); color: var(--rail-ink-2);
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.rail-find:hover { color: var(--rail-ink); border-color: var(--rail-ink-2); }
.rail-find svg { width: 15px; height: 15px; flex: none; }
.rail-find kbd { margin-left: auto; font: 500 10.5px var(--font-mono); border: 1px solid currentColor; border-radius: 6px; padding: 1px 6px; opacity: 0.75; }

/* The thing this menu works on (a shop, a workspace) with its live state */
.rail-ctx { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--rail-2); border: 1px solid var(--rail-3); color: var(--rail-ink); min-width: 0; }
.rail-ctx:hover { text-decoration: none; border-color: var(--rail-ink-2); }
.rail-ctx-logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(140deg, #F3D9C4, #D5A383); color: #5A3824; display: grid; place-items: center; font: 800 11px var(--font-display); letter-spacing: 0.06em; flex: none; }
.rail-ctx-text { min-width: 0; }
.rail-ctx-text b { display: block; color: var(--rail-strong); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-ctx-text small { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--rail-ink-2); }
.rail-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rail-good); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); flex: none; }
.rail-dot.off { background: var(--rail-ink-2); box-shadow: none; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 12px 12px 6px; font: 700 10.5px/1 var(--font-sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--rail-ink-2); }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 12px; color: var(--rail-ink); font-size: 13.5px; font-weight: 500; }
.nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a svg { width: 18px; height: 18px; flex: none; color: var(--rail-ink-2); }
.nav a:hover { background: var(--rail-2); color: var(--rail-strong); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--color-gradient); color: var(--text-on-brand); font-weight: 600; box-shadow: 0 10px 22px -12px var(--brand-glow); }
.nav a[aria-current="page"] svg { color: var(--text-on-brand); }
.nav a.nav-sub { padding: 6px 12px 6px 41px; font-size: 12.5px; color: var(--rail-ink-2); }
.nav a.nav-sub svg { display: none; }
.nav a.nav-sub:hover { color: var(--rail-strong); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.livecard { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 14px; background: var(--rail-2); border: 1px solid var(--rail-3); font-size: 12.5px; color: var(--rail-ink); }
.livecard b { color: var(--rail-strong); }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 4px 0; border-top: 1px solid var(--rail-3); }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; color: var(--rail-strong); font-weight: 600; font-size: 13px; }
.me .who span { display: block; font-size: 11.5px; color: var(--rail-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--color-gradient); color: var(--text-on-brand); display: grid; place-items: center; font-weight: 700; font-size: var(--text-xs); flex: none; }
.railbtn { width: 32px; height: 32px; border-radius: 9px; border: 0; background: transparent; color: var(--rail-ink-2); display: grid; place-items: center; cursor: pointer; flex: none; padding: 0; }
.railbtn:hover { background: var(--rail-2); color: var(--rail-strong); }
.railbtn svg { width: 18px; height: 18px; }

/* Phone bar: hidden on a computer (the rail has everything) */
.topbar { display: none; }
.menu-btn { display: none; }
.scrim { display: none; }

/* Round "Find anything" button, bottom right */
.fab {
  position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 35; width: 54px; height: 54px; border-radius: 50%;
  border: 0; background: var(--color-gradient); color: var(--text-on-brand); display: grid; place-items: center; cursor: pointer; box-shadow: 0 16px 30px -12px var(--brand-glow);
}
.fab svg { width: 22px; height: 22px; }
.fab:hover { box-shadow: 0 18px 34px -12px var(--brand-glow); }

/* ── Page header card: icon tile, eyebrow, title, subtitle, actions; a bar for tabs/filters ── */
.phead { position: relative; overflow: hidden; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.phead::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 160% at 0% 0%, var(--head-a), transparent 62%), radial-gradient(40% 120% at 100% 0%, var(--head-b), transparent 70%);
}
.phead-top { position: relative; display: flex; gap: 18px; align-items: flex-start; padding: 24px 28px 22px; flex-wrap: wrap; }
.phead-ic { width: 46px; height: 46px; border-radius: 14px; background: var(--bg-surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--color-primary); box-shadow: var(--shadow); flex: none; }
.phead-ic svg { width: 21px; height: 21px; }
.phead-text { min-width: 0; flex: 1 1 320px; }
.eyebrow { font: 700 11px/1 var(--font-sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--color-primary); }
.phead h1 { font: 800 31px/1.12 var(--font-display); letter-spacing: -0.025em; margin: 7px 0 6px; }
.phead .sub { color: var(--text-secondary); max-width: 68ch; }
.phead-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.phead-bar {
  position: relative; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 28px 14px;
  border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg-surface) 70%, transparent);
}
.phead-bar .bar-meta { margin-left: auto; font-size: 12.5px; color: var(--text-muted); }
.input.phead-find { width: 220px; margin-left: auto; height: 34px; border-radius: 999px; padding-left: 14px; }

/* ── Cards ── */
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); min-width: 0; margin: 0; padding: 0; color: var(--text-primary); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 0; }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.card-head .sub { color: var(--text-muted); font-size: var(--text-sm); }
.card-head .end { margin-left: auto; }
.card-body { padding: 16px 22px 20px; }

/* A settings box whose heading sits on a clearly indigo band with a brand stripe (owner: a heading must stand out) */
.box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); padding: 0 22px 8px; }
.box > h3 {
  position: relative; display: flex; align-items: center; gap: 12px; margin: 0 -22px 10px; padding: 12px 22px; min-height: 56px;
  background: var(--band-bg); border-bottom: 1px solid var(--band-line); color: var(--band-ink); box-shadow: inset 4px 0 0 var(--color-primary);
  border-radius: calc(var(--radius-xl) - 1px) calc(var(--radius-xl) - 1px) 0 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
}
.box > h3 .ic { width: 32px; height: 32px; border-radius: 10px; background: var(--bg-surface); }
.box-fields > .field { padding: 14px 0; border-top: 1px solid var(--border); margin: 0; }
.box-fields > .field:first-child { border-top: 0; padding-top: 6px; }
.section-title { font: 800 20px/1.2 var(--font-display); letter-spacing: -0.02em; padding: 0 4px; }

/* Night card: the one big number or chart on a page */
.night {
  position: relative; overflow: hidden; color: #fff; min-width: 0; border: 0;
  background: var(--night-gradient); border-radius: var(--radius-xl); padding: 24px 26px 18px; box-shadow: var(--night-shadow);
  --chart-bar: rgba(255, 255, 255, 0.82); --chart-grid: rgba(255, 255, 255, 0.11); --chart-ink: rgba(255, 255, 255, 0.48); --chart-line: #6EE7B7;
}
.night::after { content: ""; position: absolute; right: -120px; top: -140px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(closest-side, var(--night-orb), transparent); pointer-events: none; }
.night > * { position: relative; }
.night h2, .night h3 { color: #fff; }
.night .muted, .night-label { color: rgba(255, 255, 255, 0.70); }
.night-label b { color: #fff; font-weight: 600; }
.night-num { font: 800 58px/1.05 var(--font-sans); letter-spacing: -0.045em; margin: 14px 0 12px; color: #fff; font-variant-numeric: tabular-nums; }
.night .dpill { background: #fff; color: var(--night-1); }
.night .btn-secondary { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.28); }
.night .btn-secondary:hover { background: rgba(255, 255, 255, 0.08); }

/* Tip / explanation card */
.tip-card { display: flex; gap: 14px; padding: 16px; border-radius: var(--radius-xl); background: var(--bg-purple-tint); border: 1px solid var(--color-primary-a20); }
.tip-card .ic { background: var(--bg-surface); color: var(--color-primary); }
.tip-card b { display: block; font-size: var(--text-sm); }
.tip-card p { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }

/* ── Figures: icon tiles, KPI cards, delta pills, count chips ── */
.ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.ic svg { width: 18px; height: 18px; }
.t-brand  { background: var(--t-brand);  color: var(--c-brand); }   /* follows the palette: searches, discovery */
.t-violet { background: var(--t-violet); color: var(--c-violet); }
.t-teal   { background: var(--t-teal);   color: var(--c-teal); }
.t-amber  { background: var(--t-amber);  color: var(--c-amber); }
.t-rose   { background: var(--t-rose);   color: var(--c-rose); }
.t-sky    { background: var(--t-sky);    color: var(--c-sky); }
.kpi { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
.kpi-h { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text-secondary); font-size: 13.5px; }
.kpi-h .ic { width: 34px; height: 34px; border-radius: 10px; }
.kpi-v { font: 800 30px/1 var(--font-sans); letter-spacing: -0.03em; color: var(--text-primary); }
.kpi-v small { font-size: 15px; font-weight: 600; color: var(--text-muted); letter-spacing: 0; margin-left: 3px; }
.kpi-f { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); margin-top: auto; }
.dpill { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 999px; font: 700 12px/1.3 var(--font-sans); background: var(--bg-muted); color: var(--text-secondary); }
.dpill.good { background: var(--color-success-light); color: var(--color-success-text); }
.dpill.bad  { background: var(--color-danger-light);  color: var(--color-danger-text); }
.countchip { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-secondary); }
.countchip b { font-weight: 700; color: var(--text-primary); font-size: 14px; }

/* ── Grids ── */
.grid-4 { display: grid; gap: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
.row3 { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ── Buttons: pills ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 999px;
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.25; border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--color-gradient); color: var(--text-on-brand); box-shadow: 0 10px 22px -12px var(--brand-glow); }
.btn-primary:hover { box-shadow: 0 14px 26px -12px var(--brand-glow); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--text-muted); }
.btn-ghost { background: transparent; color: var(--text-link); padding-left: 10px; padding-right: 10px; }
.btn-ghost:hover { background: var(--color-primary-a10); }
.btn-danger { background: var(--bg-surface); color: var(--color-danger-text); border-color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-light); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.45; box-shadow: none; cursor: not-allowed; }

/* ── Badges, chips, signals ── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 0; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; line-height: 1.4; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--color-success-light); color: var(--color-success-text); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning-text); }
.badge-danger  { background: var(--color-danger-light);  color: var(--color-danger-text); }
.badge-info    { background: var(--color-info-light);    color: var(--color-info-text); }
.badge-brand   { background: var(--color-primary-a10);   color: var(--color-primary); }
.badge-neutral { background: var(--bg-muted);            color: var(--text-secondary); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--bg-muted); border: 1px solid var(--border); font-size: var(--text-xs); font-weight: 500; color: var(--text-primary); }
.chip button { border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
button.chip { cursor: pointer; font: inherit; font-size: var(--text-xs); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sig { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.sig svg { width: 14px; height: 14px; flex: none; }
.sig-fast  { background: var(--sig-fast-soft);  color: var(--sig-fast-ink); }
.sig-exact { background: var(--sig-exact-soft); color: var(--sig-exact-ink); }
.sig-found { background: var(--sig-found-soft); color: var(--sig-found-ink); }
.kbd { font: 600 11px/1 var(--font-mono); padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-muted); color: var(--text-secondary); }

/* ── Tabs: pills; the selected one inverted ── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary);
  border-radius: 999px; padding: 7px 14px; font: 500 13px/1.2 var(--font-sans); cursor: pointer; white-space: nowrap;
}
.tab:hover { border-color: var(--border-strong); color: var(--text-primary); text-decoration: none; }
.tab[aria-selected="true"], .tab[aria-current="page"], .tab[aria-current="true"] { background: var(--text-primary); color: var(--bg-surface); border-color: var(--text-primary); font-weight: 600; }
.tab-panel[hidden] { display: none; }

/* Segmented control: a sunken pill track, the chosen option raised */
.segmented { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--bg-sunken); }
.segmented button { border: 0; background: none; padding: 6px 13px; border-radius: 999px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--bg-surface); color: var(--text-primary); box-shadow: 0 1px 3px rgba(20, 23, 41, 0.14); }

/* ── Forms ── */
.fields { display: flex; flex-direction: column; gap: 20px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field label, .field .label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: 6px; color: var(--text-primary); }
.field .help { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: var(--text-sm);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-a20); }
.textarea { min-height: 140px; resize: vertical; font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.6; }
.input-pill { height: 40px; border-radius: 999px; padding-left: 16px; }
.search-input { position: relative; flex: 1; min-width: 220px; }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.search-input .input { padding-left: 36px; }

.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.switch-row .t { font-size: var(--text-sm); font-weight: 600; }
.switch-row .d { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.switch { display: inline-block; position: relative; width: 40px; height: 22px; flex: none; margin-top: 2px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: background 0.15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.switch input:checked + span { background: var(--color-gradient); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.switch input:disabled + span { opacity: 0.5; }

/* Choice cards (radio as a card) */
.choice-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.choice { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1.5px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-surface); cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice:has(input:checked) { border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-a10); }
.choice:has(input:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.choice b { display: block; font-size: var(--text-sm); }
.choice small { display: block; color: var(--text-muted); font-size: var(--text-xs); }
.choice .thumb { display: block; height: 74px; border-radius: 10px; background: var(--bg-muted); border: 1px solid var(--border); }

/* (i) help next to a setting's name: hover, focus or tap shows a dark bubble */
.tip { position: relative; display: inline-flex; vertical-align: -3px; margin-left: 6px; cursor: help; outline: none; }
.tip-i { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--text-muted); color: var(--text-muted); background: var(--bg-surface); font: italic 700 10px/1 Georgia, 'Times New Roman', serif; }
.tip:hover .tip-i, .tip:focus-visible .tip-i, .tip.is-open .tip-i { border-color: var(--color-primary); color: #fff; background: var(--color-primary); }
.tip-text { display: none; position: absolute; left: -10px; top: calc(100% + 9px); z-index: 60; width: max-content; max-width: min(320px, 78vw); padding: 9px 11px; border-radius: 10px; background: var(--text-primary); color: var(--bg-surface); box-shadow: var(--shadow-lg); font: 400 13px/1.45 var(--font-sans); white-space: normal; }
.tip:hover .tip-text, .tip:focus .tip-text, .tip.is-open .tip-text { display: block; }

/* ── Alerts ── */
.alert { display: flex; gap: 12px; margin: 0; padding: 14px 16px; border: 0; border-radius: var(--radius-lg); font-size: var(--text-sm); }
.alert b { display: block; }
.alert-info    { background: var(--color-info-light);    color: var(--color-info-text); }
.alert-success { background: var(--color-success-light); color: var(--color-success-text); }
.alert-warning { background: var(--color-warning-light); color: var(--color-warning-text); }
.alert-danger  { background: var(--color-danger-light);  color: var(--color-danger-text); }

/* ── Tables ── */
.table-wrap { position: relative; overflow-x: auto; }   /* positioned: what is inside scrolls here, never the page */
.table { width: 100%; margin: 0; border: 0; border-collapse: collapse; background: transparent; color: inherit; font-size: var(--text-sm); }
.table th { text-align: left; font-size: 10.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.09em; padding: 0 0 10px; border: 0; border-bottom: 1px solid var(--border); background: none; }
.table td { padding: 11px 0; border: 0; border-bottom: 1px solid var(--border); vertical-align: middle; background: none; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg-muted); }
.table .num { text-align: right; }
.minibar { height: 6px; border-radius: 99px; background: var(--bg-muted); overflow: hidden; }
.minibar span { display: block; height: 100%; background: var(--chart-bar); border-radius: inherit; }
.progress { height: 8px; border-radius: 99px; background: var(--bg-muted); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--color-gradient); }

/* ── Charts (inline SVG): one bar colour; a second series is a line in --chart-line, never a second axis ── */
.chart { display: block; width: 100%; height: 220px; }
.chart .bar { fill: var(--chart-bar); }
.chart .bar.muted { fill: var(--chart-bar-muted); }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2; }
.chart text { fill: var(--chart-ink, var(--text-muted)); font: 500 11px var(--font-sans); }
.chart-legend { display: flex; gap: 16px; font-size: var(--text-xs); color: var(--text-muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ── Unsaved changes: a dark pill floating over the page ── */
.save-bar {
  position: fixed; z-index: 30; left: calc(var(--rail-width) + (100% - var(--rail-width)) / 2); transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px)); width: max-content; max-width: calc(100% - var(--rail-width) - 32px);
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; border-radius: 999px;
  background: var(--rail); color: var(--rail-ink); box-shadow: var(--shadow-lg);
}
.save-bar .msg { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.save-bar .msg::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--color-warning); }
.save-bar .btn-secondary { background: transparent; color: var(--rail-strong); border-color: var(--rail-3); }
.save-bar .btn-ghost { color: var(--rail-ink-2); }

/* "Saved — live" moment */
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 95; display: flex; align-items: center; gap: 12px; max-width: min(460px, calc(100vw - 48px));
  padding: 12px 16px 12px 12px; border-radius: 14px; background: var(--night-deep); color: #fff; box-shadow: var(--shadow-lg);
  transform: translateY(16px); opacity: 0; transition: transform 220ms var(--ease-fast), opacity 220ms; }
.toast.show { transform: none; opacity: 1; }
.toast .bolt { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--sig-fast); color: #1f1300; flex: none; }
.toast small { display: block; color: var(--rail-ink); margin-top: 2px; }

/* ── Find anything palette (Ctrl K) ── */
.finder-scrim { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh;
  background: rgba(10, 9, 32, 0.45); backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity 140ms; }
.finder-scrim.open { opacity: 1; pointer-events: auto; }
.finder { width: min(640px, calc(100vw - 32px)); background: var(--bg-surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in srgb, var(--color-secondary) 18%, transparent), 0 10px 40px color-mix(in srgb, var(--color-secondary) 18%, transparent); }
.finder-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.finder-in svg { width: 18px; height: 18px; color: var(--sig-found); flex: none; }
.finder-in input { flex: 1; height: 56px; border: 0; outline: 0; background: none; color: var(--text-primary); font: 500 17px/1 var(--font-sans); min-width: 0; }
.finder-list { max-height: 52vh; overflow: auto; padding: 8px; }
.finder-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.finder-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; cursor: pointer; color: var(--text-primary); }
.finder-item:hover, .finder-item.sel { background: color-mix(in srgb, var(--color-primary) 10%, transparent); text-decoration: none; }
.finder-item .where { margin-left: auto; font-size: var(--text-xs); color: var(--text-muted); }

/* ── Lists: filters, rows that open, key/value, action rows, pager ── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .select, .filters .input { width: auto; }
.table tr.clickable { cursor: pointer; }
.kv { display: flex; flex-direction: column; gap: 12px; margin: 0; font-size: var(--text-sm); }
.kv div { display: flex; justify-content: space-between; gap: 12px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.action-list { display: flex; flex-direction: column; }
.action { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.action:last-child { border-bottom: 0; }
.action .t { font-size: var(--text-sm); font-weight: 600; }
.action .d { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.action .end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding-top: 14px; font-size: var(--text-sm); color: var(--text-muted); }

/* ── Empty and loading states (UltraFrontend additions in the same language) ── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 24px; }
.empty .ic { width: 52px; height: 52px; border-radius: 16px; }
.empty .ic svg { width: 24px; height: 24px; }
.empty h3 { font-size: 16px; font-weight: 700; }
.empty p { max-width: 46ch; font-size: var(--text-sm); color: var(--text-secondary); }
.empty .btn { margin-top: 6px; }
.skeleton { display: block; height: 12px; border-radius: 8px; background: linear-gradient(90deg, var(--bg-muted) 0%, var(--bg-sunken) 50%, var(--bg-muted) 100%); background-size: 200% 100%; animation: ufs-skeleton 1.4s ease-in-out infinite; }
.skeleton.title { height: 20px; width: 40%; }
.skeleton.block { height: 120px; border-radius: var(--radius-lg); }
@keyframes ufs-skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--color-primary-a20); border-top-color: var(--color-primary); animation: ufs-spin 0.9s linear infinite; flex: none; }
@keyframes ufs-spin { to { transform: rotate(360deg); } }

/* ── Dialog: native <dialog>, a confirmation before anything that cannot be undone (UltraFrontend addition) ── */
dialog.dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-lg); }
dialog.dialog::backdrop { background: rgba(10, 9, 32, 0.45); backdrop-filter: blur(4px); }
.dialog-head { display: flex; gap: 14px; align-items: flex-start; padding: 22px 22px 0; }
.dialog-head h2 { font: 800 20px/1.2 var(--font-display); letter-spacing: -0.02em; margin-top: 6px; }
.dialog-body { padding: 10px 22px 4px 72px; color: var(--text-secondary); font-size: var(--text-sm); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 18px 22px 22px; }

/* ── Dropdown menu: <details class="dropdown"> (UltraFrontend addition) ── */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 210px; padding: 6px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: none; color: var(--text-primary); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-muted); text-decoration: none; }
.menu-item svg { width: 16px; height: 16px; color: var(--text-muted); flex: none; }
.menu-item.danger, .menu-item.danger svg { color: var(--color-danger-text); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ── Live steps: work that runs while the user watches (connect, import, index) ── */
.live-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.live-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); }
.live-steps li[data-state="doing"] { background: var(--bg-purple-tint); }
.live-steps li[data-state="error"] { background: var(--color-danger-light); }
.live-steps .ls-icon { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; margin-top: 1px; font-size: 13px; font-weight: 700; }
.live-steps li[data-state="waiting"] .ls-icon { border: 2px solid var(--border-strong); }
.live-steps li[data-state="doing"] .ls-icon { border: 3px solid var(--color-primary-a20); border-top-color: var(--color-primary); animation: ufs-spin 0.9s linear infinite; }
.live-steps li[data-state="done"] .ls-icon { background: var(--color-success); color: #fff; }
.live-steps li[data-state="error"] .ls-icon { background: var(--color-danger); color: #fff; }
.live-steps li[data-state="done"] .ls-icon::before { content: "✓"; }
.live-steps li[data-state="error"] .ls-icon::before { content: "!"; }
.live-steps .ls-t { font-size: var(--text-sm); font-weight: 600; }
.live-steps li[data-state="waiting"] .ls-t { color: var(--text-muted); }
.live-steps .ls-d { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.live-steps li[data-state="error"] .ls-d { color: var(--color-danger-text); }
.live-steps .ls-time { margin-left: auto; font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Sign in / sign up: the brand on a night panel, the form on white ── */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 40px; padding: 48px 56px; background: var(--night-gradient); color: #fff; }
.auth-brand::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, var(--night-orb), transparent 70%); pointer-events: none; }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .brand { color: #fff; padding: 0; }
.auth-brand h2 { color: #fff; font: 800 30px/1.15 var(--font-display); letter-spacing: -0.02em; max-width: 460px; }
.auth-brand h2 em { font-style: normal; color: color-mix(in srgb, var(--color-secondary) 45%, white); }
.auth-brand ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-brand li { display: flex; gap: 12px; align-items: flex-start; color: rgba(255, 255, 255, 0.8); font-size: var(--text-sm); }
.auth-brand li b { color: #fff; display: block; font-size: var(--text-base); }
.auth-brand .tick { width: 24px; height: 24px; border-radius: 50%; background: rgba(16, 185, 129, 0.2); color: #6EE7B7; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 700; }
.auth-brand .quote { margin-top: auto; padding: 20px; border-radius: var(--radius-lg); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); font-size: var(--text-sm); color: rgba(255, 255, 255, 0.85); }
.auth-brand .quote b { display: block; margin-top: 10px; color: #fff; font-size: var(--text-xs); }
.auth-main { display: flex; flex-direction: column; justify-content: center; padding: 48px 24px; background: var(--bg-surface); }
.auth-form { width: 100%; max-width: 400px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.auth-form h1 { font: 800 26px/1.15 var(--font-display); letter-spacing: -0.02em; }
.auth-form .lede { color: var(--text-secondary); font-size: var(--text-sm); margin-top: -8px; }
.auth-form .btn-primary { width: 100%; padding: 12px 16px; font-size: 14.5px; }
.auth-form .foot { text-align: center; font-size: var(--text-sm); color: var(--text-muted); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: var(--text-sm); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--text-sm); color: var(--text-secondary); }
.check input { margin-top: 3px; accent-color: var(--color-primary); width: 16px; height: 16px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: var(--text-xs); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.theme-float { position: fixed; top: 16px; right: 16px; z-index: 10; }

/* ── Setup wizard: a top bar, a stepper, one card per step ── */
.wizard { min-height: 100vh; background: var(--bg-page); }
.wizard-top { display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: var(--rail); }
.wizard-top .brand { padding: 0; }
.wizard-top .spacer { flex: 1; }
.wizard-top .btn-ghost { color: var(--rail-ink); }
.wizard-body { width: 100%; max-width: 780px; margin: 0 auto; padding: 36px 24px 80px; display: flex; flex-direction: column; gap: 24px; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.stepper li { display: flex; flex-direction: column; gap: 8px; font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; }
.stepper li::before { content: ""; height: 4px; border-radius: 99px; background: var(--border); }
.stepper li.done::before, .stepper li.current::before { background: var(--color-gradient); }
.stepper li.current { color: var(--color-primary); }
.stepper li.done { color: var(--text-secondary); }
.step-card { padding: 30px 32px; }
.step-card h1 { font: 800 26px/1.15 var(--font-display); letter-spacing: -0.02em; }
.step-card .lede { color: var(--text-secondary); margin-top: 8px; }
.howto { list-style: none; counter-reset: h; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.howto li { counter-increment: h; display: flex; gap: 14px; font-size: var(--text-sm); color: var(--text-secondary); }
.howto li::before { content: counter(h); width: 26px; height: 26px; border-radius: 50%; background: var(--bg-purple-tint); color: var(--color-primary); font-weight: 700; display: grid; place-items: center; flex: none; font-size: var(--text-xs); }
.howto b { color: var(--text-primary); }
.waiting { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius-lg); border: 1px dashed var(--border-strong); background: var(--bg-muted); font-size: var(--text-sm); }
.big-progress { height: 12px; border-radius: 99px; background: var(--bg-muted); overflow: hidden; }
.big-progress span { display: block; height: 100%; background: var(--color-gradient); border-radius: inherit; transition: width 0.3s ease; }
.big-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-purple-tint); color: var(--color-primary); }
.big-icon svg { width: 30px; height: 30px; }
.done-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.done-hero .big-icon { width: 80px; height: 80px; background: var(--color-success-light); color: var(--color-success-text); }
.wizard-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.keybox { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-muted); font-family: var(--font-mono); font-size: var(--text-sm); }
.keybox code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Plans ── */
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.plan { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.plan.featured { border: 2px solid var(--color-primary); box-shadow: 0 10px 30px var(--color-primary-a10); }
.plan .ribbon { position: absolute; top: -12px; left: 24px; }
.plan .price { font: 800 30px/1.1 var(--font-sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); }
.plan ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: var(--text-sm); color: var(--text-secondary); }
.plan li::before { content: "✓"; color: var(--color-success); font-weight: 700; margin-right: 8px; }
.plan .btn { margin-top: auto; }

/* ── Error pages (404, 500, no access) ── */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg-page); }
.error-card { width: min(520px, 100%); text-align: center; padding: 36px 32px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.error-code { font: 800 64px/1 var(--font-display); letter-spacing: -0.04em; color: var(--color-primary); }
.error-card h1 { font: 800 24px/1.2 var(--font-display); letter-spacing: -0.02em; }
.error-card p { color: var(--text-secondary); max-width: 44ch; }
.error-card .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ── Phones and small tablets ── */
@media (max-width: 1280px) {
  .row3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { padding: 28px 20px; gap: 20px; }
  .auth-brand h2 { font-size: 22px; }
  .auth-brand ul, .auth-brand .quote { display: none; }
  .plans { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 276px; z-index: 40; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: var(--rail); color: var(--rail-strong); }
  .topbar .brand { font-size: 15px; padding: 0; }
  .topbar .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .menu-btn, .topbar .finder-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 10px; border: 1px solid var(--rail-3); background: transparent; color: var(--rail-strong); cursor: pointer; }
  .menu-btn svg, .topbar .finder-btn svg { width: 20px; height: 20px; }
  .topbar .finder-btn { margin-left: auto; }
  .content { padding: 12px 16px 110px; }
  .phead-top { padding: 20px 18px 18px; }
  .phead-bar { padding: 12px 18px; }
  .phead h1 { font-size: 26px; }
  .input.phead-find { width: 100%; margin-left: 0; }
  .night { padding: 20px 18px 16px; }
  .night-num { font-size: 44px; }
  .row3, .field-row { grid-template-columns: minmax(0, 1fr); }
  .card-pad, .card-body, .card-head { padding-left: 16px; padding-right: 16px; }
  .save-bar { left: 16px; right: 16px; transform: none; width: auto; max-width: none; border-radius: 18px; flex-wrap: wrap; }
  .fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 48px; height: 48px; }
}
@media (max-width: 640px) {
  .wizard-top { padding: 12px 16px; }
  .wizard-body { padding: 24px 16px 60px; }
  .step-card { padding: 20px; }
  .stepper li { font-size: 10px; }
  .dialog-body { padding-left: 22px; }
  .action { flex-wrap: wrap; }
  .action .end { margin-left: 0; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 14px; }
  .kpi-v { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
