/* Basser360 design system (docs/09-ui-redesign.md §1). Plain CSS, no build step.
   Tokens first, then the app shell, then components, then screen-specific rules, then phone sizes. */

:root {
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --paper: #f5f7fb;
    --panel: #ffffff;
    --line: #e2e8f0;
    --line-2: #cbd5e1;
    --brand: #1d4ed8;
    --brand-ink: #ffffff;
    --brand-soft: #e8efff;
    --brand-deep: #0b1b4a;
    --nav: #0f1f4d;
    --nav-2: #16306e;
    --nav-ink: #dbe4ff;
    --ai: #6d28d9;
    --ai-soft: #f1ebff;
    --ai-ink: #ffffff;
    /* Status colours used everywhere the same way (docs/03-screens.md). */
    --status-moving: #15803d;   /* green */
    --status-stuck: #d97706;    /* amber */
    --status-parked: #6b7280;   /* grey */
    --status-needs: #dc2626;    /* red */
    --tint-moving: #e7f6ec;
    --tint-stuck: #fff4e0;
    --tint-parked: #eef0f3;
    --tint-needs: #fde8e6;
    --tint-info: #e8f1ff;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
    --shadow-2: 0 10px 30px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.06);
    --sidebar-width: 248px;
    --accent: var(--brand);
    --accent-ink: var(--brand-ink);
    --bg: var(--paper);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 0.35rem; font-weight: 700; letter-spacing: -0.01em; }
h1 small { font-weight: 500; font-size: 1rem; color: var(--muted); margin-left: 0.4rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; font-weight: 700; }
h2 small { font-weight: 500; font-size: 0.9rem; color: var(--muted); margin-left: 0.4rem; }
h3 { font-size: 0.98rem; margin: 0 0 0.5rem; font-weight: 700; }
p { margin: 0 0 0.75rem; }
.lead { color: var(--muted); font-size: 1.02rem; margin-bottom: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
code { font-size: 0.9em; background: var(--brand-soft); padding: 0.05rem 0.35rem; border-radius: 4px; }
code.wrap { word-break: break-all; }
hr { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }

/* Icons: inline SVG from the sprite in _Icons.cshtml, always next to a label. */
.icon { width: 1.1em; height: 1.1em; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon.lg { width: 1.5em; height: 1.5em; }

/* ---- App shell ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--nav) 0%, var(--nav-2) 100%);
    color: var(--nav-ink);
    padding: 1.1rem 0.9rem 1.5rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.brand { display: flex; align-items: center; justify-content: space-between; padding: 0.2rem 0.5rem; }
.brand a { color: #fff; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; display: flex; flex-direction: column; line-height: 1.15; }
.brand a small { font-weight: 500; font-size: 0.78rem; color: var(--nav-ink); opacity: 0.85; }
.brand-mark { display: inline-flex; width: 1.6rem; height: 1.6rem; border-radius: 8px; background: linear-gradient(135deg, #60a5fa, #a78bfa); align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 0.9rem; margin-right: 0.5rem; }
.brand-row { display: flex; align-items: center; }
.nav-toggle { display: none; font: inherit; background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; padding: 0.3rem 0.7rem; cursor: pointer; }
.nav-section { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--nav-ink); opacity: 0.6; padding: 0.4rem 0.75rem 0.2rem; }
.nav { list-style: none; margin: 0; padding: 0; }
.nav li { margin-bottom: 0.15rem; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    transition: background 0.15s ease;
}
.nav-link .icon { width: 1.25rem; height: 1.25rem; opacity: 0.9; }
.nav-link small { display: block; font-weight: 400; color: var(--nav-ink); font-size: 0.75rem; opacity: 0.8; line-height: 1.2; }
.nav-link:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,0.16); box-shadow: inset 3px 0 0 #93c5fd; }
.nav-link.ai .icon { color: #c4b5fd; }
.nav-link.ai.active { box-shadow: inset 3px 0 0 #c4b5fd; }
.sidebar-foot { margin-top: auto; padding: 0 0.75rem; font-size: 0.75rem; color: var(--nav-ink); opacity: 0.6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 1.5rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 15;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar-review { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.9rem; }
.topbar-review strong { color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.topbar-user { display: flex; align-items: center; gap: 0.6rem; padding-left: 0.6rem; border-left: 1px solid var(--line); }
.avatar { display: inline-flex; width: 2rem; height: 2rem; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; align-items: center; justify-content: center; font-size: 0.85rem; }
.icon-button { display: inline-flex; align-items: center; gap: 0.4rem; font: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.4rem 0.7rem; cursor: pointer; color: var(--ink); position: relative; }
.icon-button:hover { background: var(--paper); text-decoration: none; }
.icon-button .count { position: absolute; top: -0.4rem; right: -0.4rem; min-width: 1.25rem; height: 1.25rem; border-radius: 999px; background: var(--status-needs); color: #fff; font-size: 0.72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 0.3rem; }
.icon-button .count.amber { background: var(--status-stuck); }
.icon-button.ai { border-color: #ddd6fe; background: var(--ai-soft); color: var(--ai); font-weight: 600; }
.bell-wrap { position: relative; }
.bell-menu { position: absolute; right: 0; top: calc(100% + 0.5rem); width: 380px; max-width: 92vw; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); z-index: 30; padding: 0.5rem; }
.bell-menu[hidden] { display: none; }
.bell-menu h3 { padding: 0.5rem 0.75rem 0.25rem; margin: 0; display: flex; justify-content: space-between; }
.bell-menu .alert { padding: 0.5rem 0.75rem; }
.bell-empty { padding: 1rem 0.75rem; color: var(--muted); }

.content { padding: 1.5rem; max-width: 1480px; width: 100%; }
.anonymous-content { max-width: 520px; margin: 4rem auto; padding: 0 1rem; }

/* Toasts (flash and error messages) */
.toasts { position: fixed; top: 1rem; right: 1rem; z-index: 50; display: flex; flex-direction: column; gap: 0.5rem; max-width: 420px; }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 0.7rem 1rem 0.7rem 0.9rem; box-shadow: var(--shadow-2); display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer; border-left: 4px solid var(--status-moving); }
.toast.error { border-left-color: var(--status-needs); }
.toast .toast-close { margin-left: auto; opacity: 0.7; }
.banners { padding: 0 1.5rem; }
.banner { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; background: var(--tint-stuck); border: 1px solid #f6d7a3; border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; margin-top: 0.9rem; }
.banner-body { white-space: pre-wrap; font: inherit; margin: 0.5rem 0 0; }

/* ---- Cards and layout helpers ---- */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-1);
}
.card.narrow { max-width: 480px; }
.card.flat { box-shadow: none; }
.card h2:first-child { margin-top: 0; }
.toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .lead { margin-bottom: 0; }
.toolbar .actions { margin-top: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.page-head .actions { margin-top: 0; }
.actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.flash { background: var(--tint-moving); border: 1px solid #b7e2c4; border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; margin: 0 0 1rem; }
.notice { background: var(--tint-info); border: 1px solid #c7dbff; border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; }
.error-flash { background: var(--tint-needs); border-color: #f3b7b0; }
.errors, .error { color: var(--status-needs); }
.errors { margin-bottom: 0.75rem; }
.errors ul { margin: 0; padding-left: 1.2rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-3 .card { margin-bottom: 0; }
.grid-3 + .card, .grid-3 + section, .grid-3 + .grid-2 { margin-top: 1.25rem; }
.narrow-wide { max-width: 760px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: none; }
.prewrap { white-space: pre-wrap; }
.empty { padding: 1.25rem; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); color: var(--muted); text-align: center; }
.empty strong { color: var(--ink); display: block; margin-bottom: 0.2rem; }

/* ---- Forms ---- */
.field { margin-bottom: 0.9rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.92rem; }
.field.check label { font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="url"], select, textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 5rem; }
button, .button {
    font: inherit;
    font-weight: 600;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-2);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
button:hover, .button:hover { background: var(--paper); text-decoration: none; }
button.primary, .button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover, .button.primary:hover { background: #1e40af; }
button.ai, .button.ai { background: var(--ai); color: var(--ai-ink); border-color: var(--ai); }
button.ai:hover, .button.ai:hover { background: #5b21b6; }
button.link { background: none; border: none; color: var(--brand); padding: 0; cursor: pointer; font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.button.large { font-size: 1.05rem; padding: 0.7rem 1.2rem; }
form.inline { display: inline; }
.inline-form { display: flex; gap: 0.4rem; align-items: center; }
.inline-form input { width: auto; min-width: 14rem; }
.form-row { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.form-row .field { margin-bottom: 0; min-width: 12rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.75rem 1rem; align-items: end; }
.form-grid .field { margin-bottom: 0; }
.field.wide { flex: 2; grid-column: 1 / -1; }
.setting-form { display: flex; gap: 0.5rem; align-items: flex-start; }
.setting-form input, .setting-form textarea { flex: 1; }
.add-form { margin-top: 0.75rem; }
.add-form summary { font-weight: 600; }
.add-form form { margin-top: 0.75rem; }
.summary-form { margin-top: 1rem; }
.summary-form h3 { margin-top: 1rem; }
.upload-form { margin-top: 0.75rem; }
.check-inline { display: inline-block; margin-right: 1rem; font-weight: 400; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover td { background: #fafbfe; }
table.settings td.setting-key { width: 38%; }
table.audit pre { max-width: 28rem; max-height: 14rem; overflow: auto; font-size: 0.75rem; white-space: pre-wrap; word-break: break-all; margin: 0.25rem 0 0; }
table.agenda td { vertical-align: middle; }
table.platform td, table.platform th { font-size: 0.9rem; }
tr.expiring td { background: var(--tint-stuck); }
tr.expired td { background: var(--tint-needs); }
details summary { cursor: pointer; color: var(--brand); }

/* ---- Tabs, pager ---- */
.tabs { display: flex; gap: 0.35rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs a { padding: 0.4rem 0.9rem; border-radius: 999px; color: var(--muted); font-weight: 600; border: 1px solid transparent; }
.tabs a:hover { background: var(--panel); text-decoration: none; }
.tabs a.active { color: var(--brand); background: var(--brand-soft); border-color: #c7d7ff; }
.pager a { display: inline-block; padding: 0.25rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; margin-right: 0.25rem; }
.pager a.active { background: var(--brand); color: var(--brand-ink); }

/* ---- Status: dots, pills, badges, chips ---- */
.dot { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 50%; vertical-align: middle; margin-right: 0.35rem; box-shadow: 0 0 0 2px #fff; }
.dot.moving { background: var(--status-moving); }
.dot.stuck { background: var(--status-stuck); }
.dot.parked, .dot.notstarted { background: var(--status-parked); }
.dot.needs, .dot.overdue { background: var(--status-needs); }
.status-word { font-size: 0.9rem; }
.pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.6rem 0.15rem 0.45rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: var(--tint-parked); color: var(--ink-2); white-space: nowrap; }
.pill .dot { margin: 0; box-shadow: none; width: 0.55rem; height: 0.55rem; }
.pill.moving { background: var(--tint-moving); color: #166534; }
.pill.stuck { background: var(--tint-stuck); color: #92400e; }
.pill.needs, .pill.overdue { background: var(--tint-needs); color: #991b1b; }
.pill.parked, .pill.notstarted { background: var(--tint-parked); color: #374151; }
.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; background: #eef1f5; font-size: 0.78rem; font-weight: 600; margin-right: 0.25rem; color: var(--ink-2); }
.badge.amber { background: var(--tint-stuck); color: #92400e; }
.badge.red { background: var(--tint-needs); color: #991b1b; }
.badge.green { background: var(--tint-moving); color: #166534; }
.badge.blue { background: var(--tint-info); color: #1e3a8a; }
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.8rem; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font-size: 0.88rem; font-weight: 600; }
.chip:hover { border-color: var(--brand); text-decoration: none; }
.chip.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.chip .num { font-weight: 800; }
.chip.needs .num { color: var(--status-needs); }
.chip.stuck .num { color: var(--status-stuck); }
.chip.moving .num { color: var(--status-moving); }
.chip.active .num { color: inherit; }
.ai-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--ai-soft); color: var(--ai); font-size: 0.78rem; font-weight: 700; vertical-align: middle; }
.ai-badge .icon { width: 0.95em; height: 0.95em; }

/* ---- Overview ---- */
.overview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.overview-head h1 { margin-bottom: 0; }
.attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.alert { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.8rem 0.9rem; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow-1); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.alert:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-2); }
.alert-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--status-parked); flex-shrink: 0; }
.alert.red .alert-bar { background: var(--status-needs); }
.alert.amber .alert-bar { background: var(--status-stuck); }
.alert.info .alert-bar { background: var(--brand); }
.alert-title { font-weight: 700; }
.alert-detail { color: var(--muted); font-size: 0.88rem; }
.alert-count { margin-left: auto; font-weight: 800; font-size: 1.3rem; color: var(--ink-2); }
.alert.red .alert-count { color: var(--status-needs); }
.alert.amber .alert-count { color: var(--status-stuck); }
.all-clear { display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 1rem; border-radius: var(--radius-sm); background: var(--tint-moving); color: #166534; font-weight: 600; margin-bottom: 1.25rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.kpi { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; color: var(--ink); box-shadow: var(--shadow-1); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.kpi:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-2); }
.kpi-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.kpi-value { font-size: 1.9rem; font-weight: 800; line-height: 1.1; margin: 0.2rem 0; letter-spacing: -0.02em; }
.kpi-value small { font-size: 0.95rem; font-weight: 600; color: var(--muted); }
.kpi-hint { font-size: 0.85rem; color: var(--muted); }
.kpi.needs .kpi-value { color: var(--status-needs); }
.kpi.stuck .kpi-value { color: var(--status-stuck); }
.kpi.good .kpi-value { color: var(--status-moving); }
.overview-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
.overview-grid > .card { margin-bottom: 0; }
.overview-col { display: flex; flex-direction: column; gap: 1.25rem; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; align-items: start; }
.chart-box { position: relative; height: 200px; }
.rings { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-end; }
.ring { position: relative; width: 108px; text-align: center; }
.ring svg { width: 108px; height: 108px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: var(--brand); stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.ring .target { stroke: var(--status-needs); stroke-width: 3; stroke-dasharray: 2 1000; }
.ring .ring-value { position: absolute; top: 34px; left: 0; right: 0; font-weight: 800; font-size: 1.2rem; }
.ring .ring-value small { display: block; font-size: 0.7rem; font-weight: 500; color: var(--muted); }
.ring-label { font-size: 0.85rem; font-weight: 600; margin-top: 0.35rem; }
.snapshot { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.75rem; }
.snap { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.75rem 0.85rem; color: var(--ink); background: var(--panel); }
.snap:hover { text-decoration: none; border-color: var(--brand); }
.snap-name { font-weight: 700; }
.snap-type { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.4rem; }
.snap-dots { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.snap-dots .dot { margin: 0; box-shadow: none; width: 0.75rem; height: 0.75rem; }
.snap-count { font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; }
.week-list li, .activity-list li { display: flex; gap: 0.75rem; align-items: baseline; }
.week-date { min-width: 5.5rem; font-weight: 700; font-size: 0.88rem; }
.week-date.overdue { color: var(--status-needs); }
.activity-when { min-width: 6rem; color: var(--muted); font-size: 0.82rem; }
.getting-started ol { list-style: none; padding: 0; margin: 0; counter-reset: steps; }
.getting-started li { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.getting-started li:last-child { border-bottom: none; }
.step-mark { width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 2px solid var(--line-2); flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.step-mark.done { background: var(--status-moving); border-color: var(--status-moving); color: #fff; }
.getting-started .done-text { text-decoration: line-through; color: var(--muted); }
.ai-card { border-color: #ddd6fe; background: linear-gradient(180deg, #faf7ff 0%, #ffffff 60%); }
.ai-card h2 { display: flex; align-items: center; gap: 0.5rem; }
.ai-attention { padding-left: 1.2rem; margin: 0.5rem 0 0.75rem; }
.ai-attention li { margin-bottom: 0.3rem; }

.health { display: inline-flex; align-items: center; gap: 0.7rem; padding: 0.45rem 0.9rem 0.45rem 0.5rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow-1); }
.health:hover { text-decoration: none; box-shadow: var(--shadow-2); }
.health-score { display: inline-flex; width: 2.4rem; height: 2.4rem; border-radius: 50%; align-items: center; justify-content: center; font-weight: 800; color: #fff; background: var(--status-parked); }
.health.moving .health-score { background: var(--status-moving); }
.health.stuck .health-score { background: var(--status-stuck); }
.health.needs .health-score { background: var(--status-needs); }
.health-list li { display: flex; gap: 0.6rem; align-items: flex-start; }
.next-actions ol { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0.6rem; }
.next-action { display: flex; gap: 0.7rem; align-items: center; padding: 0.7rem 0.85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); background: linear-gradient(180deg, #fff, #f8faff); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.next-action:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: var(--brand); }
.next-action > span:nth-child(2) { flex: 1; }
.next-verb { flex-shrink: 0; padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--brand); color: #fff; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }

/* ---- Context pages (entities, people, agreements) ---- */
.tree .entity-node { margin-bottom: 0.75rem; }
.tree-children { margin: 0.75rem 0 0.5rem 1.25rem; padding-left: 1rem; border-left: 2px solid var(--line); }
.entity-head { display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }
.entity-name { font-weight: 700; font-size: 1.05rem; }
.entity-meta { margin-top: 0.35rem; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ---- Map ---- */
.map-layout { position: relative; }
.map-band { background: linear-gradient(135deg, #0f1f4d 0%, #1e3a8a 100%); color: #fff; border: none; }
.map-band h2, .map-band .muted { color: #fff; }
.map-band .muted { opacity: 0.8; }
.map-band-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.map-band-grid { display: grid; grid-template-columns: minmax(16rem, 1fr) 2fr; gap: 1.5rem; margin-top: 0.75rem; }
.map-band .ring .track { stroke: rgba(255,255,255,0.2); }
.map-band .ring .fill { stroke: #93c5fd; }
.map-band .ring .ring-value small { color: #dbe4ff; }
.map-band .pill { background: rgba(255,255,255,0.14); color: #fff; }
.bar-row { display: grid; grid-template-columns: 7rem 1fr 6rem; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; }
.bar { position: relative; height: 0.7rem; background: rgba(255,255,255,0.18); border-radius: 999px; overflow: visible; }
.bar-fill { position: absolute; left: 0; top: 0; height: 100%; background: #93c5fd; border-radius: 999px; }
.bar-target { position: absolute; top: -0.25rem; width: 2px; height: 1.2rem; background: #fca5a5; }
.bar-value { font-size: 0.9rem; }
.map-band-projects { display: flex; flex-wrap: wrap; gap: 0.5rem; align-content: flex-start; }
.map-mini-card { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.4rem 0.75rem; border-radius: 999px; background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.map-mini-card:hover { text-decoration: none; background: rgba(255,255,255,0.22); }
.map-mini-card .dot { box-shadow: none; }
.map-columns { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.map-column { flex: 0 0 300px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; box-shadow: var(--shadow-1); overflow: hidden; }
.map-column-strip { height: 6px; background: var(--brand); }
.map-column.type-spc .map-column-strip, .map-column.type-llc .map-column-strip { background: #1d4ed8; }
.map-column.type-jv .map-column-strip { background: #0f766e; }
.map-column.type-partnership .map-column-strip { background: #b45309; }
.map-column.type-planned .map-column-strip { background: #6b7280; }
.map-column.type-branch .map-column-strip { background: #7c3aed; }
.map-column-body { padding: 0.9rem; }
.map-column.child { flex: none; margin-top: 0.75rem; background: #f8fafc; box-shadow: none; }
.map-children { margin-top: 0.5rem; padding-left: 0.5rem; border-left: 3px solid var(--line); }
.map-entity { display: block; color: var(--ink); margin-bottom: 0.6rem; }
.map-entity:hover { text-decoration: none; }
.map-entity:hover .map-entity-name { text-decoration: underline; }
.map-entity-name { font-weight: 700; font-size: 1.02rem; }
.map-badges { margin: 0.25rem 0; }
.map-rows { display: flex; flex-direction: column; gap: 0.25rem; }
.map-row { display: grid; grid-template-columns: auto 1fr; column-gap: 0.4rem; padding: 0.4rem 0.5rem; border-radius: var(--radius-sm); color: var(--ink); align-items: center; border: 1px solid transparent; }
.map-row:hover { background: var(--paper); text-decoration: none; border-color: var(--line); }
.map-row-name { font-weight: 600; }
.map-row-owner { grid-column: 2; font-size: 0.8rem; }
.map-add { display: block; margin-top: 0.75rem; padding: 0.5rem; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); text-align: center; color: var(--muted); }
.map-add:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.map-panel { position: fixed; top: 0; right: 0; width: 400px; max-width: 100%; height: 100vh; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(15,23,42,0.14); padding: 1.25rem; z-index: 40; }
.map-panel h3 { margin-top: 1rem; }
.map-panel-close { float: right; }

/* ---- Direction ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.card-project { display: block; color: var(--ink); margin-bottom: 0; border-left: 5px solid var(--status-parked); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.card-project:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-2); }
.card-project.moving { border-left-color: var(--status-moving); }
.card-project.stuck { border-left-color: var(--status-stuck); }
.card-project.needs { border-left-color: var(--status-needs); }
.card-project-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.card-project-name { font-weight: 700; font-size: 1.05rem; }
.card-project-status { white-space: nowrap; font-size: 0.9rem; }
.card-project-goal { margin: 0.5rem 0; color: var(--ink-2); }
.card-project-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; font-size: 0.9rem; }
.rag-strip { display: flex; gap: 0.25rem; margin: 0.6rem 0 0.2rem; }
.rag-sq { width: 1.1rem; height: 0.5rem; border-radius: 3px; background: var(--status-parked); }
.rag-sq.rag-green { background: var(--status-moving); }
.rag-sq.rag-amber { background: var(--status-stuck); }
.rag-sq.rag-red { background: var(--status-needs); }
.rag-sq.rag-grey { background: var(--line-2); }
.needs-text { color: var(--status-needs); }
.overdue { color: var(--status-needs); }
.parked { margin-top: 1.25rem; }
.parked summary { font-weight: 600; cursor: pointer; margin-bottom: 0.75rem; }
.filter-bar { margin-bottom: 1rem; }
.summarise-form { margin-bottom: 1rem; }

/* ---- Project page ---- */
.section-title { margin-top: 0.5rem; }
.stepper { display: flex; gap: 0.25rem; flex-wrap: wrap; align-items: center; font-size: 0.8rem; }
.step { padding: 0.2rem 0.65rem; border-radius: 999px; background: var(--tint-parked); color: var(--muted); font-weight: 600; }
.step.done { background: var(--tint-moving); color: #166534; }
.step.current { background: var(--brand); color: var(--brand-ink); }
.step-sep { color: var(--line-2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { display: block; background: var(--panel); border: 1px solid var(--line); border-left-width: 6px; border-radius: var(--radius); padding: 1rem; color: var(--ink); box-shadow: var(--shadow-1); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-2); }
.tile-head { display: flex; justify-content: space-between; }
.tile-label { font-weight: 700; }
.tile-headline { margin: 0.4rem 0; }
.tile-metrics { list-style: none; padding: 0; margin: 0 0 0.4rem; font-size: 0.9rem; }
.tile-metrics li { display: flex; justify-content: space-between; gap: 0.5rem; border-bottom: 1px dotted var(--line); padding: 0.15rem 0; }
.rag-green { border-left-color: var(--status-moving); }
.rag-amber { border-left-color: var(--status-stuck); }
.rag-red { border-left-color: var(--status-needs); }
.rag-grey { border-left-color: var(--status-parked); }
.rag-word { font-size: 0.85rem; color: var(--muted); }
.rag-chip { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.8rem; color: #fff; }
.rag-chip.rag-green { background: var(--status-moving); }
.rag-chip.rag-amber { background: var(--status-stuck); }
.rag-chip.rag-red { background: var(--status-needs); }
.rag-chip.rag-grey { background: var(--status-parked); }
.rag-choice { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.rag-option { padding: 0.3rem 0.6rem; border: 1px solid var(--line); border-left-width: 6px; border-radius: 6px; }
.decision { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.decision:last-child { border-bottom: none; }
.done { text-decoration: line-through; color: var(--muted); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.timeline .when { color: var(--muted); font-size: 0.85rem; margin-right: 0.5rem; white-space: nowrap; }
.comments { list-style: none; padding: 0; margin: 0 0 1rem; }
.comment { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.comment.reply { margin-left: 1.5rem; }
.comment-meta { font-size: 0.9rem; margin-bottom: 0.2rem; }
.comment-body p:last-child, .md p:last-child { margin-bottom: 0; }

/* ---- Filter ---- */
.inbox-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.inbox-card { display: block; color: var(--ink); margin-bottom: 0; }
.inbox-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-2); }
.progress-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.dimension-title { margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.question { padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.question.retag { background: var(--tint-stuck); }
.question-text { margin-bottom: 0.4rem; }
.question-inputs { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-start; }
.question-inputs input[type="number"] { max-width: 11rem; }
.question-inputs select { max-width: 16rem; }
.question-inputs textarea { flex: 1 1 100%; min-height: 3.2rem; }
.inline-label { display: inline-flex; align-items: center; gap: 0.4rem; }
.inline-label input { width: 6rem; }
.question-tag { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-top: 0.4rem; }
.tag-option { padding: 0.2rem 0.6rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.9rem; }
.tag-fact { border-color: var(--status-moving); }
.tag-assumption { border-color: var(--status-stuck); }
.tag-unknown { border-color: var(--status-parked); }
.question-tag .source { flex: 1; min-width: 14rem; }
.gate-form { margin-top: 1rem; }
.count-row { margin-bottom: 0.6rem; }
.count-bar { display: flex; height: 0.8rem; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.count-bar .seg { display: block; height: 100%; }
.seg.facts { background: var(--status-moving); }
.seg.assumptions { background: var(--status-stuck); }
.seg.unknowns { background: var(--status-parked); }
.verdict-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.verdict-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.9rem; background: #fafbfe; }
.verdict-box.ai { border-color: #ddd6fe; background: var(--ai-soft); }
.verdict-word { font-size: 1.3rem; font-weight: 800; }
.verdict-word.green { color: var(--status-moving); }
.verdict-word.amber { color: var(--status-stuck); }
.verdict-word.red { color: var(--status-needs); }
.exits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.exit-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.9rem; }

/* ---- Unit and settings ---- */
mark.assumption { background: #fff1b8; padding: 0 0.2rem; border-radius: 3px; }
.rulebook .md h1 { font-size: 1.4rem; }
.rulebook .md h2 { font-size: 1.1rem; margin-top: 1rem; }
table.matrix select, table.matrix input { padding: 0.25rem 0.4rem; }
table.matrix input { max-width: 7rem; }
select.sev-hard { border-color: var(--status-needs); }
select.sev-soft { border-color: var(--status-stuck); }
select.sev-off { color: var(--muted); }
.gate-edit input[type="text"] { margin-bottom: 0.25rem; }

/* ---- Billing ---- */
.usage > div { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.6rem; }
.meter { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 0.25rem; }
.meter-fill { height: 100%; background: var(--brand); border-radius: 4px; }
.meter-fill.ai { background: var(--ai); }

/* ---- Public pages ---- */
body.public { background: var(--paper); }
.public-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.9rem 1rem; max-width: 1100px; margin: 0 auto; }
.public-brand { font-weight: 800; font-size: 1.25rem; color: var(--ink); display: inline-flex; align-items: center; }
.public-nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.public-main { max-width: 1100px; margin: 0 auto; padding: 0 1rem 2rem; }
.public-footer { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; display: flex; gap: 1.25rem; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); }
.hero { padding: 2.5rem 0 1.5rem; display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: center; }
.hero h1 { font-size: 2.4rem; line-height: 1.12; letter-spacing: -0.02em; }
.hero .lead { font-size: 1.1rem; }
.hero-art { background: linear-gradient(135deg, #0f1f4d 0%, #1e3a8a 60%, #6d28d9 100%); border-radius: 20px; padding: 1.25rem; color: #fff; box-shadow: var(--shadow-2); }
.hero-art .mock { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 0.75rem; margin-bottom: 0.6rem; }
.hero-art .mock-row { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.85rem; margin: 0.25rem 0; }
.hero-art .mock-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.hero-art .mock-kpi { background: rgba(255,255,255,0.1); border-radius: 10px; padding: 0.5rem 0.6rem; }
.hero-art .mock-kpi b { display: block; font-size: 1.3rem; }
.hero-art .mock-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.2); position: relative; margin-top: 0.4rem; }
.hero-art .mock-bar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: #93c5fd; }
.three { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.three .card { margin-bottom: 0; }
.three .icon.lg { color: var(--brand); margin-bottom: 0.4rem; }
.rules ul { margin: 0; padding-left: 1.2rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 0.75rem 0; }
.plan { margin-bottom: 0; display: flex; flex-direction: column; }
.plan.featured { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.plan .price { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.plan ul { padding-left: 1.1rem; margin: 0 0 0.75rem; }
.plan .button { margin-top: auto; align-self: flex-start; }
.ai-section { background: linear-gradient(135deg, #faf7ff, #eef2ff); border-color: #ddd6fe; }
.join { margin: 1.5rem auto; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.document { max-width: 760px; margin: 1.5rem auto; }
.resend { margin-top: 0.75rem; }

/* ---- Phone ---- */
@media (max-width: 900px) {
    .overview-grid { grid-template-columns: 1fr; }
    .hero { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .split, .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .verdict-row, .exits { grid-template-columns: 1fr; }
    .map-band-grid { grid-template-columns: 1fr; }
    .bar-row { grid-template-columns: 5rem 1fr 5rem; }
    .map-column { flex-basis: 260px; }
    .map-panel { width: 100%; }
    .cards, .inbox-cards { grid-template-columns: 1fr; }
    .card-project-facts { grid-template-columns: 1fr; }
    .tiles { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; }
    .shell { flex-direction: column; }
    .sidebar { width: 100%; padding: 0.6rem 0.9rem; gap: 0.5rem; }
    .brand { margin-bottom: 0; }
    .nav-toggle { display: inline-block; }
    .nav, .nav-section, .sidebar-foot { display: none; }
    .sidebar.open .nav, .sidebar.open .nav-section { display: block; }
    .content { padding: 1rem; }
    .topbar { padding: 0.6rem 1rem; position: static; }
    .topbar-user { border-left: none; padding-left: 0; }
    .banners { padding: 0 1rem; }
    .toasts { left: 1rem; right: 1rem; max-width: none; }
    table.settings td.setting-key { width: auto; }
    .setting-form { flex-direction: column; }
    .setting-form input, .setting-form textarea, .setting-form button { width: 100%; }
    .inline-form { flex-direction: column; align-items: stretch; }
    .inline-form input { min-width: 0; }
    .kpi-value { font-size: 1.5rem; }
    .hero h1 { font-size: 1.7rem; }
    .public-header { flex-direction: column; align-items: flex-start; }
}

/* ---- Walkthrough ---- */
.tour-overlay { position: fixed; inset: 0; z-index: 60; }
.tour-overlay[hidden] { display: none; }
.tour-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55), 0 0 0 3px #93c5fd; transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease; pointer-events: none; }
.tour-spot[hidden] { display: block; top: 50%; left: 50%; width: 0; height: 0; box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55); }
.tour-card { position: fixed; width: 380px; max-width: calc(100vw - 32px); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 1.1rem 1.2rem; transition: top 0.25s ease, left 0.25s ease; }
.tour-card h3 { font-size: 1.05rem; margin: 0.2rem 0 0.4rem; }
.tour-card p { margin-bottom: 0.6rem; color: var(--ink-2); }
.tour-progress { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.tour-buttons { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }
.tour-spacer { flex: 1; }
body.tour-open { overflow: hidden; }
