/* Wayy Admin: design system. Light and dark themes as tokens on :root; [data-theme] on <html>
   is set by app.js from the saved choice, else the system preference. */

:root {
  color-scheme: light;
  --brand: #3d4be8;
  --primary: #1f6fe5;
  --primary-hover: #185bc4;
  --indigo: #3b37e0;
  --indigo-hover: #2f2bc4;
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --sunken: #eef2f9;
  --ink: #0f1a3b;
  --ink-2: #4a5677;
  --ink-3: #8790ab;
  --line: #e3e8f2;
  --line-strong: #cfd7e6;
  --sidebar: #eaf3fc;
  --sidebar-ink: #1a2550;
  --sidebar-label: #7b86a6;
  --sidebar-active: #d5e7fb;
  --shadow: 0 1px 2px rgba(15, 26, 59, 0.05), 0 2px 8px rgba(15, 26, 59, 0.04);
  --shadow-lg: 0 18px 50px rgba(15, 26, 59, 0.18);
  --blue: #1f6fe5;   --blue-bg: #e7f0fd;
  --violet: #7c3aed; --violet-bg: #f1eafd;
  --green: #16a34a;  --green-bg: #e3f6ea;
  --red: #dc2626;    --red-bg: #fde8e8;
  --amber: #d97706;  --amber-bg: #fdf1df;
  --teal: #0d9488;   --teal-bg: #dff5f2;
  --neutral: #5b6685; --neutral-bg: #eef1f7;
  --chart-1: #2563eb;
  --chart-2: #22b8cf;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 14px;
}

/* Dark mode: near-black surfaces (not navy-grey), with the brand's own blue → violet → purple
   gradient as the accent family — the same colors as the logo and the CTA gradient, not a generic
   dark-admin blue-grey. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #07080d;
  --surface: #0d0e17;
  --surface-2: #0a0b12;
  --sunken: #14151f;
  --ink: #f3f4fb;
  --ink-2: #9a9db8;
  --ink-3: #686c88;
  --line: #1c1e2c;
  --line-strong: #2a2c3e;
  --sidebar: #050609;
  --sidebar-ink: #ecedf8;
  --sidebar-label: #666a8a;
  --sidebar-active: rgba(94, 110, 255, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.65);
  --primary: #5e6eff;
  --primary-hover: #4d5cf0;
  --indigo: #7c6bff;
  --indigo-hover: #6a59f5;
  --blue: #5e8eff;   --blue-bg: rgba(94, 142, 255, 0.16);
  --violet: #a26bff; --violet-bg: rgba(162, 107, 255, 0.16);
  --green: #2fdb9b;  --green-bg: rgba(47, 219, 155, 0.14);
  --red: #ff6b6b;    --red-bg: rgba(255, 107, 107, 0.14);
  --amber: #ffb648;  --amber-bg: rgba(255, 182, 72, 0.14);
  --teal: #38d9c9;   --teal-bg: rgba(56, 217, 201, 0.14);
  --neutral: #9598b5; --neutral-bg: rgba(149, 152, 181, 0.12);
  --chart-1: #6e8bff;
  --chart-2: #38d9c9;
}
:root[data-theme='dark'] body { background: radial-gradient(1100px 500px at 12% -8%, rgba(61, 75, 232, 0.16) 0%, transparent 60%), var(--bg); }
:root[data-theme='dark'] .sidebar { background: linear-gradient(185deg, #090a11 0%, var(--sidebar) 45%); }
:root[data-theme='dark'] .nav-item.active::before { background: linear-gradient(180deg, #5e8eff, #a26bff); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
svg.i { width: 18px; height: 18px; flex: none; stroke-width: 1.9; }
code { background: var(--sunken); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); }
p { margin: 0; }

/* ── Signed-out screens ─────────────────────────────────────────────── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #5a6cff 0%, transparent 60%), var(--brand); }
.gate .panel { width: min(420px, 100%); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 34px 32px 30px; display: grid; gap: 16px; }
.gate h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; }
.gate p { color: var(--ink-2); }
.gate .brand { display: grid; gap: 14px; justify-items: start; }
.field { width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--ink); }
.field::placeholder { color: var(--ink-3); }
.field:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-bg); }
.form { display: grid; gap: 12px; }
.err { color: var(--red); font-size: 13px; }
.err:empty { display: none; }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ── Logo ───────────────────────────────────────────────────────────── */
.logo { display: inline-flex; align-items: center; justify-content: center; background: var(--brand); color: #fff; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; border-radius: 12px; padding: 6px 18px 8px; line-height: 1; text-decoration: none; box-shadow: 0 6px 18px rgba(61, 75, 232, 0.35); }
.logo.sm { font-size: 18px; padding: 5px 14px 7px; border-radius: 10px; }
/* The header's wordmark: no pill, just the brand gradient clipped onto the text (same treatment
   as the website's wordmark) — a background box reads as a button here, not a brand mark. */
.brand-mark { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; line-height: 1; text-decoration: none; color: #000000; }
:root[data-theme='dark'] .brand-mark { color: #ffffff; }

/* ── Universal header (full width, above the sidebar) ───────────────── */
:root { --header-h: 64px; }
.app-header { position: sticky; top: 0; z-index: 20; height: var(--header-h); display: flex; align-items: center; gap: 14px; padding: 0 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.sidebar-toggle svg { width: 19px; height: 19px; }

/* ── Shell: sidebar + page, below the header ──────────────────────────── */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); align-items: start; }
.sidebar { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; background: var(--sidebar); color: var(--sidebar-ink); padding: 18px 14px 24px; border-right: 1px solid var(--line); transition: width 0.15s ease; }
.nav-group { margin-top: 18px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--sidebar-label); padding: 0 12px 6px; white-space: nowrap; overflow: hidden; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: none; text-align: left; text-decoration: none; color: inherit; padding: 9px 12px; border-radius: 10px; font-weight: 500; font-size: 14px; position: relative; }
.nav-item:hover { background: var(--sidebar-active); }
.nav-item.active { background: var(--sidebar-active); color: var(--blue); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--blue); }
.nav-item .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.nav-item .soon { font-size: 10px; font-weight: 600; color: var(--sidebar-label); border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 6px; }

/* Collapsed (desktop): an icon-only rail. Set on <html> so it applies before first paint, same as
   the theme — avoids a flash of the expanded sidebar on load. */
html[data-sidebar='collapsed'] .shell { grid-template-columns: 76px minmax(0, 1fr); }
html[data-sidebar='collapsed'] .sidebar { padding-left: 8px; padding-right: 8px; overflow: visible; }
html[data-sidebar='collapsed'] .nav-label { height: 1px; margin: 11px 0; padding: 0; overflow: hidden; background: var(--line); text-indent: -9999px; }
html[data-sidebar='collapsed'] .nav-item { justify-content: center; padding: 10px 0; }
html[data-sidebar='collapsed'] .nav-item .grow,
html[data-sidebar='collapsed'] .nav-item .soon { display: none; }
html[data-sidebar='collapsed'] .nav-badge { position: absolute; top: 2px; right: 2px; min-width: 9px; height: 9px; padding: 0; font-size: 0; }
html[data-sidebar='collapsed'] .nav-item.active::before { display: none; }

.search { position: relative; width: 100%; }
.search .field { padding: 10px 70px 10px 40px; border-radius: 12px; border-width: 1px; background: var(--surface); }
.search > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11.5px; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; background: var(--surface-2); }
.search-pop { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.search-hit { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 10px; }
.search-hit:hover, .search-hit.sel { background: var(--sunken); }
.search-hit .t { font-weight: 600; }
.search-hit .s { font-size: 12.5px; color: var(--ink-3); }
.search-empty { padding: 14px; color: var(--ink-3); }
.spacer { flex: 1; }
.icon-btn { position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; width: 40px; height: 40px; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); background: var(--sunken); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid var(--surface); }
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px 6px; border-radius: 12px; text-align: left; }
.user-btn:hover { background: var(--sunken); }
.user-btn .n { font-weight: 700; line-height: 1.2; }
.user-btn .r { font-size: 12px; color: var(--ink-3); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 10px; text-align: left; text-decoration: none; color: inherit; }
.menu-item:hover { background: var(--sunken); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-head { padding: 8px 10px 10px; }
.menu-head .s { color: var(--ink-3); font-size: 12.5px; word-break: break-all; }

.page { padding: 26px 28px 56px; max-width: 1560px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.page-head p { color: var(--ink-2); margin-top: 4px; }
.page-head .date { color: var(--ink-2); }
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-bottom: 18px; background: var(--amber-bg); color: var(--ink); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); }
.banner svg { color: var(--amber); margin-top: 1px; }
.banner.info { background: var(--blue-bg); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.banner.info svg { color: var(--blue); }

/* ── Grid ───────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 18px; }
.g-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.45fr) minmax(0, 0.8fr) minmax(0, 1.1fr); }
.g-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.stack { display: grid; gap: 18px; align-content: start; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 18px; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.card-sub { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.link { color: var(--blue); text-decoration: none; font-weight: 600; font-size: 13px; border: 0; background: none; padding: 0; }
.link:hover { text-decoration: underline; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

.kpi { display: flex; gap: 14px; align-items: flex-start; position: relative; cursor: default; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--line-strong); }
.kpi .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi .ico svg { width: 22px; height: 22px; }
.kpi .lbl { color: var(--ink-2); font-weight: 600; font-size: 13px; }
.kpi .val { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .val.na { font-size: 15px; font-weight: 600; color: var(--ink-3); padding: 7px 0 4px; }
.kpi .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.kpi .spark { position: absolute; right: 14px; bottom: 14px; width: 84px; height: 36px; }
.kpi .chev { position: absolute; right: 14px; top: 16px; color: var(--ink-3); }

.tone-blue { color: var(--blue); background: var(--blue-bg); }
.tone-violet { color: var(--violet); background: var(--violet-bg); }
.tone-green { color: var(--green); background: var(--green-bg); }
.tone-red { color: var(--red); background: var(--red-bg); }
.tone-amber { color: var(--amber); background: var(--amber-bg); }
.tone-teal { color: var(--teal); background: var(--teal-bg); }
.tone-neutral { color: var(--neutral); background: var(--neutral-bg); }
.tone-indigo { color: var(--indigo); background: color-mix(in srgb, var(--indigo) 12%, transparent); }
:root[data-theme='dark'] .tone-indigo { color: #a5a3ff; }

/* ── Pills, badges, buttons ─────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; padding: 8px 14px; border-radius: 10px; text-decoration: none; font-size: 13.5px; }
.btn:hover { background: var(--sunken); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.indigo { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn.indigo:hover { background: var(--indigo-hover); }
.btn.block { width: 100%; padding: 12px 16px; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.outline-blue { border-color: var(--blue); color: var(--blue); background: transparent; }
.btn.outline-blue:hover { background: var(--blue-bg); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.btn.danger:hover { background: var(--red-bg); }
.btn.primary.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ── Tabs ───────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 14px 11px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; font-size: 13.5px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--sunken); }
.seg button, .seg a { border: 0; background: none; padding: 5px 12px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.seg button.on, .seg a.on { background: var(--surface); color: var(--blue); box-shadow: var(--shadow); }

/* ── Progress ───────────────────────────────────────────────────────── */
.bar { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.bar.green > i { background: var(--green); }
.bar.violet > i { background: var(--violet); }
.bar.amber > i { background: var(--amber); }
.stackbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--sunken); gap: 2px; }
.stackbar > i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ── Lists and tables ───────────────────────────────────────────────── */
.list { display: grid; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li .main { flex: 1; min-width: 0; }
.li .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.li .s { font-size: 12.5px; color: var(--ink-3); }
.li .when { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex: none; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.date-chip { width: 44px; flex: none; text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 4px 0; background: var(--surface-2); }
.date-chip .m { font-size: 10.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; }
.date-chip .d { font-size: 17px; font-weight: 800; line-height: 1.1; }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover { background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .n { font-weight: 600; }
.who .e { font-size: 12.5px; color: var(--ink-3); }

/* ── Kanban ─────────────────────────────────────────────────────────── */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 13.5px; margin-bottom: 10px; padding: 2px 4px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
.kcard .t { font-weight: 600; font-size: 13.5px; }
.kcard .d { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.kcard .foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 9px; }
.kcard .moves { display: flex; gap: 4px; }
.kcard .moves button { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; width: 26px; height: 24px; display: grid; place-items: center; color: var(--ink-2); padding: 0; }
.kcard .moves button:hover:not([disabled]) { color: var(--blue); border-color: var(--blue); }
.kcard .moves button[disabled] { opacity: 0.35; cursor: not-allowed; }
.kcard .moves svg { width: 15px; height: 15px; }
.kcard.editable[draggable='true'] { cursor: grab; }
.kcard.dragging { opacity: 0.4; }
.kcol.drag-over { outline: 2px dashed var(--blue); outline-offset: -2px; background: var(--blue-bg); }
.epic-chip { display: inline-block; margin-bottom: 6px; background: var(--violet-bg); color: var(--violet); font-weight: 700; }

/* ── Status list (system health) ────────────────────────────────────── */
.svc { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.svc:last-child { border-bottom: 0; }
.svc .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); flex: none; }
.svc .main { flex: 1; min-width: 0; }
.svc .t { font-weight: 600; }
.svc .s { font-size: 12px; color: var(--ink-3); }

/* ── Charts ─────────────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--ink-3); font: 500 11px var(--font); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.na-chart { position: relative; }
.na-chart .chart { opacity: 0.45; }
.na-chart .na-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; }
.na-msg .box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 340px; }
.na-msg .box .t { font-weight: 700; }
.na-msg .box .s { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }

/* ── Empty states ───────────────────────────────────────────────────── */
.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 34px 18px; color: var(--ink-2); }
.empty .ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--sunken); color: var(--ink-3); margin-bottom: 4px; }
.empty .ico svg { width: 24px; height: 24px; }
.empty .t { font-weight: 700; color: var(--ink); font-size: 15px; }
.empty .s { max-width: 440px; font-size: 13px; }

/* ── Big stat (in cards) ────────────────────────────────────────────── */
.stats-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
.bstat .v { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.bstat .k { font-size: 12.5px; color: var(--ink-2); }
.ring { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 18px; border: 3px solid currentColor; }

/* ── Docs reader ────────────────────────────────────────────────────── */
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.doc-card { display: flex; gap: 12px; align-items: flex-start; text-decoration: none; color: inherit; }
.doc-card:hover { border-color: var(--blue); }
.doc-card .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.doc-card .t { font-weight: 700; }
.doc-card .s { font-size: 12.5px; color: var(--ink-3); }
.docs-frame-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.docs-frame { width: 100%; height: calc(100vh - 230px); min-height: 480px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.docs-image img { max-width: 100%; height: auto; display: block; margin: 0 auto; background: #fff; border-radius: 8px; }
.markdown { max-width: 920px; line-height: 1.65; font-size: 14.5px; }
.markdown h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 14px; }
.markdown h2 { font-size: 1.3rem; font-weight: 800; margin: 30px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.markdown hr + h2 { border-top: 0; padding-top: 0; }
.markdown h3 { font-size: 1.08rem; font-weight: 700; margin: 22px 0 8px; }
.markdown h4 { font-size: 1rem; font-weight: 700; margin: 16px 0 6px; }
.markdown p, .markdown ul, .markdown ol { margin: 0 0 12px; }
.markdown li { margin: 3px 0; }
.markdown a.docs-missing { color: var(--ink-2); text-decoration: underline dotted; cursor: help; }
.md-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin: 0 0 16px; }
.markdown table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.markdown th { text-align: left; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--line); }
.markdown td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.markdown tr:last-child td { border-bottom: 0; }
.markdown pre { background: var(--sunken); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-size: 13px; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { margin: 0 0 12px; padding: 4px 16px; border-left: 3px solid var(--blue); color: var(--ink-2); }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.markdown img { max-width: 100%; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--blue); }

/* ── Brand ──────────────────────────────────────────────────────────── */
.brand-tile { border-radius: 14px; aspect-ratio: 4 / 3; display: grid; place-items: center; font-weight: 800; font-size: 30px; letter-spacing: -0.02em; border: 1px solid var(--line); }
.swatch { border-radius: 12px; height: 64px; border: 1px solid var(--line); }

/* ── Applications drawer (review) ───────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(5, 10, 30, 0.45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(500px, 100%); background: var(--surface); z-index: 41; box-shadow: var(--shadow-lg); padding: 24px; overflow-y: auto; display: grid; gap: 20px; align-content: start; border-left: 1px solid var(--line); }
.drawer h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 6px; }
.drawer h3 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; word-break: break-word; }
.reason { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; white-space: pre-wrap; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 20px; border-left: 2px solid var(--line-strong); display: grid; gap: 16px; }
.timeline li { position: relative; }
.timeline li::before { content: ''; position: absolute; left: -27px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--blue); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--blue); }
.timeline .when { font-size: 12.5px; color: var(--ink-3); }
.review { display: grid; gap: 12px; }
.review.pinned { position: sticky; bottom: -24px; margin: 0 -24px -24px; padding: 16px 24px 20px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.08); }
.review-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.review-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border: 1.5px solid var(--line-strong); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13.5px; }
.choice:hover { border-color: var(--blue); }
.choice.selected { border-color: var(--blue); background: var(--blue-bg); color: var(--blue); }
.choice input { accent-color: var(--blue); width: 16px; height: 16px; margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.confirm { display: grid; gap: 12px; padding: 14px 16px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.notice { padding: 11px 14px; border-radius: 12px; font-size: 13.5px; }
.notice.ok { background: var(--green-bg); color: var(--green); }
.notice.warn { background: var(--amber-bg); color: var(--amber); }
.notice.err { background: var(--red-bg); color: var(--red); }

/* ── Inline add form ────────────────────────────────────────────────── */
.add-row { display: flex; gap: 8px; margin-top: 8px; }
.add-row .field { padding: 8px 10px; border-radius: 9px; font-size: 13px; border-width: 1px; }
select.field { padding: 7px 10px; border-radius: 9px; border-width: 1px; font-size: 13px; width: auto; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1380px) {
  .g-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .g-main > :first-child { grid-column: span 2; }
}
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3, .g-wide { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}
@media (max-width: 900px) {
  /* Below 900px the toggle always opens an off-canvas overlay, regardless of the collapsed state
     a wider viewport may have saved — an icon-only rail doesn't help on a phone. */
  .shell, html[data-sidebar='collapsed'] .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar, html[data-sidebar='collapsed'] .sidebar { position: fixed; z-index: 50; left: 0; top: var(--header-h); bottom: 0; width: 270px; padding: 18px 14px 24px; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  html[data-sidebar='collapsed'] .nav-label { height: auto; margin: 0 0 6px; background: none; text-indent: 0; }
  html[data-sidebar='collapsed'] .nav-item { justify-content: flex-start; padding: 9px 12px; }
  html[data-sidebar='collapsed'] .nav-item .grow { display: block; }
  html[data-sidebar='collapsed'] .nav-badge { position: static; min-width: 22px; height: 20px; padding: 0 7px; font-size: 11.5px; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ''; position: fixed; inset: 0; top: var(--header-h); background: rgba(5, 10, 30, 0.45); z-index: 45; }
  .app-header { padding: 0 16px; gap: 10px; }
  .user-btn .n, .user-btn .r, .user-btn > svg:last-child, .kbd { display: none; }
  .page { padding: 18px 16px 40px; }
  .g-kpi, .g-2, .g-main { grid-template-columns: minmax(0, 1fr); }
  .g-main > :first-child { grid-column: auto; }
  .kanban { grid-template-columns: repeat(4, minmax(240px, 1fr)); }
}
@media (max-width: 560px) {
  .g-4 { grid-template-columns: minmax(0, 1fr); }
  #search-slot { width: auto; max-width: none; }
  .kbd { display: none; }
  .search .field { padding-right: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

.nowrap { white-space: nowrap; }
@media (max-width: 560px) { .seg { flex-wrap: wrap; } .card-head { flex-wrap: wrap; } }

/* ── Editing ────────────────────────────────────────────────────────── */
.editable { cursor: pointer; transition: border-color 0.12s ease, background-color 0.12s ease; }
.kcard.editable:hover, .card.editable:hover { border-color: var(--blue); }
tr.editable:hover, .li.editable:hover { background: var(--surface-2); }
.li.editable { border-radius: 8px; padding-left: 6px; padding-right: 6px; margin: 0 -6px; }
dialog.editor { border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog.editor::backdrop { background: rgba(5, 10, 30, 0.5); }
.ed-form { display: grid; gap: 14px; padding: 22px 24px 22px; }
.ed-form h2 { font-size: 1.2rem; font-weight: 800; }
.ed-field { display: grid; gap: 6px; }
.ed-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.ed-hint { font-size: 12px; color: var(--ink-3); }
.ed-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ed-form .field { border-width: 1px; padding: 10px 12px; border-radius: 10px; }
textarea.field { resize: vertical; font: inherit; }
.head-actions { display: flex; align-items: center; gap: 10px; }
@media (max-width: 560px) { .ed-grid { grid-template-columns: minmax(0, 1fr); } }

/* ── Loading gate: logo, tagline, a travel route animating in ───────── */
.gate .panel.loading-panel { box-shadow: none; background: none; padding: 0; width: auto; display: grid; justify-items: center; gap: 22px; text-align: center; }
.loading-logo { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); }
.loading-tagline { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.03em; color: rgba(255, 255, 255, 0.92); }
.loading-tagline .dot { opacity: 0.55; margin: 0 2px; }
.route-track { width: 220px; height: auto; overflow: visible; }
.route-path { fill: none; stroke: rgba(255, 255, 255, 0.3); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 5 7; }
.route-dot { fill: rgba(255, 255, 255, 0.55); }
.route-dot-end { fill: #ffffff; }
.route-marker { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.35)); }

/* ── Linked-document strip (above a table backed by a repo doc) ──────── */
.linked-doc { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--ink-3); padding: 8px 2px 14px; }
.linked-doc svg { flex: none; margin-top: 1px; color: var(--ink-3); }
.linked-doc a { color: var(--blue); }
.linked-doc code { font-size: 11.5px; }

/* ── Scrollbars: thin, theme-matched, no OS arrow buttons ────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: padding-box; }
*::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
*::-webkit-scrollbar-corner { background: transparent; }
