:root {
  --ink: #1a2a6c;
  --ink-soft: #eef1f8;
  --text: #1f2328;
  --muted: #636c76;
  --line: #d8dde3;
  --ground: #f3f4f6;
  --error: #a1262b;
  --error-bg: #fcebec;
  --ok: #1d6b34;
  --ok-bg: #e8f5ec;
  --warn: #7a5200;
  --warn-bg: #fdf3dc;
  --paper-ink: #1a2a6c;
  --on-ink: #fff;
  --surface: #fff;
  --panel: #fbfbfc;
  --border-strong: #b9c0c8;
  --top: rgba(243, 244, 246, .92);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  color-scheme: light dark;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--ground);
}
body { margin: 0; }
main { max-width: 1000px; margin: 0 auto; padding: 0 16px 80px; }
.top { position: sticky; top: 0; z-index: 5; background: var(--top); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.top .inner { max-width: 1000px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.top h1 { font-size: 19px; margin: 0; margin-right: auto; }
.top nav { display: flex; gap: 6px 14px; flex-wrap: wrap; }
.top nav a { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
.top nav a:hover { color: var(--ink); }
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.badge.bad { background: var(--error-bg); color: var(--error); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.plain { background: var(--ground); color: var(--muted); }
.badge.info { background: var(--ink-soft); color: var(--ink); }
h2 { font-size: 17px; margin: 0 0 14px; }
h3 { font-size: 14px; margin: 0; }
section { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; scroll-margin-top: 70px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 12px; }
.row.center { align-items: center; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field.wide { flex: 1 1 280px; }
input[type=text], select, textarea { font: inherit; color: var(--text); padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 7px; min-width: 180px; background: var(--surface); }
textarea { resize: vertical; min-height: 20px; }
button { font: inherit; padding: 8px 16px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--ink); }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
button.small { padding: 4px 10px; font-size: 13px; }
button.danger { color: var(--error); border-color: #e3b5b7; }
button.danger:hover { border-color: var(--error); }
button:disabled { opacity: .5; cursor: default; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.message { padding: 10px 12px; border-radius: 7px; margin-top: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.error { background: var(--error-bg); color: var(--error); }
.message.ok { background: var(--ok-bg); color: var(--ok); }
.message.warn { background: var(--warn-bg); color: var(--warn); }
.message.info { background: var(--ground); color: var(--muted); }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.choice { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: grid; gap: 6px; }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--ink-soft); }
.choice .name { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; }
.choice .preview { height: 60px; display: flex; align-items: center; }
.choice .preview img { max-height: 60px; max-width: 100%; background: #fff; border-radius: 4px; }
canvas.pad { display: block; width: 100%; height: 220px; margin-top: 14px; border: 1px dashed #aab2bc; border-radius: 9px; background: #fff; cursor: crosshair; touch-action: none; }
canvas.pad.small { height: 140px; margin-top: 10px; }

.drop { display: block; border: 1px dashed #aab2bc; border-radius: 9px; padding: 20px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--ink); background: var(--ink-soft); }
.drop strong { color: var(--ink); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; border-bottom: 1px solid var(--line); }
.tab { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--muted); font-size: 14px; background: none; }
.tab.active { border-color: var(--line); background: var(--surface); color: var(--text); margin-bottom: -1px; }
.tab .count { font-size: 12px; color: var(--muted); }
.tab .close { border: none; background: none; padding: 0 2px; color: var(--muted); font-size: 15px; line-height: 1; }
.tab .close:hover { color: var(--error); }
.kinds { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; gap: 6px; align-items: center; padding: 5px 11px; border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; font-size: 14px; }
.pill:has(input:checked) { border-color: var(--ink); background: var(--ink-soft); color: var(--ink); }
.pill input { margin: 0; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); }
.check:has(input:disabled) { opacity: .6; }
.panel { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 14px; background: var(--panel); }
.panel .head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cosigner { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }

.pages { display: grid; gap: 18px; margin-top: 16px; }
.page { position: relative; container-type: inline-size; background: #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, .18); cursor: crosshair; }
.page .sheet { display: block; width: 100%; user-select: none; }
.page .number { position: absolute; top: 6px; right: 8px; font-size: 12px; color: var(--muted); }
.mark { position: absolute; cursor: grab; outline: 1px dashed rgba(26, 42, 108, .45); outline-offset: 1px; touch-action: none; }
.mark:hover { outline-color: var(--paper-ink); }
.mark.dragging { cursor: grabbing; outline: 2px solid var(--paper-ink); }
.mark.text { color: var(--paper-ink); font-family: Helvetica, Arial, sans-serif; font-size: calc(10.5 * 100cqw / var(--w)); line-height: 1; white-space: nowrap; }
.mark.signature img { display: block; width: 100%; height: 100%; pointer-events: none; }
.mark.placeholder { display: grid; place-items: center; background: rgba(26, 42, 108, .08); color: var(--paper-ink); font-size: 12px; overflow: hidden; }
.mark .who { position: absolute; left: 0; top: -16px; font-size: 11px; color: var(--paper-ink); background: rgba(255, 255, 255, .85); padding: 0 4px; border-radius: 3px; white-space: nowrap; display: none; }
.mark:hover .who { display: block; }
.mark .remove { position: absolute; top: -11px; right: -11px; width: 20px; height: 20px; padding: 0; border-radius: 50%; font-size: 14px; line-height: 17px; background: #fff; border: 1px solid var(--error); color: var(--error); display: none; }
.mark .handle { position: absolute; right: -6px; bottom: -6px; width: 11px; height: 11px; background: var(--paper-ink); border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize; display: none; }
.mark:hover .remove, .mark:hover .handle, .mark.dragging .handle { display: block; }
.mark.fixed { cursor: default; outline-style: dotted; pointer-events: none; }
.mark.fixed img { display: block; width: 100%; }
.result .page { cursor: default; }
.actions { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 4px; border-top: 1px solid var(--line); margin-top: 16px; }
.result { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.result.ok { border-color: #b7dcc2; }
.result.failed { border-color: #e3b5b7; }

.status-line { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
a.button, label.button { display: inline-block; font: inherit; padding: 8px 16px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; }
a.button.small, label.button.small { padding: 4px 10px; font-size: 13px; }
a.button:hover, label.button:hover { border-color: var(--ink); }
.spacer { flex: 1; }
.ready-item { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.ready-item:first-child { border-top: none; }
.ready-item .what { flex: 1; min-width: 0; }
.ready-item .what div:first-child { font-weight: 500; overflow-wrap: anywhere; }
.ready-item .meta { color: var(--muted); font-size: 12.5px; }
.tools input[type=search] { font: inherit; color: var(--text); background: var(--surface); padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: 7px; min-width: 220px; flex: 1 1 220px; }
.tools select { min-width: 0; }
ul.findings { margin: 6px 0 0; padding-left: 18px; }
.twin { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.twin .panel { margin-top: 14px; }
.item { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); font-size: 14px; }
.item:first-of-type { border-top: none; }
.item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item input[type=text] { min-width: 0; flex: 1; }
.item input[type=date] { font: inherit; color: var(--text); background: var(--surface); padding: 5px 7px; border: 1px solid var(--border-strong); border-radius: 7px; }
.item .remove-item { border: none; background: none; color: var(--muted); padding: 0 4px; font-size: 16px; }
.item .remove-item:hover { color: var(--error); }
.mark.check { color: var(--paper-ink); font-size: calc(13 * 100cqw / var(--w)); line-height: 1; font-weight: 600; }
.deadline.overdue { color: var(--error); }
.deadline.soon { color: var(--warn); }
.table-wrap { overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
td { border-bottom: 1px solid var(--line); padding: 9px 8px; vertical-align: top; }
td.nowrap { white-space: nowrap; }
td .title { font-weight: 500; }
td .detail { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
td .badges { display: flex; flex-wrap: wrap; gap: 4px; }
td.buttons { white-space: nowrap; text-align: right; }
td.buttons button + button { margin-left: 6px; }
tr.revoked td { color: var(--muted); }
tr.revoked .title { text-decoration: line-through; }
tr.revoke-form td { background: var(--error-bg); }
tr.revoke-form input { flex: 1 1 320px; }

.changes { margin-top: 8px; max-height: 260px; overflow: auto; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.change { padding: 0 6px; border-radius: 3px; }
.change.added { background: var(--ok-bg); color: var(--ok); }
.change.removed { background: var(--error-bg); color: var(--error); text-decoration: line-through; }
.change.same { color: var(--muted); }
.change.skip { color: var(--muted); text-align: center; }

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #9fb0ff;
    --on-ink: #10162f;
    --ink-soft: #242b47;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --line: #343941;
    --ground: #15171b;
    --surface: #1d2025;
    --panel: #22262c;
    --border-strong: #4b525b;
    --top: rgba(21, 23, 27, .9);
    --series-1: #3987e5;
    --series-2: #d95926;
    --error: #ff8f94;
    --error-bg: #3b1e21;
    --ok: #80d49b;
    --ok-bg: #1a3223;
    --warn: #f0c463;
    --warn-bg: #392e13;
  }
  .badge.plain { background: var(--line); }
}

/* portal navigation */
.top h1 a { color: inherit; text-decoration: none; }
.top nav a.active { color: var(--text); font-weight: 600; }


/* overview and decisions */
.choice .desc { color: var(--muted); font-size: 13px; }
.item.revoked .grow { text-decoration: line-through; color: var(--muted); }
.item .nowrap { white-space: nowrap; color: var(--muted); }
input.text, textarea.text { display: block; width: 100%; box-sizing: border-box; min-width: 0; margin-top: 8px; }
input.text { font-weight: 600; }
textarea.text { resize: vertical; overflow: hidden; line-height: 1.45; }
.point { display: flex; gap: 8px; align-items: start; }
.point .no { width: 22px; flex: none; padding-top: 16px; text-align: right; color: var(--muted); }
.point .remove-item { margin-top: 12px; border: none; background: none; color: var(--muted); padding: 0 4px; font-size: 16px; }
.point .remove-item:hover { color: var(--error); }
.points + button { margin-top: 8px; }
table.fields td, table.fields th { border: none; padding: 4px 10px 4px 0; }
table.fields td.label { color: var(--muted); font-size: 13px; white-space: nowrap; }
table.fields input { min-width: 140px; width: 100%; box-sizing: border-box; }
.field input[type=date], .field input[type=number], table.fields input[type=date] { font: inherit; color: var(--text); background: var(--surface); padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 7px; }

/* links in lists, figures and worksheets */
.item a { color: inherit; text-decoration: none; }
.item a:hover { text-decoration: underline; }
.deadline.overdue a, .deadline.overdue strong { color: var(--error); }
.deadline.soon a, .deadline.soon strong { color: var(--warn); }
td.amount, th.amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); }
tr.sub td { color: var(--muted); font-size: 13px; }
.sheet-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sheet-head h3 { margin-right: auto; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; margin-top: 12px; }
.grid-form .field input, .grid-form .field select, .grid-form .field textarea { min-width: 0; width: 100%; box-sizing: border-box; }
.grid-form .field.full { grid-column: 1 / -1; }
pre.output { white-space: pre-wrap; font-size: 12.5px; max-height: 260px; overflow: auto; background: var(--ground); padding: 10px; border-radius: 7px; }
@media print {
  .top, .no-print, .actions { display: none !important; }
  section, .panel { border: none; box-shadow: none; }
}
.nowrap { white-space: nowrap; }

/* charts */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 420px)); gap: 14px; margin-top: 12px; }
.chart h3 { font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--muted); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 10px; font-family: inherit; }
.chart .mark:hover { opacity: .8; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-tip { position: fixed; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); z-index: 10; }
