:root {
  --blue: #2F4FD4;
  --blue-deep: #1E35A3;
  --blue-wash: #EEF1FC;
  --ink: #161B3D;
  --muted: #5A6283;
  --line: #DDE3F4;
  --bg: #F7F8FD;
  --surface: #FFFFFF;
  --good: #13744F;
  --warn: #965A00;
  --bad: #B52A2A;
  --info: #2F4FD4;
  --good-wash: #E8F5EF; --warn-wash: #FDF3E1; --bad-wash: #FBEAEA; --ink-wash: #ECEEF5; --muted-wash: #F1F2F7;
  --th: #FAFBFE; --col: #EEF1FA; --field-line: #C9D1EC; --grid: #E9ECF7; --axis: #B9C1DE; --win: #FFFBF2; --cal-item: #FBFCFF;
  --side-bg: var(--blue); --tone-muted: #A3AAC4; --on-accent: #FFFFFF; --tip-bg: #161B3D; --tip-ink: #FFFFFF;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --display: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  --body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-panel: 12px;
  --r-control: 7px;
  --side: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* component display rules must not un-hide hidden elements */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--body); font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; margin-top: 1.6em; }
h3 { font-size: 1.02rem; font-weight: 500; }
p { margin: 0 0 .75em; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lede { color: var(--muted); max-width: 68ch; }
.loading { padding: 40px; color: var(--muted); }
.error { color: var(--bad); }

/* Dark mode: same roles, steps chosen for the dark surface. System default, overridable via the sidebar toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --blue: #7C93F2; --blue-deep: #A3B3F7; --blue-wash: #1E2650; --ink: #E7E9F5; --muted: #A2A9C6; --line: #2B3258;
  --bg: #0E1128; --surface: #161A36; --good: #4CC98F; --warn: #E9B44C; --bad: #F08080; --info: #7C93F2;
  --good-wash: #12312A; --warn-wash: #352A12; --bad-wash: #3A1A22; --ink-wash: #232846; --muted-wash: #1C2040;
  --th: #1A1F3E; --col: #121631; --field-line: #3A4270; --grid: #252B4D; --axis: #48507C; --win: #2A2614; --cal-item: #1A1F3E;
  --side-bg: #1E35A3; --tone-muted: #5E6690; --on-accent: #0E1128; --tip-bg: #E7E9F5; --tip-ink: #0E1128;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --blue: #7C93F2; --blue-deep: #A3B3F7; --blue-wash: #1E2650; --ink: #E7E9F5; --muted: #A2A9C6; --line: #2B3258;
  --bg: #0E1128; --surface: #161A36; --good: #4CC98F; --warn: #E9B44C; --bad: #F08080; --info: #7C93F2;
  --good-wash: #12312A; --warn-wash: #352A12; --bad-wash: #3A1A22; --ink-wash: #232846; --muted-wash: #1C2040;
  --th: #1A1F3E; --col: #121631; --field-line: #3A4270; --grid: #252B4D; --axis: #48507C; --win: #2A2614; --cal-item: #1A1F3E;
  --side-bg: #1E35A3; --tone-muted: #5E6690; --on-accent: #0E1128; --tip-bg: #E7E9F5; --tip-ink: #0E1128;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
#sidebar {
  background: var(--side-bg); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
#main { padding: 28px clamp(16px, 3.5vw, 48px) 64px; outline: none; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; margin: 0 6px 22px; }
.brand b { font: 700 1.3rem/1 var(--display); display: block; letter-spacing: -.02em; }
.brand small { font-size: .78rem; opacity: .8; }
.mark { width: 34px; height: 34px; border-radius: 9px; background: url(/favicon.svg) center/cover; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .55); flex: none; }
.brand-ink { color: var(--ink); margin: 0; }
.brand-ink .mark { box-shadow: none; }

.side-link, .client-list a {
  display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
  padding: 8px 10px; border-radius: var(--r-control); font-weight: 500;
}
.side-link:hover, .client-list a:hover { background: rgba(255, 255, 255, .12); }
.side-link[aria-current], .client-list a[aria-current] { background: #fff; color: #1E35A3; }
.side-heading { margin: 18px 10px 4px; font-size: .82rem; opacity: .75; }
.client-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.client-list .flag { margin-left: auto; font-size: .7rem; color: #FFD3D3; }
.client-list a[aria-current] .flag { color: var(--bad); }
.badge { margin-left: auto; background: #fff; color: #1E35A3; border-radius: 999px; font-size: .75rem; padding: 0 8px; font-weight: 600; }
.side-link[aria-current] .badge { background: #1E35A3; color: #fff; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }
.client-switch { display: none; }

/* ---------- page parts ---------- */
.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.page > h2:first-child, .page > section > h2:first-child { margin-top: .4em; }
.page-head h1 { margin-bottom: .2em; }
.client-head { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: start; margin-bottom: 20px; }
.client-title h1 { margin-bottom: .1em; }
.client-title p { color: var(--muted); margin-bottom: .5em; }
.tabs { grid-column: 1 / -1; display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { color: var(--blue); border-bottom-color: var(--blue); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 18px 20px; min-width: 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.split-wide { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar > h2, .toolbar > p { margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }

/* ---------- controls ---------- */
.btn {
  font: 600 .9rem/1 var(--body); padding: 10px 14px; border-radius: var(--r-control); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 40px;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--on-accent); }
.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); color: var(--on-accent); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-small { min-height: 32px; padding: 6px 10px; font-size: .82rem; }
.field { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 500; min-width: 0; }
input, select, textarea {
  font: 400 .95rem/1.4 var(--body); color: var(--ink); background: var(--surface);
  border: 1px solid var(--field-line); border-radius: var(--r-control); padding: 8px 10px; min-height: 40px; width: 100%;
}
textarea { resize: vertical; }
textarea.code { font: .82rem/1.5 ui-monospace, 'SF Mono', Menlo, monospace; background: var(--bg); }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid var(--blue-wash); }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.inline-form .field { flex: 1 1 180px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filters .field { flex: 0 1 190px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.segmented button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; font: 500 .88rem var(--body); color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--blue); color: var(--on-accent); }
.checks { border: 0; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks legend { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.checks label { display: flex; gap: 6px; align-items: center; }
.checks input { width: auto; min-height: 0; }

.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; white-space: nowrap; border: 1px solid currentColor; }
.chip.small { font-size: .72rem; padding: 0 8px; margin-left: 8px; }
.chip-good { color: var(--good); background: var(--good-wash); }
.chip-warn { color: var(--warn); background: var(--warn-wash); }
.chip-bad { color: var(--bad); background: var(--bad-wash); }
.chip-info { color: var(--info); background: var(--blue-wash); }
.chip-ink { color: var(--ink); background: var(--ink-wash); }
.chip-muted { color: var(--muted); background: var(--muted-wash); border-style: dashed; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .82rem; background: var(--th); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.client-cell { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); text-decoration: none; }
.client-cell .dot { box-shadow: none; }
.clients-table tbody tr:hover { background: var(--blue-wash); }
tr.is-win td { background: var(--win); }
.panel .table-wrap { border-radius: 8px; }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.kpis div { padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.kpis dt { font-size: .82rem; color: var(--muted); }
.kpis dd { margin: 2px 0 0; font: 700 1.3rem/1.2 var(--display); white-space: nowrap; }
.source { font-size: .8rem; color: var(--muted); margin: 8px 0 0; padding-left: 10px; border-left: 2px solid var(--line); }

/* ---------- budget runway: the one bold element ---------- */
.runway-sentence { font-size: 1.02rem; max-width: 52ch; }
.runway { margin: 8px 0 16px; }
.runway-track { position: relative; height: 26px; background: var(--blue-wash); border-radius: 6px; }
.runway-used, .runway-proj { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; }
.runway-proj { background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(47, 79, 212, .28) 5px 8px); }
.runway-proj.tone-over { background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(181, 42, 42, .35) 5px 8px); }
.runway-proj.tone-under { background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(150, 90, 0, .32) 5px 8px); }
.runway-used { background: var(--blue); z-index: 1; }
.runway-budget, .runway-threshold { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--ink); z-index: 2; }
.runway-threshold { background: none; border-left: 2px dashed var(--bad); }
.runway-scale { position: relative; height: 22px; font-size: .78rem; color: var(--muted); }
.runway-scale span { position: absolute; transform: translateX(-50%); top: 6px; white-space: nowrap; }
.tone-over { color: var(--bad); }
.tone-under { color: var(--warn); }
.mini-runway { position: relative; width: 140px; height: 8px; background: var(--blue-wash); border-radius: 4px; }
.mini-used { position: absolute; inset: 0 auto 0 0; background: var(--blue); border-radius: 4px; }
.mini-budget { position: absolute; left: 80%; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.mini-proj { position: absolute; top: -5px; width: 2px; height: 18px; background: var(--muted); transform: translateX(-1px); }
.mini-proj.tone-over { background: var(--bad); }
.mini-proj.tone-under { background: var(--warn); }

/* ---------- alerts & feed ---------- */
.alerts { display: grid; gap: 8px; }
.alert { display: block; padding: 10px 14px; border-radius: 8px; text-decoration: none; color: var(--ink); border-left: 4px solid; background: var(--surface); }
.alert-bad { border-color: var(--bad); }
.alert-warn { border-color: var(--warn); }
.alert b { margin-right: 4px; }
.feed { list-style: none; margin: 0 0 12px; padding: 0; display: grid; }
.feed li { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li.unread span { font-weight: 600; }
.feed time { font-size: .78rem; color: var(--muted); }

/* ---------- charts ---------- */
.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 16px 18px; min-width: 0; }
.chart figcaption { font: 500 1rem var(--display); margin-bottom: 6px; }
.chart-plot { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--grid); }
.chart-svg .axis { stroke: var(--axis); }
.chart-svg .tick { font: 11px var(--body); fill: var(--muted); }
.chart-svg .crosshair { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart-tip { position: absolute; top: 8px; min-width: 170px; background: var(--tip-bg); color: var(--tip-ink); border-radius: 8px; padding: 8px 10px; font-size: .8rem; pointer-events: none; }
.chart-tip strong { display: block; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row b { margin-left: auto; padding-left: 12px; }
.tip-row i, .legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0; margin: 0 0 6px; font-size: .82rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.chart-table summary { cursor: pointer; font-size: .82rem; color: var(--blue); margin-top: 6px; }
.chart-table .table-wrap { max-height: 260px; margin-top: 8px; }
.hero-num { font: 700 3.4rem/1 var(--display); color: var(--blue); margin: 4px 0 6px; letter-spacing: -.03em; }

/* ---------- kanban ---------- */
.kanban, .table-wrap, .timeline, .chat { position: relative; } /* keeps .sr-only labels inside the scroll container */
.kanban { display: grid; grid-template-columns: repeat(var(--cols), minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.kanban-col { background: var(--col); border-radius: var(--r-panel); padding: 12px; display: grid; gap: 8px; align-content: start; min-height: 140px; }
.kanban-col h3 { display: flex; justify-content: space-between; margin: 0 2px 4px; font-size: .92rem; }
.count { color: var(--muted); font-family: var(--body); }
.task { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.task-title { font-weight: 600; margin-bottom: 2px; }
.task-meta { font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.task-move select { min-height: 32px; padding: 4px 8px; font-size: .82rem; }

/* ---------- calendar ---------- */
.cal-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-bar h2 { margin: 0; min-width: 11ch; text-align: center; }
.status-counts { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 0 auto; padding: 0; font-size: .85rem; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.cal-head { font-size: .8rem; color: var(--muted); padding: 0 4px; }
.cal-day { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day.is-today { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.cal-date { font-size: .78rem; color: var(--muted); }
.cal-day.is-today .cal-date { color: var(--blue); font-weight: 700; }
.cal-item { text-align: left; font: inherit; font-size: .78rem; border: 1px solid var(--line); border-left: 4px solid; border-radius: 6px; background: var(--cal-item); padding: 4px 6px; cursor: pointer; display: grid; color: var(--ink); min-width: 0; }
.cal-item:hover { background: var(--blue-wash); }
.cal-channel { font-weight: 600; }
.cal-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-meta { color: var(--muted); }
.tone-border-muted { border-left-color: var(--tone-muted); }
.tone-border-bad { border-left-color: var(--bad); }
.tone-border-warn { border-left-color: var(--warn); }
.tone-border-good { border-left-color: var(--good); }
.tone-border-info { border-left-color: var(--blue); }
.tone-border-ink { border-left-color: var(--ink); }

/* ---------- dialog & comments ---------- */
.dialog { border: 0; border-radius: var(--r-panel); padding: 22px; background: var(--surface); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); display: grid; gap: 18px; color: var(--ink); }
.dialog:not([open]) { display: none; }
.dialog::backdrop { background: rgba(22, 27, 61, .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.dialog-head h2 { margin: 0; }
.comments { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.comments li { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: .9rem; }
.comments p { margin: 2px 0 0; }

/* ---------- report ---------- */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: clamp(18px, 4vw, 40px); display: grid; gap: 22px; }
.report-head { display: flex; gap: 24px; align-items: center; border-bottom: 3px solid var(--blue); padding-bottom: 18px; flex-wrap: wrap; }
.report-head h2 { margin: 0 0 4px; font-size: 1.6rem; }
.narrative { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; max-width: 75ch; }

/* ---------- portal ---------- */
body.is-portal .shell { display: block; }
.portal { max-width: 960px; margin: 0 auto; padding: 0 16px 64px; outline: none; }
.portal-head { background: #2F4FD4; color: #fff; margin: 0 -16px 8px; padding: 28px 24px 30px; border-radius: 0 0 18px 18px; }
.portal-head .brand { margin: 0 0 22px; }
.portal-head h1 { font-size: 2.3rem; margin-bottom: .15em; }
.portal-head p { opacity: .9; margin: 0; }
.portal > section { margin-top: 10px; display: grid; gap: 14px; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.review-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 16px; display: grid; gap: 10px; align-content: start; }
.review-card header { display: flex; justify-content: space-between; gap: 8px; }
.review-caption { font-size: 1.05rem; margin: 0; }
.upcoming, .task-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.upcoming li { display: grid; grid-template-columns: 9rem 6rem 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.task-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.upcoming li:last-child, .task-list li:last-child { border-bottom: 0; }
.progress { height: 12px; background: var(--blue-wash); border-radius: 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--blue); }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--tip-bg); color: var(--tip-ink); padding: 10px 16px; border-radius: 8px; z-index: 100; font-weight: 500; max-width: calc(100vw - 32px); border-left: 4px solid var(--good); }
.toast-bad { border-left-color: #FF8A8A; }

/* ---------- auth & account ---------- */
body.is-login .shell { display: block; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--blue) 0 38%, var(--bg) 38%); outline: none; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(420px, 100%); display: grid; gap: 14px; }
.login-card h1 { font-size: 1.5rem; margin: 6px 0 0; }
.side-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 8px; }
.side-user { color: #fff; text-decoration: none; display: grid; padding: 6px 10px; border-radius: var(--r-control); }
.side-user:hover { background: rgba(255, 255, 255, .12); }
.side-user small { opacity: .8; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }
.btn-ghost:hover { color: #fff; border-color: #fff; background: rgba(255, 255, 255, .12); }
.narrow { max-width: 760px; }
.secret { font: .9rem/1.5 ui-monospace, 'SF Mono', Menlo, monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.steps { padding-left: 1.2em; display: grid; gap: 8px; margin: 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; min-height: 40px; }
.check input { width: auto; min-height: 0; }
tr.is-inactive td { color: var(--muted); }
.table-wrap input, .table-wrap select { min-height: 34px; padding: 4px 8px; min-width: 110px; }
.audit { max-height: 420px; }
.mark-initial { background: var(--blue); display: grid; place-items: center; color: #fff; font: 700 1.1rem var(--display); }
.agency-logo { max-height: 44px; max-width: 180px; object-fit: contain; }
.brand-preview { padding: 14px; border: 1px dashed var(--line); border-radius: 8px; margin-bottom: 12px; }
.portal-head .brand-ink { color: #fff; }
.portal-head .mark-initial { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .75); }
.stack > .btn { justify-self: start; }
.source + h3, .source + form, .source + section { margin-top: 18px; }

/* ---------- onboarding ---------- */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 18px; }
.checklist li { display: flex; gap: 10px; align-items: baseline; }
.checklist li > span:first-child { color: var(--blue); font-weight: 700; }
.checklist li.is-done { color: var(--muted); text-decoration: line-through; }
.checklist li.is-done > span:first-child { color: var(--good); }

/* ---------- tasks, timeline, leads ---------- */
.task-notes { font-size: .82rem; color: var(--muted); white-space: pre-wrap; margin-bottom: 4px; }
.task-actions { display: flex; gap: 6px; align-items: center; }
.task-actions .task-move { flex: 1; }
.timeline { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 14px 16px; overflow-x: auto; }
.tl-list { list-style: none; margin: 0; padding: 0; }
.tl-row { display: grid; grid-template-columns: minmax(180px, 260px) minmax(420px, 1fr); gap: 14px; align-items: center; min-height: 40px; border-bottom: 1px solid var(--line); }
.tl-list .tl-row:last-child { border-bottom: 0; }
.tl-label { font-size: .88rem; font-weight: 600; display: grid; }
.tl-label small { font-weight: 400; color: var(--muted); }
.tl-track { position: relative; height: 100%; min-height: 30px; }
.tl-axis { min-height: 28px; }
.tl-tick { position: absolute; top: 6px; font-size: .75rem; color: var(--muted); border-left: 1px solid var(--line); padding-left: 4px; height: 100%; white-space: nowrap; }
.tl-today { position: absolute; top: 0; font-size: .72rem; color: var(--bad); height: 100%; white-space: nowrap; border-right: 2px solid var(--bad); padding-right: 4px; transform: translateX(-100%); background: var(--surface); }
.tl-bar { position: absolute; top: 9px; height: 14px; border-radius: 4px; background: var(--blue); }
.tl-bar.is-done { background: var(--tone-muted); }
.tl-bar.is-late { background: repeating-linear-gradient(135deg, var(--bad) 0 5px, transparent 5px 8px); border: 1.5px solid var(--bad); }
.kanban-leads { grid-template-columns: repeat(var(--cols), minmax(180px, 1fr)); }
.kanban-leads .task { border-left-width: 4px; border-left-style: solid; }
.tone-border-bad { border-left-color: var(--bad); }
.utm-out { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: .85rem; }
.utm-out code { word-break: break-all; background: var(--bg); padding: 6px 8px; border-radius: 6px; flex: 1 1 260px; }

/* ---------- social extras ---------- */
.approval-step { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.library details { border-bottom: 1px solid var(--line); padding: 6px 0; }
.library summary, .panel > details > summary { cursor: pointer; font-weight: 600; }
.library ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.library li { display: grid; gap: 6px; padding: 8px; background: var(--bg); border-radius: 8px; }
.library li p { margin: 2px 0 0; white-space: pre-wrap; }
.mention { color: var(--blue); }

/* ---------- chat ---------- */
.chat { list-style: none; margin: 0; padding: 14px; display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); max-height: 60vh; overflow-y: auto; }
.chat li { max-width: min(620px, 88%); background: var(--bg); border-radius: 10px; padding: 8px 12px; }
.chat li.mine { justify-self: end; background: var(--blue-wash); }
.chat header { display: flex; gap: 10px; align-items: baseline; font-size: .82rem; }
.chat time { color: var(--muted); }
.chat p { margin: 2px 0 0; white-space: pre-wrap; }
.chat-form { display: flex; gap: 10px; align-items: end; }
.chat-form textarea { flex: 1; }

/* ---------- SEO extras ---------- */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
tr.is-client td { background: var(--blue-wash); }
.hit { color: var(--good); font-weight: 600; white-space: nowrap; }
.miss { color: var(--muted); }

/* ---------- ops ---------- */
.meter { display: inline-block; width: 90px; height: 8px; background: var(--blue-wash); border-radius: 4px; vertical-align: middle; overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 4px; }
.tone-bg-good { background: var(--good); }
.tone-bg-warn { background: var(--warn); }
.tone-bg-bad { background: var(--bad); }
.tone-bg-muted { background: var(--tone-muted); }
tfoot th, tfoot td { border-top: 2px solid var(--line); border-bottom: 0; }
.timer-panel.is-running { border-color: var(--blue); box-shadow: inset 4px 0 0 var(--blue); }
.timer-panel .row { align-items: center; justify-content: space-between; }
.timer-panel p { margin: 0; }
.invoice table { border: 1px solid var(--line); }

/* ---------- wiki ---------- */
.wiki-grid { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 18px; align-items: start; }
.wiki-list { display: grid; gap: 10px; }
.wiki-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.wiki-list a:not(.btn) { display: grid; padding: 8px 10px; border-radius: var(--r-control); text-decoration: none; color: var(--ink); }
.wiki-list a:not(.btn):hover { background: var(--blue-wash); }
.wiki-list a[aria-current] { background: var(--blue-wash); box-shadow: inset 3px 0 0 var(--blue); }
.wiki-list small { color: var(--muted); }
.wiki textarea[name="body"] { font: .95rem/1.6 var(--body); }
.versions { margin: 10px 0 0; padding-left: 1.4em; display: grid; gap: 6px; font-size: .88rem; }
.versions li > * { vertical-align: middle; }
.versions .row { display: inline-flex; margin-left: 8px; }

/* ---------- delegation & task detail ---------- */
.side-search { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; padding: 8px 10px; border-radius: var(--r-control);
  border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .1); color: #fff; font: 500 .9rem var(--body); cursor: pointer; }
.side-search:hover { background: rgba(255, 255, 255, .18); }
kbd { font: .72rem ui-monospace, 'SF Mono', Menlo, monospace; padding: 1px 6px; border-radius: 4px; border: 1px solid currentColor; opacity: .8; }
.task-open { all: unset; cursor: pointer; font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.task-open:hover { text-decoration-color: currentColor; color: var(--blue); }
.task-open:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
.task-badges { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; }
.task-badges:empty { display: none; }
.task-badges .chip.small, .my-task-side .chip.small, td .chip.small { margin-left: 0; }
.task.is-blocked { border-style: dashed; }
.due { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.due.is-late { color: var(--bad); font-weight: 600; }
.callout { padding: 8px 12px; border-radius: 8px; background: var(--blue-wash); font-size: .9rem; }
.callout-warn { background: var(--warn-wash); color: var(--warn); }
.dialog-small { width: min(440px, calc(100vw - 32px)); }
.task-dialog { width: min(980px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; align-content: start; }
.task-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(240px, 1fr); gap: 22px; align-items: start; }
.task-grid h3 { margin: 0 0 8px; }
.task-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }
.task-fields .field:first-child, .task-fields .field:has(textarea), .task-fields .span-all { grid-column: 1 / -1; }
.panel-sub { background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.checklist-items, .files, .deps { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.checklist-items li, .deps li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.checklist-items .check { min-height: 32px; }
.is-done { text-decoration: line-through; color: var(--muted); }
.inline-form.compact { gap: 8px; flex-wrap: nowrap; }
.inline-form.compact input { min-height: 34px; }
.progress.small { height: 6px; margin-bottom: 6px; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 360px; overflow-y: auto; font-size: .85rem; }
.history li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; }
.history p { margin: 0; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { color: var(--bad); border-color: var(--bad); }
.btn.btn-danger:not(.btn-quiet) { background: var(--bad); border-color: var(--bad); color: #fff; }
label.btn { display: inline-flex; align-items: center; }
.comments time { margin-left: 6px; }
.milestone { color: var(--blue); }

/* My Tasks */
.my-tasks { list-style: none; margin: 0; padding: 0; display: grid; }
.my-task { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.my-task:last-child { border-bottom: 0; }
.my-task p { margin: 2px 0 0; }
.my-task-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.my-task.is-blocked .task-open { color: var(--muted); }
.bucket h3 { margin: 14px 0 2px; font-size: .9rem; }

/* Goals */
.goal { display: grid; gap: 12px; }
.goal > .btn { justify-self: start; }
.goal-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.goal-head h2 { margin: 0 0 4px; }
.goal-progress .progress { position: relative; overflow: visible; }
.goal-time { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.krs { list-style: none; margin: 0; padding: 0; display: grid; }
.kr { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.kr p { margin: 0; }
.kr-title { font-weight: 600; }
.kr-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kr-update { display: flex; gap: 6px; }
.kr-update input { width: 110px; min-height: 32px; }
.tone-bg-info { background: var(--blue); }

/* Automations, teams, search */
.rule { display: flex; justify-content: space-between; gap: 16px; align-items: start; flex-wrap: wrap; }
.rule h3 { margin: 0 0 4px; }
.rule p { margin: 0 0 4px; }
.rule.is-off { opacity: .65; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.member-pick { display: flex; justify-content: space-between; gap: 6px; padding: 4px 8px; background: var(--bg); border-radius: 6px; }
.member-pick label { display: flex; gap: 6px; align-items: center; }
.search-dialog { width: min(640px, calc(100vw - 24px)); align-self: start; margin-top: 10vh; gap: 10px; }
.search-box { display: flex; align-items: center; gap: 10px; }
.search-box input { font-size: 1.05rem; min-height: 46px; }
.search-box kbd { color: var(--muted); }
.search-results { max-height: 60vh; overflow-y: auto; display: grid; gap: 10px; }
.search-results h3 { font-size: .8rem; color: var(--muted); margin: 0 0 4px; }
.search-results ul { list-style: none; margin: 0; padding: 0; }
.search-results a { display: grid; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.search-results a:hover, .search-results a:focus { background: var(--blue-wash); outline: none; box-shadow: inset 3px 0 0 var(--blue); }
.search-results small { color: var(--muted); }
.asset-thumb { display: block; max-width: 100%; max-height: 140px; border-radius: 6px; margin: 6px 0; object-fit: cover; }
.tl-milestone { position: absolute; top: 8px; width: 14px; height: 14px; background: var(--blue); transform: translateX(-7px) rotate(45deg); border-radius: 2px; }
.tl-bar.is-blocked { outline: 2px dashed var(--warn); outline-offset: 1px; }

/* ---------- content preview & pins ---------- */
.content-dialog { width: min(760px, calc(100vw - 24px)); overflow-y: auto; }
.pv { margin: 0; max-width: 380px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.pv-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: .85rem; }
.pv-head small { margin-left: auto; color: var(--muted); }
.pv-avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--blue); color: var(--on-accent); font-weight: 700; font-size: .8rem; }
.pv-media { position: relative; background: var(--bg); overflow: hidden; }
.pv-media img, .pv-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-media.is-pickable { cursor: crosshair; }
.pv-media.is-pickable:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }
.pv-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .85rem; padding: 12px; text-align: center; }
.pv-caption { padding: 8px 10px 12px; font-size: .88rem; white-space: pre-wrap; }
.pv-tiktok { max-width: 260px; }
.pv-pin { position: absolute; transform: translate(-50%, -50%); width: 24px; height: 24px; border-radius: 50%; background: var(--bad); color: #fff; font: 700 .75rem/24px var(--body); text-align: center; box-shadow: 0 0 0 2px #fff; pointer-events: none; }
.pv-pin.static { position: static; transform: none; display: inline-block; flex: none; }
.small-pin { margin: 0 6px; width: 20px; height: 20px; line-height: 20px; }
.pin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pin-list li { display: flex; align-items: center; gap: 8px; }
.pin-form { display: flex; gap: 6px; flex-wrap: wrap; }
.pin-form input { flex: 1 1 200px; }

/* ---------- import, approvals, dashboard ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.import-result.is-done { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.approval { display: grid; gap: 10px; }
.approval.is-mine { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.approval h3 { margin: 0; font-size: 1.1rem; }
.pre { white-space: pre-wrap; margin: 0; }
.steps-track { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; font-size: .9rem; }
.steps-track .is-approved::marker { color: var(--good); }
.steps-track .is-rejected { color: var(--bad); }
.steps-track .is-pending b { color: var(--warn); }
.steps-track p { margin: 2px 0 0; }
.chain-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.chain-row legend { font-weight: 600; padding: 0 4px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 14px 16px; }
.tile dt { font-size: .82rem; color: var(--muted); }
.tile dd { margin: 4px 0 0; font: 700 1.6rem/1.1 var(--display); }
.tile p { margin: 4px 0 0; }
.tile.tone-over { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.tile.tone-under { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.plain-list li:last-child { border-bottom: 0; }

/* ---------- 2FA recovery & portal accounts ---------- */
.recovery { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.codes { columns: 2; padding-left: 1.4em; margin: 0 0 12px; font-size: 1.05rem; }
.codes code { font: 600 1rem ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: .05em; }
.portal-login { margin: 40px auto; }
.portal-who { margin-top: 10px !important; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  #sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  #sidebar .brand { margin: 0 auto 0 0; }
  #sidebar .side-link { padding: 6px 10px; }
  .side-heading, .client-list { display: none; }
  .side-search { margin: 0; }
  .client-switch { display: block; flex: 1 1 100%; }
  .client-switch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .client-switch select { background: var(--surface); }
  .side-foot { margin: 0; flex: 1 1 100%; flex-direction: row; justify-content: space-between; align-items: center; }
  .split-wide { grid-template-columns: 1fr; }
  .client-head { grid-template-columns: 1fr; }
  .wiki-grid { grid-template-columns: 1fr; }
  .task-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  h1 { font-size: 1.6rem; }
  .calendar { grid-template-columns: 1fr; }
  .cal-head, .cal-pad, .cal-day.is-empty { display: none; }
  .cal-day { min-height: 0; }
  .status-counts { margin-left: 0; }
  .upcoming li { grid-template-columns: 1fr auto; }
  .kpis dd { font-size: 1.2rem; }
  .chart-svg .tick { font-size: 18px; } /* svg units scale down with viewBox on narrow screens */
  .chat-form { flex-direction: column; align-items: stretch; }
  .tl-row { grid-template-columns: 140px minmax(360px, 1fr); }
  .task-fields { grid-template-columns: 1fr; }
  .chain-row { grid-template-columns: 1fr; }
  .my-task { flex-direction: column; }
  .my-task-side { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  body { background: #fff; }
  #sidebar, .client-head, .no-print, .skip, .chart-table, .toast { display: none !important; }
  :root { color-scheme: light; }
  .shell { display: block; }
  #main { padding: 0; }
  .report { border: 0; padding: 0; }
}
