:root {
  --bg: #f3f5f4; --card: #fff; --ink: #17211d; --muted: #66736d; --line: #dfe5e2;
  --brand: #0b6b4f; --brand-ink: #fff; --brand-soft: #e3f2ec; --neg: #b3261e; --pos: #0b6b4f; --warn: #8a5a00; --warn-bg: #fff4d6;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.08rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 18px; padding-bottom: 48px; }

.top { background: var(--brand); color: var(--brand-ink); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #fff; color: var(--brand); font-weight: 800; }
.who { font-size: .88rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.role { background: rgba(255,255,255,.2); border-radius: 99px; padding: 1px 8px; font-size: .75rem; text-transform: capitalize; }
.who .link { color: #fff; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs a { color: rgba(255,255,255,.85); text-decoration: none; padding: 9px 13px; border-radius: 8px 8px 0 0; white-space: nowrap; font-weight: 600; font-size: .92rem; }
.tabs a.on { background: var(--bg); color: var(--brand); }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.subtabs a { padding: 6px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .9rem; }
.subtabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.report-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.report-title h2 { margin: 0; font-size: 1.2rem; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters label { display: flex; align-items: center; gap: 6px; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card.narrow { max-width: 440px; margin: 32px auto; }
.cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile span { color: var(--muted); font-size: .82rem; }
.tile b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); }
.tile.accent { background: var(--brand-soft); border-color: #bfe0d3; }

label { display: block; font-size: .85rem; font-weight: 600; color: #34413c; margin-bottom: 10px; }
label small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid #c5cfca; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.filters input, .filters select { width: auto; margin-top: 0; }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: .88rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 12px; }
.grid .wide { grid-column: 1 / -1; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.hint { color: var(--brand); font-weight: 600; font-size: .9rem; }
.subform { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.inline { display: inline; }

.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid #c5cfca; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
.danger { color: var(--neg); }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tfoot th { border-top: 2px solid var(--ink); border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }
.strong { font-weight: 700; }
tr.group td { background: #f0f4f2; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #44524c; }
tr.void td { color: #9aa5a0; text-decoration: line-through; }
tr.sel td { background: var(--brand-soft); }
.edit-table input, .edit-table select { margin-top: 0; padding: 6px 8px; min-width: 84px; }
.edit-table input.tiny { min-width: 60px; width: 64px; }
.edit-table input[type=checkbox] { min-width: 0; width: auto; }
.close-table input { max-width: 170px; text-align: right; margin-top: 0; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eceff0; color: #37433e; white-space: nowrap; }
.tag.deposit { background: #dff1e8; color: #0b5a43; }
.tag.withdraw { background: #e2ecfb; color: #1c4a94; }
.tag.expense, .tag.drawing { background: #fde7e5; color: #8e1f18; }
.tag.debt_given, .tag.debt_repaid { background: #fff0cf; color: #6d4700; }
.tag.adjustment { background: #f3e3f7; color: #6a2380; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); font-size: .86rem; }
.pill.closed { background: var(--brand-soft); border-color: #bfe0d3; color: #0b5a43; font-weight: 600; }
.pill.open { background: var(--warn-bg); border-color: #efd68f; color: var(--warn); }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid; }
.flash.ok { background: var(--brand-soft); border-color: #bfe0d3; color: #0b5a43; }
.flash.err { background: #fde7e5; border-color: #f3b9b4; color: #8e1f18; }
.flash.warn { background: var(--warn-bg); border-color: #efd68f; color: var(--warn); }
.flash.info { background: #e8effa; border-color: #c3d4f0; color: #1c4a94; }

@media (max-width: 860px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .tile b { font-size: 1.15rem; }
}
@media print {
  .top, .no-print, .flash { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .card, .tile { border-color: #999; break-inside: avoid; }
  main.wrap { padding: 0; max-width: none; }
}
