/* ============================================================
   RealityOS app design system v4 · Attio-style workspace
   Light sidebar, full-bleed white canvas, dense bordered tables,
   pastel status pills, one brand-blue accent, brand navy for the
   AI surfaces. Light and dark follow the system theme.
   Pages use these tokens and primitives only. Spec: /DESIGN.md
   ============================================================ */
:root {
  --primary: #1d62ee; --primary-hover: #1a56d6; --primary-soft: #edf3ff; --primary-ink: #1a56d6; --on-primary: #fff;
  --navy: #0b1b3a; --navy-2: #13254a; --navy-ink: #c9d3e8; --navy-accent: #8fb2ff;
  --bg: #ffffff; --bg-subtle: #f7f8fa; --bg-muted: #f1f2f5; --bg-hover: #f5f6f8; --bg-active: #eceef2;
  --sidebar: #fbfbfc; --overlay: rgba(11, 27, 58, .45);
  --text: #0b1b3a; --text-2: #4f596c; --text-3: #5f6779; --text-inverse: #ffffff;
  --border: #ebecf0; --border-strong: #dcdfe5; --grid: #f0f1f4;
  --shadow-sm: 0 1px 2px rgba(11, 27, 58, .05);
  --shadow-md: 0 1px 3px rgba(11, 27, 58, .06), 0 1px 2px rgba(11, 27, 58, .04);
  --shadow-lg: 0 16px 48px -12px rgba(11, 27, 58, .28), 0 0 0 1px rgba(11, 27, 58, .06);
  /* Pastel pills: bg / fg. Lead temperature colors are data, never chrome. */
  --hot-bg: #fdecec; --hot: #cb2d32; --hot-dot: #e5484d;
  --warm-bg: #fff4e0; --warm: #a16000; --warm-dot: #f59e0b;
  --cold-bg: #e3f7fb; --cold: #0a7891; --cold-dot: #06b6d4;
  --booked-bg: #f1ecff; --booked: #6b46d9; --booked-dot: #8b5cf6;
  --success-bg: #e5f6ee; --success: #0c7c55; --success-dot: #12a150;
  --danger-bg: #fdecec; --danger: #cb2d32;
  --neutral-bg: #f1f2f5; --neutral: #525c70;
  --blue-bg: #edf3ff; --blue: #1a56d6;
  --radius-xs: 4px; --radius-sm: 6px; --radius: 8px; --radius-lg: 12px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --font: 'Inter', -apple-system, system-ui, sans-serif; --font-display: 'Lexend', 'Inter', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
/* Dark tokens: theme.js sets data-theme on <html> from the user's choice (System, Light or Dark) */
:root[data-theme="dark"] {
  --primary: #2f6bef; --primary-hover: #4a80f5; --primary-soft: rgba(59, 123, 255, .14); --primary-ink: #8fb2ff;
  --navy: #13254a; --navy-2: #1b3160; --navy-ink: #c9d3e8;
  --bg: #0b0f17; --bg-subtle: #10151f; --bg-muted: #151b27; --bg-hover: #161c29; --bg-active: #1d2433;
  --sidebar: #0e131c; --overlay: rgba(0, 0, 0, .6);
  --text: #eef1f6; --text-2: #aeb7c7; --text-3: #8791a4; --text-inverse: #0b0f17;
  --border: #1e2533; --border-strong: #2a3345; --grid: #181e2a;
  --shadow-sm: none; --shadow-md: 0 0 0 1px rgba(255, 255, 255, .02);
  --shadow-lg: 0 20px 56px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .06);
  --hot-bg: rgba(229, 72, 77, .16); --hot: #ff8a8d;
  --warm-bg: rgba(245, 158, 11, .15); --warm: #f7b955;
  --cold-bg: rgba(6, 182, 212, .15); --cold: #5fd4e8;
  --booked-bg: rgba(139, 92, 246, .18); --booked: #b9a0ff;
  --success-bg: rgba(18, 161, 80, .16); --success: #5ad19a;
  --danger-bg: rgba(229, 72, 77, .16); --danger: #ff8a8d;
  --neutral-bg: #1b2130; --neutral: #a9b2c3;
  --blue-bg: rgba(59, 123, 255, .16); --blue: #8fb2ff;
  color-scheme: dark;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font); font-size: 13.5px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; letter-spacing: -0.003em; }
a { color: inherit; text-decoration: none; }
a, button, [role=button] { touch-action: manipulation; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
svg.lucide { flex-shrink: 0; }
::selection { background: rgba(31, 107, 255, .18); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.num, td, .kpi-value, .count { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 100; background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 8px; }

/* ── Shell ── */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar); border-right: 1px solid var(--border); padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 1px; overscroll-behavior: contain; }
.workspace { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: var(--radius-sm); margin-bottom: 6px; }
.workspace:hover { background: var(--bg-active); }
.org-logo { width: 24px; height: 24px; border-radius: var(--radius-sm); background: var(--navy); color: #fff; display: grid; place-items: center; font: 600 10px/1 var(--font); flex-shrink: 0; overflow: hidden; }
.org-info { min-width: 0; line-height: 1.25; }
.org-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-sub { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 8px 8px 12px; }
.brand img { width: 22px; height: 17px; }
.logo-text, .wordmark { font: 600 15px/1 var(--font-display); letter-spacing: -0.02em; color: var(--text); }
.logo-text span, .wordmark span { color: var(--primary); }
[data-theme="dark"] .brand img, [data-theme="dark"] .mark { filter: brightness(0) invert(1); }
.nav-section { font-size: 11.5px; font-weight: 500; color: var(--text-3); padding: 14px 8px 4px; }
.nav-item { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; cursor: pointer; transition: background-color .12s, color .12s; }
.nav-item svg { width: 16px; height: 16px; stroke-width: 1.8; }
.nav-item:hover { background: var(--bg-active); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--text); }
.nav-item.active svg { color: var(--primary); }
.nav-count { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding-top: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 40; height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); min-width: 0; white-space: nowrap; }
.crumbs b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs svg { width: 14px; height: 14px; }
.topbar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.search, .search-box { position: relative; width: min(360px, 100%); }
.search svg, .search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.search input, .search-box input { width: 100%; height: 32px; padding: 0 10px 0 32px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-subtle); outline: none; font-size: 13px; }
.search input:focus, .search-box input:focus { border-color: var(--primary); background: var(--bg); box-shadow: 0 0 0 3px var(--primary-soft); }
.user-menu { display: flex; align-items: center; gap: 8px; padding: 3px 6px 3px 3px; border-radius: var(--radius-sm); cursor: pointer; margin-left: 4px; }
.user-menu:hover { background: var(--bg-hover); }
.user-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 600; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-3); }
.content { padding: 24px 28px 64px; min-width: 0; }
.content.flush { padding: 0; }

/* ── Page header + view bar (Attio: title, then tabs/filters on one line) ── */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font: 600 22px/1.2 var(--font-display); letter-spacing: -0.025em; color: var(--text); }
.page-subtitle { color: var(--text-2); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.viewbar, .filters, .toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.viewbar .spacer, .filters .spacer, .toolbar .spacer { flex: 1; }

/* ── Buttons ── */
.btn, .btn-primary, .btn-ghost, .btn-danger { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color .12s, border-color .12s, transform .1s; box-shadow: var(--shadow-sm); }
.btn svg, .btn-primary svg, .btn-ghost svg, .btn-danger svg { width: 15px; height: 15px; }
.btn:hover, .btn-ghost:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-block { width: 100%; }
button:active:not(:disabled), .btn:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { position: relative; width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--text-2); cursor: pointer; transition: background-color .12s, color .12s; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--bg-active); color: var(--text); }
.icon-btn.bordered { border-color: var(--border); background: var(--bg); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--hot-dot); border: 1.5px solid var(--bg); }
.nav-toggle { display: none; }

/* Filter chips (Attio: bordered, compact, icon + label + chevron) */
.chip, .filter-btn, .date-range { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text-2); font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background-color .12s, border-color .12s, color .12s; }
.chip svg, .filter-btn svg, .date-range svg { width: 14px; height: 14px; }
.chip:hover, .filter-btn:hover, .date-range:hover { background: var(--bg-hover); color: var(--text); }
.chip.active, .filter-btn.active, .chip[aria-pressed=true] { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background: var(--primary-soft); color: var(--primary-ink); }

/* Tabs: underline (page level) and segmented (in-card) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs > * { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 0; background: none; color: var(--text-2); font-weight: 500; cursor: pointer; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; transition: color .12s, box-shadow .12s; }
.tabs > *:hover { color: var(--text); }
.tabs > .active { color: var(--text); box-shadow: inset 0 -2px 0 var(--primary); }
.tabs .count { font-size: 11.5px; color: var(--text-3); background: var(--bg-muted); border-radius: 10px; padding: 0 6px; }
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg-muted); border-radius: 7px; }
.seg > * { height: 26px; padding: 0 10px; border: 0; border-radius: 5px; background: none; color: var(--text-2); font-size: 12.5px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg svg { width: 14px; height: 14px; }
.seg > .active, .seg > [aria-pressed=true] { background: var(--bg); color: var(--text); box-shadow: var(--shadow-md); }

/* ── Pills, tags, avatars ── */
.pill, .tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--radius-xs); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); max-width: 100%; }
.pill svg, .tag svg { width: 12px; height: 12px; }
.pill .dot, .tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-hot, .tag-hot { background: var(--hot-bg); color: var(--hot); }
.pill-warm, .tag-warm { background: var(--warm-bg); color: var(--warm); }
.pill-cold, .tag-cold { background: var(--cold-bg); color: var(--cold); }
.pill-booked, .tag-booked { background: var(--booked-bg); color: var(--booked); }
.pill-success, .tag-success { background: var(--success-bg); color: var(--success); }
.pill-danger, .tag-danger { background: var(--danger-bg); color: var(--danger); }
.pill-blue, .tag-blue, .tag-project { background: var(--blue-bg); color: var(--blue); }
.pill-outline { background: none; border: 1px solid var(--border); color: var(--text-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0; font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--bg-active); }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.xl { width: 64px; height: 64px; font-size: 20px; }
.avatar.brand { background: var(--navy); color: #fff; }
.kbd { display: inline-flex; align-items: center; height: 18px; padding: 0 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--radius-xs); font: 500 11px/1 var(--font); color: var(--text-3); background: var(--bg); }

/* ── Surfaces ── */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 42px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.card-title svg { width: 15px; height: 15px; color: var(--text-3); }
.card-title .count { font-size: 12px; font-weight: 500; color: var(--text-3); }
.card-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.card-link:hover { color: var(--text); }
.card-link svg { width: 13px; height: 13px; }
.card-body { padding: 14px; }
.card-foot { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.grid { display: grid; gap: 16px; }
.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)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: grid; gap: 16px; align-content: start; }

/* KPI strip: one bordered row, hairline dividers */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.kpi { padding: 14px 16px; box-shadow: -1px 0 0 var(--border); min-width: 0; }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.kpi-label svg { width: 14px; height: 14px; color: var(--text-3); }
.kpi-row { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.kpi-value { font: 600 22px/1.1 var(--font-display); letter-spacing: -0.02em; }
.kpi-trend { font-size: 12px; font-weight: 500; }
.trend-up { color: var(--success); } .trend-down { color: var(--danger); } .trend-flat { color: var(--text-3); }

/* List rows */
.list > * { border-bottom: 1px solid var(--grid); }
.list > *:last-child { border-bottom: 0; }
.row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px; transition: background-color .12s; }
a.row:hover, .row.clickable:hover { background: var(--bg-hover); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

/* Tables (Attio grid: header strip, 1px vertical + horizontal grid) */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--bg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-2); background: var(--bg-subtle); height: 34px; padding: 0 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th svg { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; margin-right: 5px; color: var(--text-3); }
.table td { height: 42px; padding: 0 12px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.table th + th, .table td + td { box-shadow: inset 1px 0 0 var(--grid); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover td { background: var(--bg-hover); }
.table .right { text-align: right; }

/* Forms */
.field { display: grid; gap: 6px; }
.field label, .label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--text-3); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=range]), .field select, .field textarea, select.input, textarea.input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 13.5px; outline: none; transition: border-color .12s, box-shadow .12s; }
.field textarea, textarea.input { height: auto; min-height: 96px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select { background-color: var(--bg); color: var(--text); }
::placeholder { color: var(--text-3); opacity: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.switch { position: relative; width: 32px; height: 18px; border-radius: 10px; background: var(--border-strong); cursor: pointer; flex-shrink: 0; transition: background-color .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s var(--ease); }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(14px); }

/* AI surfaces: brand navy, reserved for Reality AI */
.ai-surface { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 16px 18px; }
.ai-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--navy-accent); }
.ai-tag svg { width: 14px; height: 14px; }
.ai-inline { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); background: var(--primary-soft); border-radius: var(--radius); font-size: 13px; }

/* Empty state */
.empty { display: grid; place-items: center; gap: 8px; padding: 40px 16px; text-align: center; color: var(--text-3); }
.empty svg { width: 22px; height: 22px; }
.empty b { color: var(--text); font-weight: 600; }

/* Kanban (Attio board: muted column, white cards, stage accent) */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(272px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kcol { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 4px; font-weight: 600; font-size: 13px; }
.kcol-head .count, .kcol-count { font-weight: 500; color: var(--text-3); font-size: 12px; }
.kcol-head .sum { margin-left: auto; font-weight: 500; color: var(--text-3); font-size: 12px; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.lcard { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow-sm); display: grid; gap: 8px; min-width: 0; transition: border-color .12s, box-shadow .12s; }
.lcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

/* Modal-ish side panel for records */
.drawer { position: fixed; inset: 0 0 0 auto; width: min(440px, 100%); background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 90; overflow-y: auto; overscroll-behavior: contain; }

/* Phone tab bar (shown under 900px) */
.tabbar { display: none; }

/* ── Motion: content settles in once ── */
@media (prefers-reduced-motion: no-preference) {
  .content > * { animation: ro-rise .35s var(--ease) both; }
  .content > *:nth-child(2) { animation-delay: .03s; } .content > *:nth-child(3) { animation-delay: .06s; } .content > *:nth-child(n+4) { animation-delay: .09s; }
  @keyframes ro-rise { from { opacity: 0; transform: translateY(4px); } }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ── Tablet and phone ── */
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .layout, .layout.ro-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 60; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .layout.ro-nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax var(--overlay); }
  .nav-toggle { display: inline-grid; }
  body { overflow-x: hidden; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar .search, .topbar .search-box, .user-menu > div:last-child { display: none; }
  .content { padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 20px; }
  .grid-2, .grid-3, .grid-4, .grid-main, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { box-shadow: none; } .kpi:nth-child(n+3) { border-top: 1px solid var(--border); }
  .kanban { grid-auto-columns: minmax(264px, 86vw); scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: start; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 4px 0; font-size: 10.5px; font-weight: 500; color: var(--text-3); }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a[aria-current=page] { color: var(--primary); }
}

/* ── Auth pages: sign in, platform admin, reset, signup (split layout) ── */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); background: var(--bg); }
.auth-main { display: flex; flex-direction: column; padding: 28px clamp(20px, 5vw, 64px); min-width: 0; }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-top .brand { padding: 0; }
.auth-top a.link { font-size: 13px; color: var(--text-2); }
.auth-body { flex: 1; display: grid; align-content: center; width: min(400px, 100%); margin: 32px auto; gap: 20px; }
.auth-body h1 { font: 600 26px/1.2 var(--font-display); letter-spacing: -0.025em; }
.auth-body .lead { color: var(--text-2); margin-top: -12px; }
.auth-form { display: grid; gap: 14px; }
.auth-form .btn-primary, .auth-form .btn { height: 38px; font-size: 14px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; }
.link { color: var(--primary-ink); font-weight: 500; }
.link:hover { text-decoration: underline; }
.auth-foot { font-size: 13px; color: var(--text-2); text-align: center; }
.auth-legal { font-size: 12px; color: var(--text-3); text-align: center; }
.form-alert { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; background: var(--danger-bg); color: var(--danger); }
.form-alert.info { background: var(--blue-bg); color: var(--blue); }
.form-alert.ok { background: var(--success-bg); color: var(--success); }
.form-alert svg { width: 16px; height: 16px; margin-top: 1px; }
.form-alert:empty { display: none; }
.field .error { font-size: 12px; color: var(--danger); }
.field input[aria-invalid=true] { border-color: var(--danger); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px !important; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.otp-input { letter-spacing: .5em; font: 600 20px/1 var(--mono) !important; text-align: center; height: 48px !important; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.meter-bar { height: 4px; border-radius: 2px; background: var(--bg-muted); overflow: hidden; }
.meter-bar span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s, background-color .2s; }
.demo-box { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 6px; }
.demo-box summary { cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.demo-list { display: grid; gap: 4px; margin-top: 6px; }
.demo-acct { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer; font-size: 12.5px; }
.demo-acct:hover { background: var(--bg-hover); }
.demo-acct span:last-child { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }
.steps { display: flex; gap: 6px; }
.steps span { flex: 1; height: 3px; border-radius: 2px; background: var(--bg-muted); }
.steps span.on { background: var(--primary); }
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.plan-opt { position: relative; display: grid; gap: 2px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 12.5px; }
.plan-opt input { position: absolute; opacity: 0; }
.plan-opt b { font-size: 13px; }
.plan-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.plan-opt:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.auth-side { position: relative; overflow: hidden; background: var(--navy); color: #fff; padding: clamp(28px, 5vw, 56px); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-side h2 { font: 600 clamp(24px, 2.6vw, 32px)/1.2 var(--font-display); letter-spacing: -0.025em; max-width: 18ch; }
.auth-side p { color: var(--navy-ink); max-width: 44ch; }
.auth-side ul { list-style: none; display: grid; gap: 10px; color: var(--navy-ink); font-size: 13.5px; }
.auth-side li { display: flex; gap: 10px; align-items: flex-start; }
.auth-side li svg { width: 16px; height: 16px; color: var(--navy-accent); margin-top: 2px; }
.auth-shot { border-radius: 10px; border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .6); width: 118%; max-width: none; height: auto; }
/* Platform admin: dark, single column */
.auth-admin { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: #070d1c; color: #eef1f6; color-scheme: dark;
  --bg: #0e1526; --bg-subtle: #121a2e; --bg-hover: #16203a; --bg-muted: #182237; --text: #eef1f6; --text-2: #b3bccd; --text-3: #8a94a8; --border: #1f2a44; --border-strong: #2c3a5c;
  --primary: #2f6bef; --primary-hover: #4a80f5; --primary-soft: rgba(47, 107, 239, .16); --primary-ink: #8fb2ff; --danger-bg: rgba(229, 72, 77, .16); --danger: #ff8a8d;
  --blue-bg: rgba(59, 123, 255, .16); --blue: #8fb2ff; --success-bg: rgba(18, 161, 80, .16); --success: #5ad19a; }
.admin-card { width: min(420px, 100%); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; display: grid; gap: 18px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8); }
.admin-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--primary-ink); }
.admin-badge svg { width: 16px; height: 16px; }
@media (max-width: 960px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-side { display: none; } }
@media (max-width: 420px) { .plan-grid { grid-template-columns: minmax(0, 1fr); } .admin-card { padding: 20px; } }
.link-btn { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; font-weight: 500; }

/* ── Data states (data.js): loading spinner, empty and error blocks ── */
.ro-state span { max-width: 44ch; }
.ro-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: ro-spin .8s linear infinite; }
@keyframes ro-spin { to { transform: rotate(360deg); } }
.ro-error { color: var(--text-2); }
.ro-error svg { color: var(--danger); }
.skeleton { background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-hover) 50%, var(--bg-muted) 75%); background-size: 200% 100%; border-radius: var(--radius-xs); color: transparent !important; animation: ro-shimmer 1.2s linear infinite; }
@keyframes ro-shimmer { to { background-position: -200% 0; } }
