:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2c2c2a;
  --hair: #2c2c2a;
  --axis: #383835;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --border: rgba(255, 255, 255, 0.1);
  /* The two people. Colour follows the person on both screens. */
  --onecrime: #3987e5;
  --decoder: #d95926;
  /* Status colours: always shown with an icon and a label. */
  --good: #0ca30c;
  --warn: #fab219;
  --crit: #e66767;
  --crit-fill: #d03b3b;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; margin-bottom: 8px; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
b { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }
.grow { flex: 1 1 auto; min-width: 0; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.icon { flex: none; vertical-align: -3px; }

.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
.narrow { max-width: 720px; }

/* ---------- shell ---------- */
.shell { display: flex; height: 100vh; }
.side {
  width: 212px; flex: none; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--hair); background: var(--page);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 18px; }
.logo { display: inline-grid; place-items: center; color: var(--ink); }
.nav {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--ink-2); text-align: left; cursor: pointer;
}
.nav:hover { background: var(--surface); color: var(--ink); }
.nav.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--ink); color: #0b0b0b;
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center;
}
.side-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--hair); }
.seat { display: flex; align-items: center; gap: 8px; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 28px;
  border-bottom: 1px solid var(--hair);
}
.content { flex: 1; overflow-y: auto; padding: 24px 28px 48px; }
.content > * { max-width: 1080px; }

/* ---------- pieces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.empty { color: var(--muted); padding: 22px 18px; text-align: center; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
section > h2 { margin-bottom: 10px; }
.lead { font-size: 15px; color: var(--ink-2); text-wrap: pretty; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--axis); background: var(--surface-2); color: var(--ink); font-weight: 550; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #0b0b0b; }
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn-danger { background: var(--crit-fill); border-color: var(--crit-fill); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc4a4a; }
.btn-ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-icon { padding: 6px; }
:focus-visible { outline: 2px solid var(--onecrime); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 5px 11px; border-radius: 6px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.segmented button:hover { color: var(--ink); }
.segmented button.on { background: var(--ink); color: #0b0b0b; font-weight: 600; }

.input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--axis); background: var(--page); color: var(--ink);
}
.input::placeholder { color: var(--muted); }
.input.num { width: 76px; }
.input.num-wide { min-width: 120px; }
.input.cur { width: 96px; flex: none; margin-right: 8px; }
textarea.input { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--muted); }
.inline { display: inline-flex; align-items: center; gap: 8px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap; }
.pill .icon { vertical-align: 0; }
.pill-good .icon { color: var(--good); }
.pill-warn .icon { color: var(--warn); }
.pill-crit .icon { color: var(--crit); }

.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; flex: none; }
.swatch-onecrime { background: var(--onecrime); }
.swatch-decoder { background: var(--decoder); }
.party { display: inline-flex; align-items: center; white-space: nowrap; color: var(--ink); }

.splitbar { display: inline-flex; align-items: center; gap: 7px; vertical-align: middle; }
.splitbar-track { display: inline-flex; width: 56px; height: 8px; gap: 2px; }
.seg { height: 100%; border-radius: 4px; min-width: 3px; }
.seg-onecrime { background: var(--onecrime); }
.seg-decoder { background: var(--decoder); }
.splitbar-text { font-variant-numeric: tabular-nums; color: var(--ink-2); }

.thumb { width: 96px; height: 54px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-3); }
.thumb-blank { display: grid; place-items: center; font-weight: 700; color: var(--muted); letter-spacing: 1px; }

.note { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2); }
.note .icon { margin-top: 2px; }
.note-crit .icon { color: var(--crit); }
.note-warn .icon { color: var(--warn); }
.note-good .icon { color: var(--good); }
.note.banner { align-items: center; margin-bottom: 18px; }
.note.banner > div { flex: 1; }

/* ---------- overview ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 22px 24px; flex-wrap: wrap; }
.hero-label { color: var(--ink-2); font-size: 15px; }
.hero-value { font-size: 52px; font-weight: 650; line-height: 1.1; letter-spacing: -0.5px; margin: 2px 0 8px; }
.hero-sub { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.tile-label { color: var(--ink-2); font-size: 13px; }
.tile-value { font-size: 24px; font-weight: 650; margin: 2px 0; }
.tile-sub { font-size: 12px; }

/* ---------- chart ---------- */
.chart { padding-top: 4px; }
.legend { display: flex; gap: 18px; margin-bottom: 14px; color: var(--ink-2); font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; }
.plot-wrap { display: flex; gap: 8px; }
.yaxis { position: relative; width: 48px; flex: none; }
.yaxis span { position: absolute; right: 0; transform: translateY(50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plot { position: relative; flex: 1; min-width: 0; }
.grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--hair); }
.grid-base { background: var(--axis); }
.cols { position: absolute; inset: 0; display: flex; }
.col { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; border: 0; padding: 0; background: none; cursor: default; border-radius: 4px; }
.col-on { background: rgba(255, 255, 255, 0.04); }
.col .stack { display: flex; flex-direction: column; gap: 2px; width: min(24px, 60%); }
.bar { display: block; width: 100%; }
.bar-top { border-radius: 4px 4px 0 0; }
.bar-onecrime { background: var(--onecrime); }
.bar-decoder { background: var(--decoder); }
.xaxis { display: flex; margin-left: 56px; margin-top: 6px; }
.xaxis span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.xaxis span.open { font-style: italic; }
.chart-foot { font-size: 12px; margin-top: 10px; }
.tip {
  position: absolute; top: 4px; z-index: 2; pointer-events: none; min-width: 190px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.tip-title { font-weight: 650; margin-bottom: 4px; }
.tip-row { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; color: var(--ink-2); }
.tip-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tip-total { border-top: 1px solid var(--axis); margin-top: 5px; padding-top: 5px; }

/* ---------- proposals and videos ---------- */
.prop { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.prop-main { display: flex; gap: 12px; align-items: center; min-width: 0; }
.prop-title { font-weight: 600; }
.prop-meta { color: var(--ink-2); font-size: 13px; }
.prop-side { display: flex; gap: 8px; align-items: center; }
.prop-foot { grid-column: 1 / -1; }
.prop-details { margin-top: 6px; }
.prop-details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.prop-details .table { margin-top: 8px; }

.video-main { display: flex; gap: 14px; align-items: center; }
.video-title { font-weight: 600; }
.video-nums { display: flex; gap: 22px; flex: none; }
.video-nums div { display: flex; flex-direction: column; align-items: flex-end; }
.video-nums b { font-size: 15px; }
.video-foot { display: flex; align-items: center; gap: 8px; margin: 10px -6px -4px; }
.video .table { margin-top: 10px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
.table th.r { text-align: right; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.table td.r { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--axis); border-bottom: 0; }
.money { cursor: default; }

.statement summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; }
.statement[open] summary { margin-bottom: 10px; }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--hair); }
.kv span { color: var(--ink-2); }
.kv b { text-align: right; overflow-wrap: anywhere; }
.card > .row, .card > .kv + p { margin-top: 12px; }
.card > p + .row, .card > p { margin-bottom: 10px; }
.privacy { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; color: var(--ink-2); font-size: 13px; }
.privacy li { display: flex; gap: 9px; align-items: flex-start; }
.privacy .icon { margin-top: 2px; color: var(--muted); }
.demo-chip { padding: 3px 10px; border-radius: 20px; border: 1px dashed var(--muted); color: var(--ink-2); font-size: 12px; font-weight: 600; }

/* ---------- dialogs ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.62); display: grid; place-items: center; padding: 24px; z-index: 20; }
.modal { width: min(540px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); }
.modal-wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--hair); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--hair); }
.foot-hint { margin-right: auto; font-size: 12px; }
.summary { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); }
.summary b { color: var(--ink); }
.splitpicker { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

.picker { display: flex; flex-direction: column; gap: 8px; }
.picker-list { max-height: 232px; overflow-y: auto; border: 1px solid var(--hair); border-radius: 8px; }
.picker-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--hair); background: none; text-align: left; cursor: pointer; }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover:not(:disabled) { background: var(--surface-2); }
.picker-item.on { background: var(--surface-3); }
.picker-item:disabled { opacity: 0.45; cursor: default; }
.picker-item .thumb, .picked .thumb { width: 64px; height: 36px; font-size: 11px; }
.picker-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item .grow, .picked .grow { display: flex; flex-direction: column; }
.picked { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }

/* ---------- welcome / sign in ---------- */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.welcome { width: min(600px, 100%); display: flex; flex-direction: column; gap: 16px; }
.brand-big { display: flex; align-items: center; gap: 12px; }
.brand-big h1 { font-size: 28px; }
.welcome .card { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.welcome .card > * { max-width: 100%; }
.welcome .card .row, .welcome .card .stack, .welcome .card .field, .welcome form .field { width: 100%; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast { display: flex; align-items: center; gap: 9px; max-width: 420px; padding: 10px 14px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.toast-good .icon { color: var(--good); }
.toast-crit .icon { color: var(--crit); }

.spin { display: inline-flex; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

@media (max-width: 980px) {
  .video-main { flex-wrap: wrap; }
  .video-nums { width: 100%; justify-content: flex-start; }
  .video-nums div { align-items: flex-start; }
  .top { flex-wrap: wrap; }
}

/* small alignment fixes */
.party .muted { margin-left: 4px; }
.modal-body > .segmented { align-self: flex-start; }

/* per-collab summary */
.collab-sum-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.collab-sum-nums { display: flex; gap: 28px; flex-wrap: wrap; }
.collab-sum-nums div { display: flex; flex-direction: column; }
.collab-sum-nums b { font-size: 15px; }
.collab-sum .table { margin-top: 12px; }

/* invoices */
.inv-amount { flex: none; width: 140px; }
.modal-body .inv-paper { border: 1px solid var(--border); }

.inv-search { width: 230px; }
.inv-lines-head { display: flex; gap: 10px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 2px; }
.inv-qty { width: 72px; flex: none; }
.inv-rate { width: 116px; flex: none; }
.inv-amt { width: 100px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.inv-x { width: 30px; flex: none; }
.inv-lines-head .inv-qty, .inv-lines-head .inv-rate { padding-left: 2px; }
.inv-totals { align-self: flex-end; width: min(380px, 100%); display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.inv-totals > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.inv-totals b { color: var(--ink); font-variant-numeric: tabular-nums; }
.inv-totals-total { border-top: 1px solid var(--axis); padding-top: 6px; font-size: 16px; }
.inv-disc-type { width: 62px; flex: none; }
.saved-items { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-radius: 8px; border: 1px solid var(--hair); }
.saved-item { display: inline-flex; align-items: stretch; border-radius: 20px; border: 1px solid var(--axis); background: var(--surface-2); overflow: hidden; }
.saved-item button { border: 0; background: none; color: var(--ink); padding: 4px 10px; cursor: pointer; font-size: 13px; }
.saved-item button:hover { background: var(--surface-3); }
.saved-item .saved-x { padding: 4px 8px 4px 6px; color: var(--muted); border-left: 1px solid var(--axis); }

.link { color: var(--ink-2); text-decoration: underline; }
.link:hover { color: var(--ink); }

/* ---------- phones and narrow windows (website) ---------- */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side { width: auto; flex-direction: row; align-items: center; gap: 2px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--hair); overflow-x: auto; }
  .brand { padding: 4px 8px 4px 4px; }
  .brand span:last-child { display: none; }
  .nav { width: auto; flex: none; padding: 8px 10px; white-space: nowrap; }
  .side-foot { display: none; }
  .top { padding: 10px 14px; }
  .top h1 { font-size: 18px; }
  .content { padding: 16px 14px 40px; }
  .card { overflow-x: auto; }
  .hero-value { font-size: 40px; }
  .prop { grid-template-columns: 1fr; }
  .modal-body .row.gap { flex-wrap: wrap; }
  .overlay { padding: 10px; }
}
@media (max-width: 760px) {
  .top > .row { flex-wrap: wrap; }
  .top .segmented { flex-wrap: nowrap; }
}

/* per-video metrics strip */
.video-metrics { display: flex; flex-wrap: wrap; gap: 6px 26px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--hair); }
.video-metrics div { display: flex; flex-direction: column; min-width: 64px; }
.video-metrics b { font-size: 14px; font-variant-numeric: tabular-nums; }
.video .table { display: block; overflow-x: auto; white-space: nowrap; }
