/* Budget app — styles. Self-contained, no external fonts or assets. */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #101828;
  --ink-2: #475467;
  --line: #e4e7ec;
  --track: #eaecf0;
  --accent: #3b6ef6;
  --accent-2: #e8efff;
  --good: #12a15c;
  --bad: #d92d20;
  --warn: #b54708;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --panel: #161b24;
    --ink: #eef2f7;
    --ink-2: #9aa4b2;
    --line: #232a35;
    --track: #232a35;
    --accent: #6d94ff;
    --accent-2: #1b2436;
    --good: #3ddc84;
    --bad: #ff6b5e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0 0 6px; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; margin-top: 18px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.dim { opacity: .55; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.ra { text-align: right; }

/* ---------- chrome ---------- */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand h1 { font-size: 18px; }
.logo {
  font-size: 22px; width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--accent-2); border-radius: 12px;
}
.month { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tabs {
  display: flex; gap: 4px; padding: 8px 16px; overflow-x: auto;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 71px; z-index: 19;
}
.tabbtn {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.tabbtn:hover { background: var(--track); color: var(--ink); }
.tabbtn.on { background: var(--accent); color: #fff; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; }
kbd {
  background: var(--track); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; font: 12px ui-monospace, Menlo, monospace;
}

/* ---------- panels + cards ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 18px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel > header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel > header h2 { margin: 0; }
.panel > header .muted, .panel > header .row-actions { margin-left: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.hero { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.hero.small { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .hero, .hero.small { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .hero, .hero.small { grid-template-columns: repeat(2, 1fr); } }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.card-l { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.card-v { font-size: 22px; font-weight: 700; margin: 4px 0 2px; }
.card-s { font-size: 12px; color: var(--ink-2); }
.card.in .card-v { color: var(--good); }
.card.out .card-v { color: var(--ink); }
.card.good .card-v { color: var(--good); }
.card.bad .card-v { color: var(--bad); }
.card.accent .card-v { color: var(--accent); }

/* ---------- budget rows ---------- */
.brow { margin-bottom: 14px; }
.brow-top { display: flex; align-items: baseline; gap: 8px; }
.bname { font-weight: 600; }
.bnum { margin-left: auto; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.bar > i { display: block; height: 100%; border-radius: 999px; }
.brow-sub { display: flex; gap: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.chip {
  font-size: 11.5px; background: var(--track); color: var(--ink-2); border-radius: 999px;
  padding: 2px 8px; font-weight: 600;
}
.chip.good { background: rgba(18, 161, 92, .14); color: var(--good); }
.chip.bad { background: rgba(217, 45, 32, .14); color: var(--bad); }
.tag {
  font-size: 10.5px; border: 1px solid var(--line); border-radius: 5px; padding: 0 4px;
  color: var(--ink-2); vertical-align: middle;
}

/* ---------- lists / tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); border-bottom: 2px solid var(--line); }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--accent-2) 45%, transparent); }
.tbl tfoot th { border-top: 2px solid var(--line); font-weight: 700; }
.bills { list-style: none; margin: 0; padding: 0; }
.bills li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bills li:last-child { border-bottom: 0; }
.bills .row-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bills .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { list-style: none; margin: 8px 0 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.legend li b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend-inline { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.sw.inc { background: var(--good); }
.sw.exp { background: var(--accent); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.bar-inc { fill: var(--good); opacity: .85; }
.bar-exp { fill: var(--accent); opacity: .85; }
.axis { font-size: 9px; fill: var(--ink-2); text-anchor: middle; }
.axis-line { stroke: var(--line); stroke-width: 1; }
.grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.axis-y { text-anchor: start; }
.brow-sub .muted-chip { background: var(--track); color: var(--ink-2); }
.donut-wrap { display: flex; justify-content: center; }
.donut { max-width: 230px; }
.donut-mid { text-anchor: middle; font-size: 17px; font-weight: 700; fill: var(--ink); }
.donut-sub { text-anchor: middle; font-size: 10px; fill: var(--ink-2); }
.ring { width: 92px; height: 92px; flex: 0 0 92px; }
.ring-txt { text-anchor: middle; font-size: 16px; font-weight: 700; fill: var(--ink); }

/* ---------- goals ---------- */
.goals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .goals { grid-template-columns: 1fr; } }
.goal { display: flex; align-items: center; gap: 14px; }
.goal.wide {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; align-items: flex-start;
}
.goal-body { flex: 1; }
.goal-body .row-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mini { margin-top: 8px; }
.mini summary { cursor: pointer; color: var(--ink-2); font-size: 12.5px; }
.clist { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
.clist li { display: flex; gap: 10px; align-items: center; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.clist li span:first-child { min-width: 74px; }
.clist li span:nth-child(2) { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- forms + buttons ---------- */
.inp {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.inp:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--panel); }
.inp.narrow { width: auto; min-width: 90px; }
.inp.num { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.inp.color { width: 60px; padding: 3px; height: 38px; }
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline > span { margin: 0; display: inline; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters .inp { width: auto; }
.btn {
  display: inline-block; border: 1px solid transparent; background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--track); }
.btn.ghost.danger { color: var(--bad); }
.btn.tiny { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.wide { width: 100%; text-align: center; }
.row-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- auth screens ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px; box-shadow: var(--shadow);
}
.auth-title { font-size: 22px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---------- dialog + toast ---------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(520px, 94vw);
  background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(10, 15, 25, .55); }
#dlg-form { padding: 20px 22px 16px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin: 14px 0 0; padding: 0; }
.toast {
  position: fixed; left: 50%; transform: translate(-50%, 20px); bottom: 22px; z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: .96; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- print ---------- */
@media print {
  :root { --shadow: none; }
  .top, .tabs, .foot, .row-actions, #toast, #month-prev, #month-next, #month-pick, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .panel { break-inside: avoid; box-shadow: none; border-color: #ccc; }
  .wrap { max-width: none; padding: 0; }
  .tbl th, .tbl td { border-color: #ccc; }
}
