:root {
  --bg: #f4f6f8; --panel: #fff; --ink: #1d2733; --muted: #6b7785; --line: #e1e6eb;
  --nav: #17212b; --nav-ink: #c9d3dd; --nav-hi: #fff; --accent: #0f7b6c; --accent-ink: #fff;
  --danger: #b42318; --warn: #b54708; --ok: #067647; --draft: #8a5a00;
  --radius: 6px; font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
nav.side { background: var(--nav); color: var(--nav-ink); padding: 14px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
nav.side .brand { color: var(--nav-hi); font-weight: 700; font-size: 17px; padding: 4px 18px 14px; letter-spacing: .3px; }
nav.side .brand small { display: block; font-weight: 400; font-size: 11px; color: var(--nav-ink); }
nav.side h4 { margin: 14px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #7d8a98; }
nav.side a { display: block; color: var(--nav-ink); padding: 5px 18px 5px 26px; font-size: 13.5px; }
nav.side a:hover { background: #22303d; color: var(--nav-hi); text-decoration: none; }
nav.side a.active { background: #22303d; color: var(--nav-hi); border-left: 3px solid var(--accent); padding-left: 23px; }
nav.side a.soon { opacity: .45; pointer-events: none; }
nav.side form { padding: 12px 18px; }
main { padding: 22px 28px 60px; min-width: 0; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 16px; font-weight: 600; margin: 22px 0 10px; }
.toolbar { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.grid td { padding: 6px 10px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
table.grid tr:hover td { background: #f7fbfa; }
table.grid tfoot td { font-weight: 600; background: #fafbfc; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }
.badge.booked { background: #dcfae6; color: var(--ok); }
.badge.draft { background: #fef0c7; color: var(--draft); }
.badge.reversed { background: #fee4e2; color: var(--danger); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #cdd5dd; border-radius: 4px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9ad5cc; border-color: var(--accent); }
input[type=checkbox] { width: auto; }
input.num { text-align: right; }
textarea { min-height: 60px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.field { min-width: 0; }
.check { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); }
.btn { display: inline-block; font: inherit; border: 1px solid #cdd5dd; background: #fff; color: var(--ink); padding: 6px 14px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f4f6; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #0c6458; }
.btn.danger { color: var(--danger); border-color: #f3b8b2; }
.btn.small { padding: 2px 8px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: default; }
.flash { padding: 9px 12px; border-radius: 4px; margin-bottom: 12px; }
.flash.ok { background: #dcfae6; color: var(--ok); }
.flash.error { background: #fee4e2; color: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.entry-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.lines td { padding: 3px 4px; }
.lines td input, .lines td select { padding: 4px 6px; }
.totals { display: flex; justify-content: flex-end; gap: 24px; padding: 8px 4px; font-variant-numeric: tabular-nums; }
.totals .diff.bad { color: var(--danger); font-weight: 600; }
.doc-drop { border: 2px dashed #cdd5dd; border-radius: var(--radius); padding: 20px; text-align: center; color: var(--muted); background: #fff; }
.doc-preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.login { max-width: 340px; margin: 12vh auto; }
.login h1 { text-align: center; }
.kbd-hint { font-size: 12px; color: var(--muted); margin-top: 10px; }
.inline-form { display: inline; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; }
  .entry-layout { grid-template-columns: 1fr; }
  main { padding: 16px; }
  table.grid { display: block; overflow-x: auto; }
}
