/* ValorAi Dashboard: the design system (docs/product-package.md, section 7), ported from the approved prototype.
   Order: tokens, base, layout, components, login pages, motion.
   No literal colors outside the token blocks. */

/* ---------- 1. Tokens ---------- */

:root {
  /* Colors: light is the default. */
  --canvas: #F4F6F9;
  --panel: #FFFFFF;
  --line: #E3E8EF;
  --ink: #0E1B2C;
  --text-2: #46566C;
  --text-3: #5A6A80;
  --ice-bg: #E6F1FC;
  --ice-ink: #1D5FA6;
  --accent: #D62B21;
  --accent-hover: #C4271D;
  --ok: #1B784A;
  --ok-bg: #E5F4EC;
  --warn: #8A5A00;
  --warn-bg: #FFF4DB;
  --new-bg: #FDECEA;
  --muted-bg: #EEF1F5;
  --active-pill: #E9EDF2;
  /* Extra tokens the table does not cover. */
  --on-accent: #FFFFFF;
  --accent-ink: #B3231A;
  --field-line: #7C8CA3;
  --qr-bg: #FFFFFF;
  --scrim: rgba(14, 27, 44, .42);
  --shadow-pop: 0 12px 32px rgba(14, 27, 44, .14), 0 2px 6px rgba(14, 27, 44, .06);
  --shadow-sheet: -12px 0 40px rgba(14, 27, 44, .16);
  color-scheme: light;

  /* Type */
  --font-display: 'Archivo', 'Helvetica Neue', Arial, system-ui, sans-serif;
  --font-text: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  /* Spacing steps of 4 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Shape */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-pill: 999px;

  /* Layout */
  --side-w: 220px;
  --side-w-collapsed: 64px;
  --bar-h: 56px;

  /* Motion */
  --t-press: 100ms;
  --t-small: 150ms;
  --t-sheet: 220ms;
  --ease: ease-out;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #091421;
    --panel: #101C2B;
    --line: #1E2C44;
    --ink: #ECF1F8;
    --text-2: #9BAAC0;
    --text-3: #8394AD;
    --ice-bg: rgba(168, 212, 255, .12);
    --ice-ink: #A8D4FF;
    --accent: #D62B21;
    --accent-hover: #C4271D;
    --ok: #4CC38A;
    --ok-bg: rgba(76, 195, 138, .14);
    --warn: #F2C14E;
    --warn-bg: rgba(242, 193, 78, .14);
    --new-bg: rgba(236, 59, 47, .16);
    --muted-bg: rgba(155, 170, 192, .12);
    --active-pill: rgba(168, 212, 255, .10);
    --on-accent: #FFFFFF;
    --accent-ink: #FF7A6E;
    --field-line: #5F7396;
    --qr-bg: #FFFFFF;
    --scrim: rgba(2, 8, 16, .62);
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
    --shadow-sheet: -12px 0 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --canvas: #091421;
  --panel: #101C2B;
  --line: #1E2C44;
  --ink: #ECF1F8;
  --text-2: #9BAAC0;
  --text-3: #8394AD;
  --ice-bg: rgba(168, 212, 255, .12);
  --ice-ink: #A8D4FF;
  --accent: #D62B21;
  --accent-hover: #C4271D;
  --ok: #4CC38A;
  --ok-bg: rgba(76, 195, 138, .14);
  --warn: #F2C14E;
  --warn-bg: rgba(242, 193, 78, .14);
  --new-bg: rgba(236, 59, 47, .16);
  --muted-bg: rgba(155, 170, 192, .12);
  --active-pill: rgba(168, 212, 255, .10);
  --on-accent: #FFFFFF;
  --accent-ink: #FF7A6E;
  --field-line: #5F7396;
  --qr-bg: #FFFFFF;
  --scrim: rgba(2, 8, 16, .62);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-sheet: -12px 0 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

[hidden] { display: none !important; }

.app-root {
  --fs-body: 15px;
  --lh-body: 22px;
  --fs-small: 13px;
  --lh-small: 18px;
  --fs-time: 20px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font: 400 var(--fs-body)/var(--lh-body) var(--font-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Counter mode: everything one step larger. */
.app-root.is-counter {
  --fs-body: 17px;
  --lh-body: 26px;
  --fs-small: 14px;
  --lh-small: 20px;
  --fs-time: 22px;
}

.app-root.has-bar { --bar-clear: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px)); }
.app-root { --bar-clear: 0px; }

/* :where() keeps these resets at zero extra specificity, so every component rule below wins over them. */
:where(.app-root) :is(h1, h2, h3, p) { margin: 0; }
:where(.app-root) :is(button, input, select, textarea) { font: inherit; color: inherit; }
:where(.app-root) a { color: var(--ice-ink); }
:where(.app-root) :is(img, svg) { max-width: 100%; }

:focus-visible { outline: 2px solid var(--ice-ink); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

/* Type helpers */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-small); line-height: var(--lh-small); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.strike { text-decoration: line-through; color: var(--text-3); }

.eyebrow {
  font: 500 11px/16px var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.wanted {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: var(--fs-time);
  line-height: 1.2;
  letter-spacing: -.01em;
}

.signal-dot {
  display: inline-block;
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 700 22px/1 var(--font-display);
  font-stretch: 118%;
  letter-spacing: -.01em;
  color: var(--ink);
}
.wordmark .signal-dot { width: 9px; height: 9px; margin-top: 3px; }

/* Layout helpers */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-6); min-width: 0; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); min-width: 0; }
.grow { flex: 1 1 0; min-width: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
.hide-phone { }
.show-phone { display: none !important; }

@media (min-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr) 360px; }
}

/* ---------- 3. App shell ---------- */

.shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.side {
  flex: none;
  position: sticky;
  top: 0;
  z-index: 10;
  width: var(--side-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) var(--sp-2) 64px;
  border-right: 1px solid var(--line);
  background: var(--canvas);
  overflow-x: hidden;
  overflow-y: auto;
  transition: width var(--t-small) var(--ease);
}

.side-head { display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: var(--sp-4); }

.biz {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  font: 600 16px/22px var(--font-display);
  font-stretch: 118%;
}
.biz-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.scope-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-press) var(--ease);
}
.scope-btn:hover { background: var(--muted-bg); }
.scope-text { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.scope-btn.is-brand .scope-text { font: 600 15px/20px var(--font-display); font-stretch: 118%; }
.scope-chev { color: var(--text-3); }

.side-nav { display: flex; flex-direction: column; gap: var(--sp-4); flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px; margin: -2px; }
/* The menu list scrolls on short screens, so "Collapse" always stays in reach. */
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px var(--sp-1); }
.nav-sep { height: 1px; margin: var(--sp-2) 10px; background: var(--line); }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-press) var(--ease), color var(--t-press) var(--ease);
}
.app-root a.nav-item { color: var(--text-2); }
.nav-item:hover, .app-root a.nav-item:hover { background: var(--muted-bg); color: var(--ink); }
.nav-item[aria-current="page"], .app-root a.nav-item[aria-current="page"] { background: var(--active-pill); color: var(--ink); }
.nav-item[aria-current="page"] .icon { color: var(--ice-ink); }
.nav-text { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-badge {
  flex: none;
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--ice-bg);
  color: var(--ice-ink);
  font: 500 11px/20px var(--font-mono);
  text-align: center;
}
/* Red is kept for new requests only, so it keeps meaning "act now". */
.nav-badge[data-badge="c1"] { background: var(--accent); color: var(--on-accent); }

.side-foot { margin-top: auto; padding-top: var(--sp-3); }
.nav-collapse .icon { transition: transform var(--t-small) var(--ease); }

/* Collapsed side menu: 64 px, icons only. */
.shell.is-collapsed .side { width: var(--side-w-collapsed); padding-left: var(--sp-2); padding-right: var(--sp-2); }
.shell.is-collapsed .nav-label { display: none; }
.shell.is-collapsed .nav-group + .nav-group { padding-top: var(--sp-2); border-top: 1px solid var(--line); }
.shell.is-collapsed .nav-item { justify-content: center; padding: 0; min-height: 44px; }
.shell.is-collapsed .nav-text, .shell.is-collapsed .scope-text, .shell.is-collapsed .scope-chev, .shell.is-collapsed .biz-name {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.shell.is-collapsed .scope-btn { justify-content: center; padding: 6px; }
.shell.is-collapsed .biz { justify-content: center; padding: 0; }
.shell.is-collapsed .nav-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
.shell.is-collapsed .nav-collapse .icon { transform: rotate(180deg); }

.main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.main-top { position: sticky; top: 0; z-index: 25; }
.mobile-head { display: none; }

.screen {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-6) var(--sp-12);
  min-width: 0;
}
@media (min-width: 1100px) {
  .screen { padding: var(--sp-8) var(--sp-8) var(--sp-12); }
}

#screen:focus, #screen:focus-visible { outline: none; }
.screen-view { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.screen-view > .page-head, .screen-view > .topbar { margin-bottom: 0; }

.bottombar { display: none; }

.bar-item {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--text-2);
  font: 500 11px/14px var(--font-text);
  text-decoration: none;
  cursor: pointer;
}
.app-root a.bar-item { color: var(--text-2); }
.bar-item[aria-current="page"], .app-root a.bar-item[aria-current="page"] { color: var(--ice-ink); }
.bar-item .nav-badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }

/* Phone: bottom bar, no side menu. */
@media (max-width: 699px) {
  .side { display: none; }
  .main-top { background: var(--canvas); }
  .mobile-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    border-bottom: 1px solid var(--line);
  }
  .mobile-head > * { flex: 1 1 0; min-width: 0; }
  .mobile-head .biz { padding: 0; }
  .mobile-head .scope-btn + .scope-btn { flex: 0 1 auto; max-width: 48%; }
  .bottombar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    height: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--panel);
    border-top: 1px solid var(--line);
  }
  .screen { padding: var(--sp-4) var(--sp-4) calc(var(--bar-clear) + 72px); }
  .hide-phone { display: none !important; }
  .show-phone { display: revert !important; }
}

/* Page header */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-6);
}
.page-title {
  font: 600 28px/34px var(--font-display);
  font-stretch: 118%;
  letter-spacing: -.01em;
  min-width: 0;
  overflow-wrap: anywhere;
}
.page-sub { margin-top: var(--sp-1); color: var(--text-2); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
@media (max-width: 699px) {
  .page-title { font-size: 22px; line-height: 28px; }
  .page-head { margin-bottom: var(--sp-4); }
}

/* ---------- 4. Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink);
  font: 600 var(--fs-body)/20px var(--font-text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t-press) var(--ease), border-color var(--t-press) var(--ease), transform var(--t-press) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.app-root a.btn-primary { color: var(--on-accent); }

.btn-secondary { background: var(--panel); border-color: var(--field-line); color: var(--ink); }
.btn-secondary:hover { background: var(--muted-bg); }

.btn-quiet { color: var(--text-2); padding: 0 var(--sp-3); }
.btn-quiet:hover { background: var(--muted-bg); color: var(--ink); }
.btn-quiet[aria-pressed="true"] { background: var(--ice-bg); color: var(--ice-ink); }

.btn-danger { background: var(--panel); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger:hover { background: var(--new-bg); }

.btn-icon { width: 40px; padding: 0; flex: none; }
.btn-block { width: 100%; }

.btn.is-busy { position: relative; color: transparent; pointer-events: none; }
.btn.is-busy::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--on-accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.btn-secondary.is-busy::after, .btn-quiet.is-busy::after, .btn-danger.is-busy::after { border-color: var(--text-2); border-right-color: transparent; }
.btn.is-busy .icon { visibility: hidden; }

@media (pointer: coarse), (max-width: 699px) {
  .btn, .nav-item { min-height: 44px; }
  .btn-icon { width: 44px; }
}

/* ---------- 5. Form controls ---------- */

.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field-label { font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 500; color: var(--ink); }
.hint { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--text-3); }
.error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
  color: var(--accent-ink);
}

.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px var(--sp-3);
  border: 1px solid var(--field-line);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: 22px;
  transition: border-color var(--t-press) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--ice-ink); outline-offset: 2px; border-color: var(--ice-ink); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--accent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--muted-bg); color: var(--text-3); cursor: not-allowed; }
.textarea { min-height: 96px; resize: vertical; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
@media (max-width: 699px) {
  .input, .select, .textarea { font-size: 16px; min-height: 44px; }
}

.check {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 44px;
  cursor: pointer;
}
.check input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  display: grid;
  place-content: center;
  width: 20px; height: 20px;
  margin: 0;
  border: 1.5px solid var(--field-line);
  border-radius: var(--r-xs);
  background: var(--panel);
  cursor: pointer;
  transition: background var(--t-press) var(--ease), border-color var(--t-press) var(--ease);
}
.check input::after {
  content: '';
  width: 10px; height: 5px;
  margin-top: -2px;
  border-left: 2px solid var(--panel);
  border-bottom: 2px solid var(--panel);
  transform: rotate(-45deg) scale(0);
  transition: transform var(--t-press) var(--ease);
}
.check input:checked { background: var(--ice-ink); border-color: var(--ice-ink); }
.check input:checked::after { transform: rotate(-45deg) scale(1); }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]::after { display: none; }
.check input[type="radio"]:checked { background: var(--ice-ink); box-shadow: inset 0 0 0 3.5px var(--panel); }
.check input:disabled { opacity: .5; cursor: not-allowed; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 44px;
  cursor: pointer;
}
.switch input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 44px; height: 24px;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--field-line);
  cursor: pointer;
  transition: background var(--t-small) var(--ease);
}
.switch input::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--panel);
  transition: transform var(--t-small) var(--ease);
}
.switch input:checked { background: var(--ice-ink); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--muted-bg);
}
.seg-btn {
  min-height: 34px;
  padding: 0 var(--sp-4);
  border: 0;
  border-radius: var(--r-xs);
  background: none;
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-press) var(--ease), color var(--t-press) var(--ease);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-checked="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
@media (pointer: coarse), (max-width: 699px) { .seg-btn { min-height: 38px; } }

.tabs {
  display: flex;
  gap: var(--sp-1);
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-press) var(--ease), color var(--t-press) var(--ease);
}
.tab:hover { color: var(--ink); background: var(--muted-bg); }
.tab[aria-selected="true"] { background: var(--active-pill); color: var(--ink); }
.tab-count {
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--muted-bg);
  color: var(--text-2);
  font: 500 12px/18px var(--font-mono);
}
.tab[aria-selected="true"] .tab-count { background: var(--panel); }
@media (pointer: coarse), (max-width: 699px) { .tab { min-height: 44px; } }

/* ---------- 6. Cards, lists, tables ---------- */

.card {
  min-width: 0;
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.card-title { font: 600 17px/24px var(--font-display); font-stretch: 118%; letter-spacing: -.005em; }
.card-body { padding: var(--sp-5); }
@media (max-width: 699px) {
  .card { padding: var(--sp-4); }
  .card-head { padding: var(--sp-3) var(--sp-4); }
  .card-body { padding: var(--sp-4); }
}

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 56px;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  transition: background var(--t-press) var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row.is-click { cursor: pointer; }
.list-row.is-click:hover { background: var(--muted-bg); }
.row-time { flex: none; min-width: 64px; }
.row-main { flex: 1 1 0; min-width: 0; }
.row-title { font-weight: 500; overflow-wrap: anywhere; }
.row-sub { color: var(--text-2); font-size: var(--fs-small); line-height: var(--lh-small); overflow-wrap: anywhere; }
.row-end { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2); }
@media (max-width: 699px) {
  .list-row { padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); flex-wrap: wrap; }
  .row-end { flex: 1 1 100%; justify-content: flex-start; }
}

.tbl-wrap {
  max-width: 100%;
  max-height: min(72vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font: 500 11px/16px var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: left;
  white-space: nowrap;
}
.tbl td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
/* Computers: tables grow with the page (no box that scrolls inside the page); the header sticks to the top of the window. */
@media (min-width: 1100px) {
  .tbl-wrap { max-height: none; overflow: visible; }
  .tbl thead th:first-child { border-top-left-radius: var(--r-md); }
  .tbl thead th:last-child { border-top-right-radius: var(--r-md); }
}
.tbl th.num, .tbl td.num { text-align: right; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--muted-bg); }
.tbl tr.is-click { cursor: pointer; }
.tbl tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; background: var(--panel); }
.tbl th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tbl th button:focus-visible { outline: 2px solid var(--ice-ink); outline-offset: 2px; }

@media (max-width: 699px) {
  .tbl-cards { max-height: none; overflow: visible; border: 0; border-radius: 0; background: none; }
  .tbl-cards .tbl, .tbl-cards tbody, .tbl-cards tfoot, .tbl-cards tr, .tbl-cards td { display: block; }
  .tbl-cards thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl-cards tr {
    margin-bottom: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--panel);
  }
  .tbl-cards td, .tbl-cards tfoot td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: 6px 0;
    border: 0;
    text-align: right;
    background: none;
    min-width: 0;
  }
  .tbl-cards tbody tr:hover td { background: none; }
  .tbl-cards td::before {
    content: attr(data-label);
    flex: none;
    font: 500 11px/18px var(--font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
    text-align: left;
  }
  .tbl-cards td:not([data-label])::before { content: none; }
  .tbl-cards td.cell-main { display: block; padding-bottom: var(--sp-2); text-align: left; font-weight: 600; }
}

/* Numbers card */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.kpi {
  min-width: 0;
  margin: 0 -1px -1px 0;
  padding: var(--sp-5);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.kpi-value { font: 500 30px/36px var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; overflow-wrap: anywhere; }
.kpi-label { margin-top: 2px; color: var(--text-2); font-size: var(--fs-small); line-height: var(--lh-small); }
.kpi-hint { margin-top: var(--sp-1); color: var(--text-3); font-size: var(--fs-small); line-height: var(--lh-small); }
.kpi.is-warn .kpi-value { color: var(--warn); }
.kpi.is-bad .kpi-value { color: var(--accent-ink); }
.kpi.is-ok .kpi-value { color: var(--ok); }
@media (max-width: 699px) { .kpi { padding: var(--sp-4); } .kpi-value { font-size: 26px; line-height: 32px; } }

/* ---------- 7. Chips, tags, flags ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--muted-bg);
  color: var(--text-2);
  font: 500 12.5px/24px var(--font-text);
  white-space: nowrap;
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip-new { background: var(--new-bg); color: var(--ink); }
.chip-new .chip-dot { background: var(--accent); }
.chip-confirmed { background: var(--ice-bg); color: var(--ice-ink); }
.chip-done, .chip-called-back { background: var(--ok-bg); color: var(--ok); }
.chip-cancelled { background: var(--muted-bg); color: var(--text-3); text-decoration: line-through; }
.chip-sync { background: var(--warn-bg); color: var(--warn); }
.chip-lead { background: var(--muted-bg); color: var(--text-2); }
.chip-onboarding { background: var(--warn-bg); color: var(--warn); }
.chip-trial { background: var(--ice-bg); color: var(--ice-ink); }
.chip-live { background: var(--ok-bg); color: var(--ok); }
.chip-paused { background: var(--muted-bg); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line); }

.kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  background: var(--muted-bg);
  color: var(--text-2);
  font: 500 11px/16px var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--new-bg);
  color: var(--ink);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}
.flag .icon { width: 16px; height: 16px; color: var(--accent-ink); }
.flag strong { font-weight: 600; }
.flag-text { overflow-wrap: anywhere; }

/* ---------- 8. Progress ---------- */

.progress { display: block; }
.progress-track { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--muted-bg); }
.progress-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: var(--r-pill); background: var(--ice-ink); transition: width var(--t-sheet) var(--ease); }
.progress-warn .progress-fill { background: var(--warn); }
.progress-over .progress-fill { background: var(--accent); }
.progress-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text-3); }
.progress-mark.m80 { left: 80%; }
.progress-mark.m100 { left: 100%; margin-left: -2px; }
.progress-scale { position: relative; height: 18px; margin-top: var(--sp-2); font: 500 11px/16px var(--font-mono); color: var(--text-3); }
.progress-scale span { position: absolute; top: 0; transform: translateX(-50%); }
.progress-scale .s80 { left: 80%; }
.progress-scale .s100 { left: 100%; transform: translateX(-100%); }

/* ---------- 9. Live dot, top bar, offline bar, band ---------- */

.live { display: inline-flex; align-items: center; gap: var(--sp-2); font: 500 13px/20px var(--font-mono); color: var(--ok); white-space: nowrap; }
.live-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.live-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  animation: pulse 2.4s ease-out infinite;
}
.live.is-off { color: var(--text-3); }
.live.is-off .live-dot::after { display: none; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-6);
}
.topbar-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2); min-width: 0; }
.search { position: relative; display: block; flex: 1 1 200px; min-width: 0; max-width: 280px; }
.search .icon { position: absolute; left: 12px; top: 50%; margin-top: -10px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 38px; }
.topbar-day { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 40px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
@media (max-width: 699px) {
  .topbar { margin-bottom: var(--sp-4); }
  .topbar-end { flex: 1 1 100%; justify-content: flex-start; }
  .search { max-width: none; flex: 1 1 100%; order: -1; }
  .topbar-tools { display: none; }
}

.offline-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 500;
}

.viewas-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-4);
  margin-bottom: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--ice-bg);
  color: var(--ice-ink);
  font-weight: 500;
}
.viewas-band .btn { color: var(--ice-ink); }

/* ---------- 10. Empty state, skeleton ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  margin-bottom: var(--sp-2);
  border-radius: 50%;
  background: var(--muted-bg);
  color: var(--text-2);
}
.empty-icon .icon { width: 24px; height: 24px; }
.empty-title { font: 600 17px/24px var(--font-display); font-stretch: 118%; overflow-wrap: anywhere; }
.empty-text { max-width: 44ch; color: var(--text-2); }
.empty .btn { margin-top: var(--sp-3); }

.skel { display: flex; flex-direction: column; gap: var(--sp-3); }
.skel-row {
  height: 56px;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--muted-bg) 0%, var(--active-pill) 50%, var(--muted-bg) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

/* ---------- 11. Layers: sheets, dialogs, popovers, toasts ---------- */

.layer { position: fixed; inset: 0; z-index: 80; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--t-sheet) var(--ease); }
.layer.is-open .scrim { opacity: 1; }

.sheet {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  box-shadow: var(--shadow-sheet);
  transition: transform var(--t-sheet) var(--ease);
  outline: none;
}
.sheet-grip { display: none; flex: none; width: 36px; height: 4px; margin: var(--sp-2) auto 0; border-radius: var(--r-pill); background: var(--field-line); touch-action: none; }
.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.sheet-title { min-width: 0; font: 600 18px/24px var(--font-display); font-stretch: 118%; overflow-wrap: anywhere; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-5); }
.sheet-foot { flex: none; display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--panel); }

@media (min-width: 700px) {
  .sheet { top: 0; right: 0; bottom: 0; width: min(480px, 100%); border-radius: var(--r-md) 0 0 var(--r-md); transform: translateX(100%); }
  .sheet.sheet-wide { width: min(680px, 100%); }
  .layer.is-open .sheet { transform: none; }
}
@media (max-width: 699px) {
  .sheet {
    left: 0; right: 0; bottom: 0;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--r-md) var(--r-md) 0 0;
    transform: translateY(100%);
  }
  .layer.is-open .sheet { transform: none; }
  .sheet-grip { display: block; }
  .sheet-head { touch-action: none; padding-left: var(--sp-4); }
  .sheet-body { padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px)); }
  .sheet-foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

.layer-center { display: flex; align-items: center; justify-content: center; padding: var(--sp-4); z-index: 90; }
.dialog {
  position: relative;
  width: min(440px, 100%);
  padding: var(--sp-6);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t-sheet) var(--ease), transform var(--t-sheet) var(--ease);
  outline: none;
}
.layer.is-open .dialog { opacity: 1; transform: none; }
.dialog-title { font: 600 18px/24px var(--font-display); font-stretch: 118%; }
.dialog-text { margin-top: var(--sp-2); color: var(--text-2); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-6); }
@media (max-width: 699px) { .dialog-actions .btn { flex: 1 1 0; } }

.pop {
  position: fixed;
  z-index: 95;
  width: 300px;
  max-width: calc(100vw - 16px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-pop);
}
.pop-list { display: flex; flex-direction: column; max-height: min(320px, 50vh); overflow-y: auto; }
.pop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
  min-height: 44px;
  padding: 6px var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.pop-item:hover { background: var(--muted-bg); }
.pop-item[aria-current="true"] { background: var(--active-pill); }
.pop-main { display: flex; flex-direction: column; min-width: 0; }
.pop-main > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-sub { color: var(--text-3); font-size: var(--fs-small); line-height: var(--lh-small); }
.pop-empty { padding: var(--sp-3); color: var(--text-2); }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  width: 100%;
  min-height: 48px;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border: 1px solid var(--field-line);
  border-radius: var(--r-md);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: toast-in var(--t-small) var(--ease);
}
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--t-small) var(--ease), transform var(--t-small) var(--ease); }
.toast-text { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.toast-action { flex: none; color: var(--ice-ink); }
@media (max-width: 699px) {
  .toasts { bottom: calc(var(--bar-clear) + 68px); }
}

/* ---------- 13. The More sheet (phone) ---------- */

.more { display: flex; flex-direction: column; gap: var(--sp-1); }
.more-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 48px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.more-item[aria-current="true"], .more-item[aria-current="page"] { background: var(--active-pill); }
.more-item[aria-current="true"] .icon:last-child { color: var(--ice-ink); }
.app-root a.more-item { color: var(--ink); }
.more-item:hover { background: var(--muted-bg); }
.more-item .icon { color: var(--text-2); }
.more-item .nav-text { flex: 1 1 0; }
.more-sep { height: 1px; margin: var(--sp-2) 0; background: var(--line); }

/* ---------- 14. Login pages (C0, A0) ---------- */

.login {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-4) var(--sp-12);
  min-width: 0;
}
.login-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.login-top .select { width: auto; min-width: 132px; }
.login-card { padding: var(--sp-6); }
.login-title { font: 600 22px/28px var(--font-display); font-stretch: 118%; letter-spacing: -.01em; overflow-wrap: anywhere; }
.login-card .page-title { overflow-wrap: anywhere; }
.band { margin-bottom: 0; }

.code-boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp-2); }
.code-boxes { position: relative; }
.code-boxes.is-locked .code-box { opacity: .55; }
.code-boxes.is-locked::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid var(--ice-ink);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.code-box { padding-left: 0; padding-right: 0; min-height: 48px; text-align: center; font-family: var(--font-mono); font-size: 20px; }

.qr {
  display: block;
  width: 200px; height: 200px;
  max-width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--qr-bg);
}
.key { font: 500 14px/20px var(--font-mono); overflow-wrap: anywhere; word-break: break-all; }

@media (max-width: 479px) {
  .login { padding-top: var(--sp-6); }
  .login-card { padding: 0; border: 0; background: none; }
}
@media (max-width: 379px) {
  .code-boxes { gap: var(--sp-1); }
}

/* ---------- 15. Motion ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: .5; transform: scale(.6); } 70%, 100% { opacity: 0; transform: scale(1.4); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes fresh { from { background-color: var(--ice-bg); } to { background-color: transparent; } }
@keyframes fresh-static { from { box-shadow: inset 0 0 0 2px var(--ice-ink); } to { box-shadow: none; } }

/* A request that just arrived: slides in over 220 ms, highlight fades over 2 s. */
.slide-in { animation: slide-in var(--t-sheet) var(--ease); }
.is-fresh { animation: fresh 2s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .live-dot::after, .skel-row, .btn.is-busy::after, .slide-in, .toast { animation: none; }
  .is-fresh { animation: fresh-static 5s steps(1, end) forwards; }
  .btn.is-busy::after, .code-boxes.is-locked::after { animation: spin 1.6s linear infinite; }
}
