:root {
  --paper: #F5F6F8; --field: #F0F2F5; --ink: #1F2A44; --ink-2: #3D4556; --muted: #6B7280; --faint: #9AA1AE;
  --rule: #D5D9E0; --rule-soft: #E6E9EE; --signal: #0F6E56; --signal-soft: #E1F5EE; --warn: #993C1D; --warn-soft: #FAECE7;
  --panel: #FFFFFF; --panel-border: #E3E6EB; --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.03); --radius: 10px;
  --white: #FFFFFF; --serif: 'Newsreader', Georgia, serif; --sans: 'IBM Plex Sans', system-ui, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --gutter: 18px; --max: 1180px;
}
@media (min-width: 900px) { :root { --gutter: 32px; } }
* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--signal-soft); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* type */
.disp { font-family: var(--serif); font-weight: 500; letter-spacing: -0.012em; line-height: 1.1; margin: 0; }
.h1 { font-size: 30px; } .h2 { font-size: 24px; } .h3 { font-size: 18px; line-height: 1.25; }
@media (min-width: 900px) { .h1 { font-size: 44px; } .h2 { font-size: 30px; } }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .tiny { font-size: 11px; }
.signal { color: var(--signal); } .warn { color: var(--warn); }
.lead { font-size: 15px; color: var(--ink-2); max-width: 62ch; }
.src { font-size: 11px; color: var(--muted); margin: 6px 0 0; }
.lnk { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; cursor: pointer; font-size: 13px; }
.lnk.small { font-size: 12px; }

/* layout */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px var(--gutter); background: var(--panel); border-bottom: 1px solid var(--panel-border); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }

.brand .disp { font-size: 18px; }
.nav { display: flex; gap: 14px; align-items: center; font-size: 13px; }
.nav a { text-decoration: none; color: var(--muted); padding: 4px 0; border-bottom: 1px solid transparent; }
.nav a.on { color: var(--ink); border-bottom-color: var(--ink); }
.nav .tenant { color: var(--muted); font-size: 12px; }
@media (max-width: 720px) { .nav .hide-m { display: none; } }
.page { width: 100%; max-width: var(--max); margin: 0 auto; padding: 22px var(--gutter) 60px; flex: 1; }
.cols { display: grid; gap: 28px; }
@media (min-width: 900px) { .cols { grid-template-columns: 5fr 7fr; gap: 48px; } .cols.rev { grid-template-columns: 7fr 5fr; } .cols.eq { grid-template-columns: 1fr 1fr; } .sticky { position: sticky; top: 20px; } }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.four { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 900px) { .four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sec { margin-top: 16px; }
/* panels: sections and cards become white panels on the grey canvas */
.page > .sec, .cols > div > .sec, .cols > div > .card, .page > .card, .card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.sec .sec { background: none; border: 0; box-shadow: none; padding: 0; margin-top: 18px; }
.cols > div > .sec:first-child, .cols > div > .card:first-child { margin-top: 0; }
.cols > div > .eyebrow + .ledger, .cols > div > .ledger:first-child { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 20px 10px; }
.cols > div > .eyebrow:first-child { padding: 0 2px; }
.tblwrap { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 20px 8px; overflow-x: auto; }
.four > .fig, .two > .fig { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border-top: 1px solid var(--panel-border); }
.four > .fig .eyebrow, .two > .fig .eyebrow { margin-bottom: 8px; }
hr.rule { border: 0; border-top: 0.5px solid var(--rule); margin: 24px 0; }

/* stage stamps */
.stamps { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 18px; }
.stamp { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--ink); border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.04em; color: var(--ink); text-decoration: none; }
.stamp b { font-family: var(--mono); font-weight: 500; }
.stamp.on { background: var(--ink); color: var(--paper); }
.stamp.off { color: var(--faint); border-color: var(--rule); }

/* figures */
.fig { border-top: 1px solid var(--rule); padding-top: 8px; }
.fig .n { font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1; }
.fig .n.mono { font-family: var(--mono); font-weight: 500; }

/* ledger rows */
.ledger { border-top: 1px solid var(--rule); }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 0.5px solid var(--rule-soft); }
.row .r { white-space: nowrap; }

/* table */
.tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tbl th { text-align: left; font-weight: 500; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px 6px 8px 0; border-bottom: 1px solid var(--rule); }
.tbl td { padding: 8px 6px 8px 0; border-bottom: 0.5px solid var(--rule-soft); vertical-align: middle; height: 46px; }
.tbl tr.sel td { background: var(--field); }
.tbl .nm { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl .sg { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl tr[data-id] { cursor: pointer; }
.tbl tr[data-id]:hover td { background: var(--field); }
.chk { width: 14px; height: 14px; accent-color: var(--ink); margin: 0; }

/* controls */
.btn { font-family: var(--sans); font-size: 13px; border: 1px solid var(--ink); border-radius: 6px; background: transparent; color: var(--ink); padding: 9px 14px; cursor: pointer; }
.btn.pri { background: var(--signal); border-color: var(--signal); color: var(--paper); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.actions { display: flex; gap: 8px; margin-top: 20px; align-items: center; }
.actions .btn { flex: 1; }
@media (min-width: 900px) { .actions .btn { flex: none; } }
.inp, .sel, .ta { font-family: var(--sans); font-size: 13px; border: 1px solid var(--rule); border-radius: 6px; background: var(--white); color: var(--ink); padding: 9px 10px; width: 100%; }
.inp.mono { font-family: var(--mono); }
.ta { min-height: 88px; resize: vertical; }
label.lb { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.filters { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0; }
.filters .lnk { color: var(--muted); }
.filters .lnk.on { color: var(--ink); font-weight: 500; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 8px; border: 1px solid var(--rule); border-radius: 999px; background: var(--field); margin: 0 6px 6px 0; background: none; cursor: pointer; }
.tag.soft { border-color: var(--rule); color: var(--muted); }
.tag i { font-style: normal; color: var(--faint); font-size: 11px; }
.mode { display: flex; border: 1px solid var(--rule); border-radius: 6px; background: var(--panel); overflow: hidden; margin-top: 10px; max-width: 360px; }
.mode button { flex: 1; text-align: center; padding: 7px 0; font-size: 12px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.mode button.on { background: var(--ink); color: var(--paper); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border: 1px solid var(--rule); border-radius: 999px; background: none; cursor: pointer; color: var(--ink); }
.chip.on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.drop { border: 1px dashed var(--rule); border-radius: 8px; background: var(--field); padding: 12px; text-align: center; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* blocks (D3) */
.blk { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: start; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px; box-shadow: var(--shadow); padding: 9px 12px; margin-top: 6px; cursor: grab; }
.blk.drag { opacity: 0.5; } .blk.over { border-top: 2px solid var(--signal); }
.blk .hand { color: var(--faint); font-size: 15px; line-height: 1.2; user-select: none; }
.blk .bt { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.blk .bc { font-size: 13px; margin: 2px 0 0; white-space: pre-wrap; }
.blk .lock { color: var(--faint); font-size: 11px; }
.blk .ta { margin-top: 6px; }
.preview { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px; padding: 20px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.preview .sub { font-weight: 500; margin-bottom: 12px; }

/* status */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--signal); } .dot.bad { background: var(--warn); }
.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.err { font-size: 12px; color: var(--warn); margin-top: 8px; }
.busy { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.busy::before { content: ""; width: 10px; height: 10px; border: 1.5px solid var(--rule); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); font-size: 12px; padding: 8px 14px; border-radius: 2px; opacity: 0; transition: opacity 120ms; pointer-events: none; }
.toast.show { opacity: 1; }
.demo { font-size: 11px; color: var(--muted); border-top: 1px solid var(--panel-border); background: var(--panel); padding: 12px var(--gutter); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* home */
.hero { text-align: center; padding: 36px 0 20px; }
.page > .hero + .cols > div { background: none; }

.hero .wm { font-size: 40px; margin-top: 12px; }
.hero .by { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--muted); margin-top: 8px; }
.moves .row { align-items: baseline; }
.moves .k { font-family: var(--mono); font-weight: 500; width: 34px; flex: none; }
.moves .row > div { flex: 1; }

/* admin bars */
.bar { height: 8px; background: var(--ink); }
.bar.sig { background: var(--signal); }
.funnel .row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 46px; gap: 10px; align-items: center; }
.conn { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 0.5px solid var(--rule-soft); }
.conn .who { font-weight: 500; }
.conn .what { font-size: 12px; color: var(--muted); }

/* login card */
.card { max-width: 420px; }

/* print (Export PDF) */
.printonly { display: none; }
@media print {
  @page { margin: 16mm; }
  html, body { background: #fff; }
  .page > .sec, .cols > div > .sec, .card, .four > .fig, .two > .fig { box-shadow: none; }
  .top, .demo, .noprint, .toast { display: none !important; }
  .printonly { display: block; }
  .page { padding: 0; max-width: none; }
  .cols { grid-template-columns: 5fr 7fr; gap: 28px; }
  .h1 { font-size: 30px; }
  a { text-decoration: none; }
  .lnk.tiny::after { content: ""; }
  .row, .fig { break-inside: avoid; }
}
