/* ============================================================
   TrustPlot CRM app design system v5 · "Steep" editorial
   Serif headlines on white paper, near-monochrome ink/gray system,
   one warm peach accent (TrustPlot AI callouts and hot leads), pill
   buttons, 16–24px card radii, hairline borders, whisper-quiet
   navigation. Same class names and tokens as v4 so every page and
   script keeps working; only the values changed. Spec: /DESIGN.md
   ============================================================ */
:root {
  /* Ink is the only dark surface and the single "primary" action colour */
  --primary: #17191c; --primary-hover: #2c2f35; --primary-soft: #f2f2f3; --primary-ink: #17191c; --on-primary: #ffffff;
  /* AI surfaces: ink with a peach accent (kraft-paper pairing) */
  --navy: #17191c; --navy-2: #2c2f35; --navy-ink: #b9bcc4; --navy-accent: #fbe1d1;
  --peach: #fbe1d1; --sienna: #5d2a1a;
  --bg: #ffffff; --bg-subtle: #fafafb; --bg-muted: #f2f2f3; --bg-hover: #f6f6f7; --bg-active: #ececee;
  --sidebar: #fafafb; --overlay: rgba(23, 25, 28, .4);
  --text: #17191c; --text-2: #4d525c; --text-3: #777b86; --text-inverse: #ffffff;
  --border: #ececec; --border-strong: #d9dadd; --grid: #f2f2f3;
  --shadow-sm: 0 0 0 1px rgba(4, 23, 43, .05);
  --shadow-md: 0 0 0 1px rgba(4, 23, 43, .05), 0 4px 24px rgba(0, 0, 0, .06);
  --shadow-lg: 0 0 0 1px rgba(4, 23, 43, .05), 0 8px 40px rgba(0, 0, 0, .1);
  /* Status pills are data, never chrome. Achromatic except hot, which takes the peach accent. */
  --hot-bg: #fbe1d1; --hot: #5d2a1a; --hot-dot: #c2673f;
  --warm-bg: #f6eddc; --warm: #6b4a12; --warm-dot: #c99a3b;
  --cold-bg: #eef0f3; --cold: #4d525c; --cold-dot: #a3a6af;
  --booked-bg: #e4e5e8; --booked: #17191c; --booked-dot: #17191c;
  --success-bg: #e6efe9; --success: #2d5a3c; --success-dot: #3f7d55;
  --danger-bg: #f8e4e1; --danger: #8a2a22;
  --neutral-bg: #f2f2f3; --neutral: #4d525c;
  --blue-bg: #f2f2f3; --blue: #17191c;
  --radius-xs: 8px; --radius-sm: 12px; --radius: 16px; --radius-lg: 24px; --radius-pill: 9999px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --font: 'Inter', -apple-system, system-ui, sans-serif; --font-display: 'Source Serif 4', 'Signifier', Georgia, 'Times New Roman', 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).
   Same editorial restraint: ink canvas, paper text, peach accent. */
:root[data-theme="dark"] {
  --primary: #f2f2f3; --primary-hover: #ffffff; --primary-soft: #26282d; --primary-ink: #f2f2f3; --on-primary: #17191c;
  --navy: #26282d; --navy-2: #2f3238; --navy-ink: #c8cbd1; --navy-accent: #fbe1d1;
  --bg: #141517; --bg-subtle: #191b1e; --bg-muted: #1f2125; --bg-hover: #1c1e22; --bg-active: #26282d;
  --sidebar: #191b1e; --overlay: rgba(0, 0, 0, .6);
  --text: #f2f2f3; --text-2: #b5b8bf; --text-3: #8a8e97; --text-inverse: #ffffff;
  --border: #26282d; --border-strong: #34373d; --grid: #202226;
  --shadow-sm: 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-md: 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-lg: 0 20px 56px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .06);
  --hot-bg: rgba(251, 225, 209, .16); --hot: #f3c6ad; --hot-dot: #e0936a;
  --warm-bg: rgba(245, 200, 120, .14); --warm: #e6c37a; --warm-dot: #c99a3b;
  --cold-bg: rgba(163, 166, 175, .16); --cold: #c3c6cd; --cold-dot: #8a8e97;
  --booked-bg: rgba(242, 242, 243, .16); --booked: #f2f2f3; --booked-dot: #f2f2f3;
  --success-bg: rgba(63, 125, 85, .2); --success: #8fcfa4; --success-dot: #3f7d55;
  --danger-bg: rgba(200, 80, 70, .2); --danger: #f0a09a;
  --neutral-bg: #26282d; --neutral: #b5b8bf;
  --blue-bg: #26282d; --blue: #f2f2f3;
  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: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; letter-spacing: 0; }
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: var(--peach); color: var(--sienna); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3, h4 { font-weight: 500; letter-spacing: -0.01em; text-wrap: balance; }
/* Editorial serif is reserved for page-level headlines, always weight 400 */
h1, .page-title, .auth-body h1, .auth-side h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.015em; }
.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 12px; border-radius: var(--radius-pill); }
.skip-link:focus { top: 8px; }

/* ── Shell: quiet fog sidebar, transparent top bar ── */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar); padding: 14px 12px 18px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.workspace { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); margin-bottom: 8px; background: var(--bg); box-shadow: 0 0 0 1px var(--border); }
.workspace:hover { background: var(--bg-hover); }
.org-logo { width: 28px; height: 28px; border-radius: var(--radius-pill); background: var(--brand-color, var(--navy)); color: var(--text-inverse); display: grid; place-items: center; font: 500 10px/1 var(--font); flex-shrink: 0; overflow: hidden; }
.org-info { min-width: 0; line-height: 1.25; }
.org-name { font-weight: 500; font-size: 13.5px; 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: 6px 10px 14px; }
.brand img { width: 22px; height: 17px; }
.logo-text, .wordmark { font: 500 16px/1 var(--font); letter-spacing: -0.02em; color: var(--text); }
.logo-text span, .wordmark span { color: var(--text-3); }
[data-theme="dark"] .brand img, [data-theme="dark"] .mark { filter: brightness(0) invert(1); }
.nav-section { font-size: 11.5px; font-weight: 400; color: var(--text-3); padding: 16px 12px 4px; letter-spacing: .02em; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px; border-radius: var(--radius-pill); color: var(--text-2); font-weight: 400; cursor: pointer; transition: background-color .12s, color .12s; }
.nav-item svg { width: 16px; height: 16px; stroke-width: 1.7; }
.nav-item:hover { background: var(--bg-active); color: var(--text); }
.nav-item.active { background: var(--bg); color: var(--text); font-weight: 500; box-shadow: 0 0 0 1px var(--border); }
.nav-item.active svg { color: var(--text); }
.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: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px); }
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-3); min-width: 0; white-space: nowrap; }
.crumbs b { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.crumbs svg { width: 15px; height: 15px; }
.topbar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.search, .search-box { position: relative; width: min(380px, 100%); }
.search svg, .search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.search input, .search-box input { width: 100%; height: 36px; padding: 0 14px 0 38px; border: 1px solid transparent; border-radius: var(--radius-pill); background: var(--bg-muted); outline: none; font-size: 14px; }
.search input:focus, .search-box input:focus { border-color: var(--border-strong); background: var(--bg); box-shadow: var(--shadow-md); }
.user-menu { display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border-radius: var(--radius-pill); cursor: pointer; margin-left: 4px; }
.user-menu:hover { background: var(--bg-muted); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--peach); color: var(--sienna); display: grid; place-items: center; font-size: 11px; font-weight: 500; }
.user-name { font-size: 13.5px; font-weight: 500; }
.user-role { font-size: 11.5px; color: var(--text-3); }
.content { padding: 12px 32px 72px; min-width: 0; max-width: 1400px; }
.content.flush { padding: 0; }

/* ── Page header + view bar ── */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 32px; line-height: 1.2; color: var(--text); }
.page-subtitle { color: var(--text-3); margin-top: 4px; font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.viewbar, .filters, .toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.viewbar .spacer, .filters .spacer, .toolbar .spacer { flex: 1; }

/* ── Buttons: pills. Filled ink for the primary action, ghost for the rest ── */
.btn, .btn-primary, .btn-ghost, .btn-danger { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font-size: 13.5px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color .12s, border-color .12s, color .12s, transform .06s; }
.btn svg, .btn-primary svg, .btn-ghost svg, .btn-danger svg { width: 15px; height: 15px; }
.btn:hover, .btn-ghost:hover { background: var(--bg-muted); border-color: var(--text-3); }
.btn-ghost { border-color: transparent; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger-bg); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
button:active:not(:disabled), .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { position: relative; width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: var(--radius-pill); background: none; color: var(--text-2); cursor: pointer; transition: background-color .12s, color .12s; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--bg-muted); color: var(--text); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--bg); }
.icon-btn .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--hot-dot); border: 1.5px solid var(--bg); }
.nav-toggle { display: none; }

/* Filter chips: soft pills, ink when active */
.chip, .filter-btn, .date-range { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius-pill); background: var(--bg-muted); color: var(--text-2); font-size: 13px; font-weight: 400; cursor: pointer; white-space: nowrap; transition: background-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-active); color: var(--text); }
.chip.active, .filter-btn.active, .chip[aria-pressed=true] { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }

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

/* ── Pills, tags, avatars ── */
.pill, .tag { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.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-strong); color: var(--text-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0; font-size: 11px; font-weight: 500; 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: var(--text-inverse); }
.kbd { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--radius-xs); font: 500 11px/1 var(--font); color: var(--text-3); background: var(--bg-subtle); }

/* ── Surfaces: soft 20px cards, hairline border, no shadow ── */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-height: 52px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; }
.card-title svg { width: 16px; height: 16px; color: var(--text-3); }
.card-title .count { font-size: 12.5px; font-weight: 400; color: var(--text-3); }
.card-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 400; color: var(--text-2); }
.card-link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.card-link svg { width: 13px; height: 13px; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.grid { display: grid; gap: 20px; }
.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: 20px; align-content: start; }

/* KPI strip: separate mist stat cards, metric in Inter 500 */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { padding: 18px 20px; background: var(--bg-muted); border-radius: 20px; min-width: 0; }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 13px; 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: 10px; flex-wrap: wrap; }
.kpi-value { font: 500 26px/1.1 var(--font); letter-spacing: -0.02em; }
.kpi-trend { font-size: 12.5px; font-weight: 400; }
.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: 12px; min-height: 48px; padding: 10px 20px; 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: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 13px; color: var(--text-3); white-space: nowrap; }

/* Tables: quiet rows, no vertical rules */
.table-wrap { border: 1px solid var(--border); border-radius: 20px; overflow: auto; background: var(--bg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 400; font-size: 12.5px; color: var(--text-3); background: var(--bg-subtle); height: 40px; padding: 0 16px; 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: 48px; padding: 0 16px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.table th + th, .table td + td { box-shadow: none; }
.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: 12px radius fields, ink focus */
.field { display: grid; gap: 6px; }
.field label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .help { font-size: 12.5px; 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: 38px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 14px; outline: none; transition: border-color .12s, box-shadow .12s; }
.field textarea, textarea.input { height: auto; min-height: 100px; padding: 10px 14px; 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: #a3a6af; opacity: 1; }
[data-theme="dark"] ::placeholder { color: var(--text-3); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.switch { position: relative; width: 34px; height: 20px; 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: 16px; height: 16px; 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: ink card with a peach accent; the inline callout is the one peach card per page */
.ai-surface { background: var(--navy); color: var(--text-inverse); border-radius: var(--radius-lg); padding: 20px 22px; }
.ai-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--navy-accent); }
.ai-tag svg { width: 14px; height: 14px; }
.ai-inline { display: flex; gap: 12px; align-items: flex-start; padding: 16px 20px; border: 0; background: var(--peach); color: var(--sienna); border-radius: var(--radius-lg); font-size: 13.5px; }
.ai-inline .ai-banner-title, .ai-inline b { color: var(--sienna); }
.ai-inline .ai-banner-sub, .ai-inline .muted { color: color-mix(in srgb, var(--sienna) 78%, var(--peach)); }
.ai-inline svg { color: var(--sienna); }
.ai-inline .pill { background: rgba(255, 255, 255, .55); color: var(--sienna); }
[data-theme="dark"] .ai-inline { background: rgba(251, 225, 209, .12); color: #f3c6ad; }
[data-theme="dark"] .ai-inline .ai-banner-title, [data-theme="dark"] .ai-inline b, [data-theme="dark"] .ai-inline svg { color: #f3c6ad; }
[data-theme="dark"] .ai-inline .ai-banner-sub, [data-theme="dark"] .ai-inline .muted { color: #d9b8a5; }
[data-theme="dark"] .ai-inline .pill { background: rgba(255, 255, 255, .08); color: #f3c6ad; }

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

/* Kanban: mist columns, white 16px cards */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kcol { background: var(--bg-muted); border: 0; border-radius: var(--radius-lg); padding: 8px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; font-weight: 500; font-size: 14px; }
.kcol-head .count, .kcol-count { font-weight: 400; color: var(--text-3); font-size: 12.5px; }
.kcol-head .sum { margin-left: auto; font-weight: 400; color: var(--text-3); font-size: 12.5px; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.lcard { background: var(--bg); border: 1px solid transparent; border-radius: var(--radius); padding: 14px 16px; cursor: pointer; box-shadow: none; display: grid; gap: 8px; min-width: 0; transition: box-shadow .12s, transform .12s; }
.lcard:hover { box-shadow: var(--shadow-md); }
[data-theme="dark"] .lcard { background: var(--bg-subtle); }

/* 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 .4s 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: 280px; z-index: 60; transform: translateX(-100%); transition: transform .25s var(--ease); background: var(--bg); }
  .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 12px; gap: 6px; height: 56px; }
  .topbar .search, .topbar .search-box, .user-menu > div:last-child { display: none; }
  .content { padding: 8px 16px calc(88px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 26px; }
  .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)); gap: 10px; }
  .kpi { padding: 14px 16px; }
  .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-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 10.5px; font-weight: 400; color: var(--text-3); }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a[aria-current=page] { color: var(--text); font-weight: 500; }
}

@media (max-width: 900px) {
  /* Wide tables swipe sideways: a soft shadow marks the edge that has more columns.
     Scroll shadows: the "local" covers travel with the rows, the shadows stay on the edges.
     Rows are transparent, so the shadows show through them. */
  .table-wrap {
    background:
      linear-gradient(to right, var(--bg) 30%, transparent) left center / 40px 100% no-repeat local,
      linear-gradient(to left, var(--bg) 30%, transparent) right center / 40px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--text) 18%, transparent), transparent) left center / 14px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--text) 18%, transparent), transparent) right center / 14px 100% no-repeat scroll,
      var(--bg);
    overscroll-behavior-x: contain;
  }
}

/* ── 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: 13.5px; color: var(--text-2); }
.auth-body { flex: 1; display: grid; align-content: center; width: min(420px, 100%); margin: 32px auto; gap: 22px; }
.auth-body h1 { font-size: 36px; line-height: 1.2; }
.auth-body .lead { color: var(--text-3); margin-top: -12px; font-size: 15px; }
.auth-form { display: grid; gap: 14px; }
.auth-form .btn-primary, .auth-form .btn { height: 42px; font-size: 14.5px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; }
.link { color: var(--text); font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-foot { font-size: 13.5px; color: var(--text-2); text-align: center; }
.auth-legal { font-size: 12.5px; color: var(--text-3); text-align: center; }
.form-alert { display: flex; gap: 8px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); font-size: 13.5px; background: var(--danger-bg); color: var(--danger); }
.form-alert.info { background: var(--bg-muted); color: var(--text-2); }
.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: 12.5px; color: var(--danger); }
.field input[aria-invalid=true] { border-color: var(--danger); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px !important; }
.pw-toggle { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); }
.otp-input { letter-spacing: .5em; font: 500 20px/1 var(--mono) !important; text-align: center; height: 52px !important; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12.5px; }
.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: 12px 14px; display: grid; gap: 6px; }
.demo-box summary { cursor: pointer; font-size: 13px; 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: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer; font-size: 13px; }
.demo-acct:hover { background: var(--bg-muted); }
.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: 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.plan-opt input { position: absolute; opacity: 0; }
.plan-opt b { font-size: 13.5px; font-weight: 500; }
.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: var(--text-inverse); padding: clamp(28px, 5vw, 56px); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-side h2 { font-size: clamp(30px, 3vw, 44px); line-height: 1.25; max-width: 18ch; }
.auth-side h2 em { font-style: italic; color: var(--navy-accent); }
.auth-side p { color: var(--navy-ink); max-width: 44ch; font-size: 15px; }
.auth-side ul { list-style: none; display: grid; gap: 10px; color: var(--navy-ink); font-size: 14px; }
.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: 16px; border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .6); width: 118%; max-width: none; height: auto; }
/* Platform admin: dark, single column (same ink palette as dark mode) */
.auth-admin { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: #0f1012; color: #f2f2f3; color-scheme: dark;
  --bg: #17191c; --bg-subtle: #1c1e22; --bg-hover: #202328; --bg-muted: #26282d; --text: #f2f2f3; --text-2: #b5b8bf; --text-3: #8a8e97; --border: #2c2f35; --border-strong: #3a3d44;
  --primary: #f2f2f3; --primary-hover: #ffffff; --on-primary: #17191c; --primary-soft: #26282d; --primary-ink: #f2f2f3; --danger-bg: rgba(200, 80, 70, .2); --danger: #f0a09a;
  --blue-bg: #26282d; --blue: #f2f2f3; --success-bg: rgba(63, 125, 85, .2); --success: #8fcfa4; }
.admin-card { width: min(440px, 100%); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; 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: 12.5px; font-weight: 500; color: var(--navy-accent); }
.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: 22px; } }
.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; } }
