
/* Layout: sticky top bar with section tabs; one centered column (max 1180px) of ledger-style panels; deal pages as a fact sheet + history */
:root {
  --paper: #F5F6F2; --panel: #FFFFFF; --ink: #17221E; --muted: #5D6A64; --line: #DCE1DC;
  --accent: #1D6B57; --accent-ink: #FFFFFF; --accent-soft: #E2EEE9; --brass: #946519;
  --ok: #2B7A4B; --warn: #9A6200; --bad: #B3261E; --chip: #EEF1ED;
  --f-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #0F1513; --panel: #151D1A; --ink: #E4EBE7; --muted: #92A29B; --line: #263430;
  --accent: #62BB9F; --accent-ink: #0B1411; --accent-soft: #1A2C26; --brass: #D3A45C;
  --ok: #6FCB8F; --warn: #E3A848; --bad: #F2766C; --chip: #1C2622; color-scheme: dark; } }
:root[data-theme="dark"] {
  --paper: #0F1513; --panel: #151D1A; --ink: #E4EBE7; --muted: #92A29B; --line: #263430;
  --accent: #62BB9F; --accent-ink: #0B1411; --accent-soft: #1A2C26; --brass: #D3A45C;
  --ok: #6FCB8F; --warn: #E3A848; --bad: #F2766C; --chip: #1C2622; color-scheme: dark; }

body { background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--panel); }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.n, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); font-size: 0.86em; }

.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
.bar-in { max-width: 1180px; margin-inline: auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-block: 10px; }
.brand { display: flex; align-items: baseline; gap: 8px; font-family: var(--f-display); font-size: 19px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.brand small { font-family: var(--f-body); font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: var(--r); font-weight: 500; font-size: 14px; }
nav a:hover { color: var(--ink); background: var(--chip); }
nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 7px 12px; cursor: pointer; font-weight: 500; font-size: 14px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; }

main { max-width: 1180px; margin-inline: auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 28px 64px; }
section[data-view] { display: grid; gap: 22px; }
h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(26px, 4vw, 34px); line-height: 1.15; margin: 0; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.lede b { color: var(--ink); font-weight: 600; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.note { font-size: 12.5px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.kpi { padding: 16px 18px; border-right: 1px solid var(--line); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi .v { font-family: var(--f-display); font-size: 32px; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-family: var(--f-body); font-size: 13px; color: var(--muted); margin-left: 3px; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
@media (max-width: 700px) { .kpi { border-right: 0; border-bottom: 1px solid var(--line); } .kpi:last-child { border-bottom: 0; } }

.stages { display: grid; gap: 8px; }
.stage-row { display: grid; grid-template-columns: 8.5rem 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.stage-row .track { height: 14px; background: var(--chip); border-radius: 3px; overflow: hidden; }
.stage-row .fill { height: 100%; background: var(--accent); border-radius: 3px; min-width: 0; }
.stage-row .lbl { color: var(--muted); }
.stage-row .val { font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 7.5rem; text-align: right; }

.list { display: grid; }
.item { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item .t { font-weight: 500; }
.item a { color: inherit; }
.meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.empty { color: var(--muted); font-size: 13.5px; padding: 6px 0; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--chip); color: var(--ink); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); } .pill.acc { color: var(--accent); }
.pill.plain::before { display: none; }

.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chipbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 11px; font-size: 13px; cursor: pointer; color: var(--muted); }
.chipbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }
input[type=search], input[type=text], input[type=number], input[type=date], select, textarea {
  border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 7px 10px; font-size: 14px; width: 100%; min-width: 0; }
textarea { min-height: 96px; resize: vertical; }
.tools input[type=search] { width: min(100%, 18rem); }

.tbox { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--accent); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--chip); }
td .co { font-weight: 500; }
td .sub { font-size: 12px; color: var(--muted); }
@media (max-width: 720px) { .hn { display: none; } }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.fact { background: var(--panel); padding: 12px 14px; min-width: 0; }
.fact .k { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.fact .v { margin-top: 3px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fact .v.big { font-family: var(--f-display); font-size: 22px; }
.back { color: var(--muted); text-decoration: none; font-size: 13.5px; }
.back:hover { color: var(--ink); }
.dealhead { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-end; }

.task { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.task.done .tt { color: var(--muted); text-decoration: line-through; }

.feed { display: grid; }
.post { display: grid; grid-template-columns: 2.25rem 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.post:first-child { border-top: 0; padding-top: 0; }
.av { width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.post .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.post .chg { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.daysep { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 14px 0 6px; border-top: 1px solid var(--line); }
.daysep:first-child { border-top: 0; padding-top: 0; }

form.compose { display: grid; gap: 12px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: 12px; }
label.f { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
details.more summary { cursor: pointer; font-size: 13.5px; color: var(--accent); font-weight: 500; }
details.more[open] summary { margin-bottom: 10px; }
.formfoot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.status { font-size: 13px; color: var(--muted); }
.status.err { color: var(--bad); }

.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 16px; }
.person .top { display: flex; gap: 12px; align-items: center; }
.person .nm { font-weight: 600; }
.person .rl { font-size: 12.5px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: 8px; margin: 14px 0 10px; }
.stat .v { font-family: var(--f-display); font-size: 22px; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat.bad .v { color: var(--bad); }
.person ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13.5px; }
.person li a { color: inherit; }
.loadline { color: var(--muted); font-size: 13.5px; padding: 40px 0; text-align: center; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: var(--r); font-size: 14px; z-index: 20; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
