:root {
  --blue: #3a87c8; --blue-l: #6fb9ec; --green: #7fd1a6; --ink: #222a3a; --slate: #4b5072;
  --muted: #6b7280; --line: #e5e7eb; --bg: #f5f7fa; --red: #c0392b; --amber: #c98a12; --ok: #2f8f5b;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
a { color: var(--blue); }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 340px; }
.login-logo { width: 180px; display: block; margin: 0 auto 8px; }
.login-card h2 { text-align: center; color: var(--slate); font-weight: 500; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0; }
input, select, textarea { width: 100%; padding: 7px 9px; border: 1px solid #cfd5dd; border-radius: 6px; font: inherit; color: var(--ink); background: #fff; margin-top: 3px; }
textarea { min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-l); border-color: var(--blue); }
.btn { border: 1px solid #cfd5dd; background: #fff; border-radius: 6px; padding: 7px 13px; cursor: pointer; font: inherit; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--red); border-color: #e9b4ad; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font: inherit; }
.err { color: var(--red); min-height: 1em; }
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.nav { background: #fff; border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.nav-logo { width: 140px; margin: 0 8px 16px; }
.nav a { padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--slate); }
.nav a.active, .nav a:hover { background: #eef5fc; color: var(--blue); }
.nav-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.view { padding: 24px 28px; max-width: 1280px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi .v { font-size: 22px; font-weight: 600; margin-top: 4px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi.warn .v { color: var(--red); }
table.t { width: 100%; border-collapse: collapse; background: #fff; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); padding: 8px; }
table.t td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f8fbfe; }
.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: 12px; background: #eef0f3; color: var(--slate); }
.pill.draft { background: #f1f1f1; color: #777; }
.pill.issued, .pill.accepted { background: #e7f1fb; color: var(--blue); }
.pill.paid, .pill.converted, .pill.received { background: #e6f5ec; color: var(--ok); }
.pill.partially_paid { background: #fdf3e1; color: var(--amber); }
.pill.overdue, .pill.void, .pill.declined, .pill.failed { background: #fbe9e7; color: var(--red); }
.pill.credited { background: #efeaf8; color: #6a4fb3; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.lines-ed td { padding: 4px; }
.lines-ed input, .lines-ed textarea { margin: 0; }
.lines-ed textarea { min-height: 34px; font-size: 12px; }
.lines-ed .w-desc { width: 34%; }
.lines-ed .w-num { width: 10%; }
.totals { margin-left: auto; width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .big { font-size: 18px; font-weight: 600; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 8px 4px 0; border-bottom: 1px solid var(--line); }
.bars .m { flex: 1; display: flex; gap: 3px; align-items: flex-end; height: 100%; position: relative; }
.bars .b { flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .b.inv { background: var(--blue-l); }
.bars .b.col { background: var(--green); }
.bars-lbl { display: flex; gap: 10px; padding: 4px; font-size: 11px; color: var(--muted); }
.bars-lbl span { flex: 1; text-align: center; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.dot.inv { background: var(--blue-l); }
.dot.col { background: var(--green); }
.age { display: flex; height: 16px; border-radius: 4px; overflow: hidden; background: #eef0f3; margin: 8px 0; }
.age div { height: 100%; }
.a0 { background: var(--green); } .a1 { background: #f2c14e; } .a2 { background: #ec9a3c; } .a3 { background: #df6a3d; } .a4 { background: var(--red); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; max-width: 420px; z-index: 50; }
.toast.bad { background: var(--red); }
.modal { position: fixed; inset: 0; background: rgba(20, 25, 35, .45); display: grid; place-items: center; z-index: 40; }
.modal-box { width: min(560px, 92vw); max-height: 90vh; overflow: auto; }
.mb { margin-bottom: 14px; }
.mt { margin-top: 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs .btn.on { background: #eef5fc; border-color: var(--blue); color: var(--blue); }
code { font-size: 12px; background: #f1f3f6; padding: 1px 5px; border-radius: 4px; word-break: break-all; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav-logo, .nav-foot { display: none; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
  .view { padding: 14px; }
}
a.btn { text-decoration: none; display: inline-block; }
.row > select, .row > input:not([type=checkbox]) { width: auto; min-width: 140px; margin-top: 0; }
.row > input[name=q] { min-width: 280px; }
.row input[name=interval] { width: 70px; min-width: 70px; }
pre { white-space: pre-wrap; background: #f6f8fa; padding: 8px; border-radius: 6px; }
ol { padding-left: 18px; }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; vertical-align: middle; }
