:root {
  --bg: #f4f5f2; --panel: #ffffff; --ink: #1d2329; --muted: #67727c; --rule: #dfe3e6;
  --accent: #23524a; --accent-ink: #ffffff; --accent-soft: #e3eeeb;
  --warn: #9a5b00; --warn-soft: #fbf0dc; --bad: #a3271c; --bad-soft: #fbe6e3; --good: #23704a; --good-soft: #e2f2e8;
  --radius: 8px; --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: #1c2a27; color: #dfe9e6; padding: 18px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .01em; margin-bottom: 22px; }
.brand span { display: block; font-weight: 400; font-size: 12px; opacity: .7; letter-spacing: .12em; text-transform: uppercase; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { color: inherit; text-decoration: none; padding: 7px 10px; border-radius: 6px; }
.side nav a:hover { background: rgba(255,255,255,.07); }
.side nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.nav-h { margin: 16px 10px 4px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .55; }
.me { font-size: 12px; opacity: .8; display: flex; flex-direction: column; gap: 4px; }
main { padding: 26px 30px 60px; max-width: 1400px; width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.bar label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.bar .grow { flex: 1; }
input, select, textarea { border: 1px solid var(--rule); border-radius: 6px; padding: 7px 9px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button { border: 1px solid var(--rule); background: #fff; border-radius: 6px; padding: 7px 13px; cursor: pointer; }
button:hover { border-color: #b9c1c7; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; text-align: left; }
button:disabled { opacity: .5; cursor: default; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tile { padding: 14px 16px; }
.tile b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
.tbl { overflow-x: auto; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfa; position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7faf9; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: #eef0f2; white-space: nowrap; }
.pill.Draft { background: var(--warn-soft); color: var(--warn); }
.pill.Approved, .pill.Queued, .pill.Received { background: var(--accent-soft); color: var(--accent); }
.pill.Sent, .pill.Paid { background: var(--good-soft); color: var(--good); }
.pill.PartPaid { background: #e7ecfb; color: #2c4aa0; }
.pill.Rejected, .pill.Cancelled, .pill.Failed { background: var(--bad-soft); color: var(--bad); }
.warnmark { color: var(--warn); font-weight: 700; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
dialog { border: 0; border-radius: 10px; padding: 0; width: min(880px, 96vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,30,28,.45); }
#dlg-body { padding: 22px 24px; overflow: auto; max-height: 92vh; }
.dlg-h { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 14px; }
.dlg-h h2 { margin: 0; font-size: 19px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.grid label.wide { grid-column: 1 / -1; }
.grid label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.grid .hint { font-size: 11px; color: var(--muted); }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius); margin: 14px 0 0; padding: 12px 14px 14px; }
legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.units-pick { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.units-pick label { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 18px; margin-bottom: 14px; }
.facts div span { display: block; font-size: 12px; color: var(--muted); }
pre.log { background: #f6f7f5; border: 1px solid var(--rule); border-radius: 6px; padding: 10px 12px; white-space: pre-wrap; font: 12px/1.5 ui-monospace, Consolas, monospace; }
.note { padding: 9px 12px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); margin: 8px 0; }
.note.info { background: var(--accent-soft); color: var(--accent); }
.err { color: var(--bad); }
h3 { font-size: 14px; margin: 18px 0 6px; }
#toast { position: fixed; right: 20px; bottom: 20px; background: #1c2a27; color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 10; white-space: pre-line; }
#toast.bad { background: var(--bad); }
.split { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.split .card { padding: 16px; }
.split h2 { font-size: 16px; margin: 0 0 4px; }
body.login { display: grid; place-items: center; min-height: 100vh; background: #1c2a27; }
.login-card { background: #fff; padding: 28px; border-radius: 10px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 12px; }
.login-card .brand { color: var(--ink); }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .nav-h { display: none; }
  main { padding: 18px 14px 50px; }
}
