:root {
  --bg: #f4f5f3; --surface: #ffffff; --sunken: #eceee9; --ink: #1c211f; --muted: #5d6662; --line: #d9ddd6;
  --accent: #0f6b5c; --accent-ink: #ffffff; --accent-soft: #dcefe9;
  --ok: #1a7a4c; --ok-soft: #dff2e6; --warn: #8f5a00; --warn-soft: #fbedcf; --bad: #b3362b; --bad-soft: #fae3df;
  --sample: #fff4d1; --sample-ink: #5f4700;
  --grid: #e1e0d9; --axis: #c3c2b7;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6;
  --h1: #cde2fb; --h2: #9ec5f4; --h3: #5598e7; --h4: #256abf; --h5: #0d366b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131715; --surface: #1c211f; --sunken: #171b19; --ink: #e8ece9; --muted: #9aa5a0; --line: #303733;
    --accent: #4cc2a9; --accent-ink: #08201b; --accent-soft: #17342d;
    --ok: #5fd096; --ok-soft: #17321f; --warn: #e6b95c; --warn-soft: #362a10; --bad: #f08a7e; --bad-soft: #3b1c18;
    --sample: #33290d; --sample-ink: #edd48a;
    --grid: #2c2c2a; --axis: #383835;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9;
    --h1: #184f95; --h2: #256abf; --h3: #3987e5; --h4: #86b6ef; --h5: #cde2fb;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 24px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.demo-bar { background: var(--sample); color: var(--sample-ink); padding: 6px 16px; font-size: 13px; text-align: center; }
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 0 24px; flex-wrap: wrap; }
.brand { font-weight: 700; padding: 13px 0; color: var(--ink); text-decoration: none; }
nav.main { display: flex; gap: 2px; overflow-x: auto; max-width: 100%; scrollbar-width: none; flex: 1; }
nav.main a { border-bottom: 2px solid transparent; padding: 14px 12px 12px; color: var(--muted); white-space: nowrap; text-decoration: none; }
nav.main a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.who { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.who form { margin: 0; }
main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 56px; }
main.narrow { max-width: 460px; padding-top: 56px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.sub { color: var(--muted); margin-top: 4px; max-width: 72ch; }
.small { font-size: 13px; color: var(--muted); }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; display: inline-block; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; text-align: left; font-weight: 600; }
.btn.link:hover { text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
select, input[type=number], input[type=text], input[type=email], input[type=password], textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; margin: 0; vertical-align: middle; }
input[type=checkbox]:disabled { cursor: not-allowed; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.stats.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat { background: var(--surface); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-weight: 650; }
.stat span { color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
.seg a { padding: 6px 12px; color: var(--muted); text-decoration: none; }
.seg a[aria-current="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.pill { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.none { background: var(--sunken); color: var(--muted); }
.flash { padding: 9px 12px; border-radius: 6px; margin-bottom: 14px; background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--bad-soft); color: var(--bad); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-width: 0; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.mono { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 12px 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; overflow: hidden; background: var(--sunken); }
progress::-webkit-progress-bar { background: var(--sunken); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); gap: 8px; }
.reasons { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: center; }
.grid thead th { vertical-align: bottom; font-weight: 600; background: var(--surface); }
.grid .tcol { text-align: left; min-width: 300px; position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 1px 0 0 var(--line); font-weight: 400; }
.grid .mcol { width: 84px; }
.grid .acol { min-width: 84px; }
.grid .allcol, .grid thead .allcol { background: var(--accent-soft); min-width: 62px; }
.grid .group td, .grid .group th { background: var(--sunken); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; padding: 5px 8px; }
.grid tfoot td, .grid tfoot th { font-weight: 650; font-variant-numeric: tabular-nums; border-bottom: 0; background: var(--surface); }
.grid input[type=number] { width: 60px; text-align: right; padding: 3px 5px; }
.tag { font-size: 11px; color: var(--accent); font-weight: 600; margin-left: 6px; white-space: nowrap; }
.rm { display: inline; margin: 0; }
.x { background: none; border: 0; color: var(--muted); margin-left: 4px; padding: 0 4px; }
.lock { font-size: 11px; color: var(--muted); display: block; font-weight: 500; }
.stack { margin-top: 4px; }
.add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px; margin: 0; }
.add input[type=text] { flex: 1 1 260px; }
.add input[type=number] { width: 80px; }
.list th, .list td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.list th { color: var(--muted); font-weight: 600; font-size: 13px; }
.list tr:last-child td { border-bottom: 0; }
.list td.wrap-text { white-space: normal; min-width: 240px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.bar form { margin: 0; }
.spacer { flex: 1; }
.scroll-x { overflow-x: auto; }
.invoice { margin-top: 18px; }
.delivery { max-width: 820px; margin: 0 auto 14px; }
.delivery p { margin-top: 6px; }
.extra-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.extra-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.extra-form input { width: 100%; font-weight: 400; }
.extra-form .wide { grid-column: 1 / -1; }
.extra-form .err { font-weight: 400; }
.row { display: grid; grid-template-columns: 24px 1fr 150px 76px; gap: 10px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.row input[type=date] { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; width: 100%; }
.row input:disabled { opacity: .45; }
.row-head { padding-top: 6px; padding-bottom: 6px; font-weight: 600; }
.row input[type=number] { width: 66px; text-align: right; padding: 3px 5px; }
.note-form { padding: 14px; margin: 0; }
.note-form textarea { width: 100%; min-height: 96px; margin: 6px 0 8px; }
.group-head { background: var(--sunken); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 5px 14px; }
.form { display: grid; gap: 12px; max-width: 560px; }
.form label { display: grid; gap: 4px; font-weight: 600; }
.form label.check { display: flex; gap: 8px; align-items: center; }
.form input:not([type=checkbox]), .form select, .form textarea { width: 100%; font-weight: 400; }
.err { color: var(--bad); font-size: 13px; font-weight: 400; }
.qr { background: #fff; padding: 10px; border-radius: 8px; width: 220px; margin: 12px 0; }
.qr svg { display: block; width: 200px; height: 200px; }
.doc { background: #fff; color: #1c211f; max-width: 820px; margin: 0 auto; padding: 44px 48px; border: 1px solid var(--line); border-radius: 4px; }
.doc header { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid #1c211f; padding-bottom: 14px; }
.doc .meta { text-align: right; font-size: 13px; }
.doc h1 { font-size: 22px; }
.doc h2 { margin: 20px 0 6px; font-size: 15px; }
.doc .rstats { display: flex; flex-wrap: wrap; gap: 28px; margin: 18px 0; }
.doc .rstats b { display: block; font-size: 20px; }
.doc .rstats span { font-size: 12px; color: #5d6662; }
.doc table { font-size: 14px; }
.doc th, .doc td { padding: 6px 8px 6px 0; border-bottom: 1px solid #d9ddd6; text-align: left; vertical-align: top; }
.doc thead th { font-size: 12px; color: #5d6662; font-weight: 600; }
.doc .rgroup td { font-weight: 650; padding-top: 14px; border-bottom: 1px solid #1c211f; }
.doc .nd { color: #b3362b; }
.doc .date { white-space: nowrap; }
.doc .total td { font-weight: 700; border-bottom: 0; padding-top: 10px; }
.doc .prewrap { white-space: pre-wrap; }
.doc .requested { display: block; font-size: 12px; color: #5d6662; }
.doc footer { margin-top: 26px; padding-top: 10px; border-top: 1px solid #d9ddd6; font-size: 12px; color: #5d6662; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.doc .mark { background: #fff4d1; color: #5f4700; font-size: 12px; padding: 4px 8px; margin-bottom: 14px; text-align: center; }
.doc section.client { break-before: page; margin-top: 32px; }
.doc section.client h2 { font-size: 18px; margin: 0 0 2px; }
.charts { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; margin-bottom: 14px; }
.chart-card h2 { font-size: 15px; }
.chart { margin-top: 12px; min-height: 40px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart text.ink { fill: var(--ink); font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .plan { stroke: var(--ink); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:hover, .chart .hit:focus { fill: var(--ink); fill-opacity: .05; }
.chart .hit.current { fill: var(--accent-soft); fill-opacity: .55; }
.s1 { fill: var(--s1); } .s2 { fill: var(--s2); } .s3 { fill: var(--s3); } .s4 { fill: var(--s4); } .s5 { fill: var(--s5); } .s6 { fill: var(--s6); } .s7 { fill: var(--s7); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.legend svg { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }
details.table-view { margin-top: 10px; font-size: 13px; }
details.table-view summary { cursor: pointer; color: var(--muted); }
details.table-view .scroll { overflow-x: auto; margin-top: 6px; }
details.table-view th, details.table-view td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
details.table-view th:first-child, details.table-view td:first-child { text-align: left; }
.heat th, .heat td { padding: 2px; font-size: 12px; text-align: center; font-weight: 500; }
.heat thead th { color: var(--muted); }
.heat tbody th { text-align: left; white-space: nowrap; padding-right: 10px; font-weight: 500; font-size: 13px; }
.heat .cell { display: block; min-width: 40px; padding: 5px 2px; border-radius: 3px; font-variant-numeric: tabular-nums; outline-offset: 1px; }
.heat .h0 { background: var(--sunken); color: var(--muted); }
.heat .h1 { background: var(--h1); color: #0b0b0b; }
.heat .h2 { background: var(--h2); color: #0b0b0b; }
.heat .h3 { background: var(--h3); color: #0b0b0b; }
.heat .h4 { background: var(--h4); color: #ffffff; }
.heat .h5 { background: var(--h5); color: #ffffff; }
@media (prefers-color-scheme: dark) {
  .heat .h1, .heat .h2 { color: #ffffff; }
  .heat .h3, .heat .h4, .heat .h5 { color: #0b0b0b; }
}
.heat-scroll { overflow-x: auto; }
.scale { display: flex; gap: 2px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.scale .cell { min-width: 26px; width: 26px; height: 10px; padding: 0; border-radius: 2px; }
.scale .lbl { margin: 0 6px; }
.health-list { list-style: none; margin: 10px 0 0; padding: 0; }
.health-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: flex-start; flex-wrap: wrap; }
.health-list li:last-child { border-bottom: 0; }
.health-list .why { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.viz-tip { position: fixed; z-index: 20; background: var(--ink); color: var(--bg); padding: 6px 9px; border-radius: 6px; font-size: 13px; white-space: pre-line; pointer-events: none; max-width: 260px; font-variant-numeric: tabular-nums; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; font-size: 14px; opacity: 0; transition: opacity .15s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 10; }
#toast.on { opacity: 1; }
.pager { margin-top: 12px; display: flex; justify-content: space-between; }
[hidden] { display: none !important; }
@media (max-width: 1040px) {
  .stats.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.five .stat:first-child { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .charts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 780px) {
  .row { grid-template-columns: 24px 1fr 76px; }
  .row input[type=date] { grid-column: 2; grid-row: 2; }
  .row input[type=number] { grid-column: 3; grid-row: 1; }
  .row-head { display: none; }
  .top-in { justify-content: space-between; }
  nav.main { order: 3; flex-basis: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc { padding: 22px 16px; }
  .doc .meta { text-align: left; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .grid .tcol { min-width: 190px; max-width: 190px; }
}
@media print {
  .noprint, .top, .demo-bar, #toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .doc { border: 0; padding: 0; max-width: none; }
  .doc tr { break-inside: avoid; }
}
