:root {
  color-scheme: light dark;
  --bg: #dfe4ea; --bg-2: #d3d9e1;
  --card: rgba(255,255,255,0.92); --card-solid: #ffffff;
  --line: #e5e7eb; --line-strong: #d4d8df;
  --ink: #141c2b; --ink-2: #4a5568; --ink-3: #8390a3;
  --accent: #1f6f78; --accent-ink: #ffffff; --accent-soft: #e0f0f1;
  --good: #1c7a4d; --good-soft: #def3e7;
  --warn: #9a6200; --warn-soft: #fdf0d3;
  --bad: #b3261e; --bad-soft: #fbe3e1;
  --row-hover: #f4f7fa; --row-sel: #eaf5f5;
  --shadow: 0 1px 2px rgba(20,28,43,.06), 0 8px 24px -6px rgba(20,28,43,.14);
  --shadow-lift: 0 2px 4px rgba(20,28,43,.08), 0 14px 32px -8px rgba(20,28,43,.2);
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c; --bg-2: #161d28;
    --card: rgba(27,35,48,0.82); --card-solid: #1b2330;
    --line: #2a3445; --line-strong: #364257;
    --ink: #eef2f7; --ink-2: #b2bccb; --ink-3: #7c8aa0;
    --accent: #4fb3bd; --accent-ink: #06232a; --accent-soft: #15353a;
    --good: #5fd39a; --good-soft: #13352a;
    --warn: #f0b84a; --warn-soft: #3a2d10;
    --bad: #ff8a80; --bad-soft: #3d1b19;
    --row-hover: #212b3a; --row-sel: #17343a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -6px rgba(0,0,0,.55);
    --shadow-lift: 0 2px 4px rgba(0,0,0,.5), 0 16px 36px -8px rgba(0,0,0,.65);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%) fixed; background-color: var(--bg);
  color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.45;
  padding: 24px 16px 40px; min-height: 100vh;
}
.wrap { max-width: 1240px; margin: 0 auto; display: grid; gap: 20px; }
header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.eyebrow { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(26px, 4vw, 36px); line-height: 1.05; margin: 4px 0 0; letter-spacing: -.02em; }
.head-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.chip b { color: var(--ink); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.dot.on { background: var(--good); }
.grid { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.rail { display: grid; gap: 16px; min-width: 0; }
@media (max-width: 880px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.tray { background: var(--card); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 20px; min-width: 0; transition: box-shadow .2s ease; }
.tray:hover { box-shadow: var(--shadow-lift); }
.tray-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tray-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: -.01em; margin: 0; }
.tray-sub { color: var(--ink-3); font-size: 12px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
label { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
input[type="text"], input[type="date"], select {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--card-solid); color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input.num { text-align: right; font-family: var(--font-mono); font-weight: 500; font-size: 15px; font-variant-numeric: tabular-nums; }
input:hover, select:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input[disabled] { background: var(--bg); color: var(--ink-3); cursor: not-allowed; }
.row { display: flex; gap: 8px; }
.row > select { flex: 1; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two .field { margin-bottom: 0; }
.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.btnrow.one { grid-template-columns: 1fr; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 0; margin-top: 16px; border-top: 1px solid var(--line); cursor: pointer; }
.switch span { font-size: 13px; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { width: 40px; height: 24px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .2s ease; flex: none; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s ease; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status.ok { background: var(--good-soft); color: var(--good); }
.status.off { background: var(--bad-soft); color: var(--bad); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sum-row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line-strong); }
.sum-row .k { color: var(--ink-2); font-size: 13px; display: flex; gap: 8px; }
.sum-row .op { font-family: var(--font-mono); color: var(--ink-3); width: 14px; text-align: center; }
.sum-row .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 500; }
.sum-total { margin-top: 6px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); display: grid; gap: 10px; }
.sum-total .r { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sum-total .k { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.sum-total .big { font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.diff-ok { color: var(--good); } .diff-off { color: var(--bad); }
.last { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--ink-3); font-size: 12px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.ledger { padding: 0; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.bar.bottom { border-bottom: 0; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--card-solid) 60%, var(--bg)); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card-solid); color: var(--ink); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease; }
.btn:hover { border-color: var(--accent); box-shadow: 0 2px 8px -2px rgba(20,28,43,.18); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled] { background: var(--line-strong); border-color: var(--line-strong); color: var(--ink-3); cursor: not-allowed; transform: none; box-shadow: none; filter: none; }
.btn.small { height: 32px; padding: 0 10px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.variant { height: 38px; width: auto; padding-right: 28px; font-size: 13px; font-weight: 600; }
.scroll { overflow-x: auto; min-height: 220px; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
thead th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding: 12px 16px; background: var(--card-solid); border-bottom: 1px solid var(--line); white-space: nowrap; }
th.r, td.r { text-align: right; } th.c, td.c { text-align: center; }
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s ease; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.on { background: var(--row-sel); }
tbody tr.locked { cursor: default; }
td.mono { font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
td.desc { max-width: 340px; }
td.desc div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
td.amt { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
td.amt.cr { color: var(--bad); } td.amt.dr { color: var(--accent); }
td.muted { color: var(--ink-3); }
.cb { position: relative; display: inline-block; width: 22px; height: 22px; }
.cb input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.cb input:disabled { cursor: not-allowed; }
.cb i { position: absolute; inset: 0; border-radius: 7px; border: 1.5px solid var(--line-strong); background: var(--card-solid); transition: all .15s ease; pointer-events: none; }
.cb i::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform .15s ease; }
.cb input:checked + i { background: var(--accent); border-color: var(--accent); }
.cb input:checked + i::after { transform: rotate(45deg) scale(1); }
.cb input:disabled:checked + i { opacity: .55; }
.cb input:focus-visible + i { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
.empty { padding: 56px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-family: var(--font-display); font-size: 16px; margin-bottom: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-3); font-size: 12px; }
.legend .dr { color: var(--accent); font-weight: 600; } .legend .cr { color: var(--bad); font-weight: 600; }
.ulist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-height: 260px; overflow-y: auto; }
.ulist li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line-strong); }
.ulist li:last-child { border-bottom: 0; }
.u-desc { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.u-date { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); }
.u-amt { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.u-amt.in { color: var(--accent); } .u-amt.out { color: var(--bad); }
.note { color: var(--ink-3); font-size: 12px; margin: 0; }
.foot { color: var(--ink-3); font-size: 12px; }
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card-solid); color: var(--ink); padding: 24px; width: min(420px, calc(100% - 32px)); box-shadow: var(--shadow-lift); }
dialog::backdrop { background: rgba(15,20,28,.5); }
dialog form { display: grid; gap: 16px; }
dialog .field { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s ease; box-shadow: var(--shadow-lift); z-index: 20; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); color: #fff; }
@media (max-width: 520px) { .tray { padding: 16px; } .bar { padding: 16px; } .actions { margin-left: 0; width: 100%; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* sign-in and header extras */
.signout { margin: 0; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(420px, 100%); display: grid; gap: 20px; }
.login h1 { font-size: 28px; }
.login form { display: grid; gap: 16px; }
.login .field { margin: 0; }
.login input[type="password"], .login input[type="text"] { width: 100%; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card-solid); color: var(--ink); font: inherit; font-size: 15px; }
.login input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.login .btn { height: 44px; }
.msg { padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 500; }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.info { background: var(--accent-soft); color: var(--ink-2); }

.sum-row.nob { border-bottom: 0; }
