:root {
  --bg: #f6f7f9;
  --panel: #fff;
  --panel2: #fbfcfd;
  --ink: #17212b;
  --muted: #687382;
  --line: #d9dee6;
  --brand: #d96b00;
  --bad: #bb3d3d;
  --good: #167447;
  --warn: #b77418;
}
body.dark {
  --bg: #11161d;
  --panel: #18212b;
  --panel2: #202b36;
  --ink: #edf2f7;
  --muted: #aab5c2;
  --line: #334251;
  --brand: #f08a24;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--ink); }
.topbar, .tabs { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 22px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tabs { justify-content: flex-start; position: sticky; top: 0; z-index: 3; }
h1 { margin: 0; font-size: 22px; }
main { padding: 22px; max-width: 1440px; margin: auto; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }
.actions, .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
button, .button, input, select, textarea { font: inherit; }
button, .button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px; min-height: 38px; padding: 8px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.danger { color: var(--bad); }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px; background: var(--panel); color: var(--ink); min-height: 38px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.password-control { display: flex; gap: 8px; align-items: center; }
.password-control button { flex: 0 0 auto; min-width: 78px; }
.finance-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; align-items: end; }
.finance-form-grid label { margin: 0; }
.finance-wide { grid-column: span 2; }
.finance-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.due-today { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.due-card { border: 1px solid var(--line); border-left: 5px solid var(--brand); background: var(--panel); padding: 14px; border-radius: 8px; }
.due-card.pay { border-left-color: var(--bad); }
.due-card.receive { border-left-color: var(--good); }
.due-card > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.due-card strong { font-size: 20px; }
.due-list { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.due-list li { display: flex; justify-content: space-between; gap: 14px; padding-top: 9px; margin-top: 9px; }
.due-list b { white-space: nowrap; }
.due-empty { margin: 12px 0 0; }
.total-line { color: var(--muted); font-weight: 700; margin: 0 0 10px; }
.negative { color: var(--bad) !important; }
.column-chart { min-height: 280px; display: flex; gap: 28px; align-items: end; justify-content: center; padding: 18px 12px 0; border-bottom: 1px solid var(--line); }
.column-group { width: min(180px, 30%); display: grid; grid-template-rows: auto 190px auto; gap: 8px; text-align: center; }
.column-value { min-height: 20px; font-size: 13px; font-weight: 700; }
.column-area { height: 190px; display: flex; align-items: end; justify-content: center; background: var(--panel2); border: 1px solid var(--line); border-bottom: 0; }
.column-bar { width: min(80px, 60%); min-height: 9px; border-radius: 5px 5px 0 0; }
.column-bar.income { background: var(--good); }
.column-bar.expense { background: var(--brand); }
.column-bar.balance { background: #277da1; }
.column-bar.negative { background: var(--bad); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px; text-align: left; vertical-align: top; }
th { color: var(--muted); background: var(--panel2); }
.table { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); }
.error { color: var(--bad); }
.backup-feedback { color: var(--good); font-size: 13px; font-weight: 700; }
.kpi { font-size: 28px; font-weight: 800; }
@media (max-width: 900px) { .span-3,.span-4,.span-6 { grid-column: span 12; } .finance-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 580px) { .finance-form-grid { grid-template-columns: 1fr; } .finance-wide { grid-column: span 1; } .finance-actions { justify-content: stretch; } .finance-actions button { width: 100%; justify-content: center; } }
@media (max-width: 700px) { .due-today { grid-template-columns: 1fr; } }
@media (max-width: 580px) { .column-chart { gap: 10px; padding-inline: 0; } .column-group { width: 32%; } .column-value { font-size: 11px; } }
