/* McLean Family Budget — v1 styles (from the approved mockup) */

:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --accent: #2a78d6;
  --accent-deep: #256abf;
  --track-blue: #cde2fb;
  --good: #0ca30c;
  --good-text: #006300;
  --bad-text: #ac2727;
  --warn: #fab219;
  --warn-track: rgba(250,178,25,0.18);
  --serious: #ec835a;
  --crit: #d03b3b;
  --crit-track: rgba(208,59,59,0.14);
  --deemph: #898781;
  --avatar-blue: #2a78d6;
  --avatar-violet: #4a3aa7;
  --chip: #f0efec;
  --hover-wash: rgba(11,11,11,0.04);
}
[data-theme="dark"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255,255,255,0.10);
  --accent: #3987e5;
  --accent-deep: #3987e5;
  --track-blue: rgba(57,135,229,0.24);
  --good-text: #0ca30c;
  --bad-text: #e66767;
  --warn-track: rgba(250,178,25,0.20);
  --crit-track: rgba(208,59,59,0.22);
  --avatar-blue: #3987e5;
  --avatar-violet: #9085e9;
  --chip: #262624;
  --hover-wash: rgba(255,255,255,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page); color: var(--ink);
  font-size: 14px; line-height: 1.45;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 20px 48px; }
button { font: inherit; }

/* ---------- header ---------- */
header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand h1 { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.brand .sub { font-size: 12px; color: var(--muted); }
.month-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 8px; font-weight: 600; font-size: 13px;
}
.month-pill .m-label { min-width: 96px; text-align: center; }
.month-pill button {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 0 8px; line-height: 1;
}
.month-pill button:hover { color: var(--ink); }
.avatars { display: flex; align-items: center; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  border: 2px solid var(--page);
}
.avatar + .avatar { margin-left: -8px; }
.avatar.blue { background: var(--avatar-blue); }
.avatar.violet { background: var(--avatar-violet); }
.ghost-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.ghost-btn:hover { background: var(--hover-wash); }
nav.tabs { display: flex; gap: 4px; margin: 12px 0 18px; overflow-x: auto; padding-bottom: 2px; }
nav.tabs a {
  text-decoration: none; color: var(--ink-2); font-size: 13px; font-weight: 550;
  padding: 6px 13px; border-radius: 999px; white-space: nowrap; cursor: pointer;
}
nav.tabs a.active { background: var(--ink); color: var(--page); }
nav.tabs a:not(.active):hover { background: var(--hover-wash); }

/* ---------- alerts ---------- */
.alerts { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.alert {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; font-size: 12.5px; color: var(--ink-2);
}
.alert .tag { font-weight: 700; color: var(--ink); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.alert svg { flex: none; }

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.card h2 { font-size: 13px; font-weight: 650; color: var(--ink-2); letter-spacing: 0.01em; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .meta { font-size: 12px; color: var(--muted); }
.top-grid { display: grid; grid-template-columns: 5fr 7fr; gap: 14px; margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.main-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.right-col { display: flex; flex-direction: column; gap: 14px; }

/* ---------- hero ---------- */
.hero { display: flex; flex-direction: column; }
.hero .label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.hero .value { font-size: 50px; font-weight: 650; letter-spacing: -0.02em; margin: 6px 0 2px; }
.hero .value.neg { color: var(--bad-text); }
.hero .explain { font-size: 12.5px; color: var(--muted); max-width: 36ch; }
.hero .math { margin-top: auto; padding-top: 16px; display: grid; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.hero .math div { display: flex; justify-content: space-between; gap: 12px; }
.hero .math .num { font-variant-numeric: tabular-nums; }
.hero .math .total { border-top: 1px solid var(--grid); padding-top: 6px; font-weight: 650; color: var(--ink); }

/* ---------- stat tiles ---------- */
.tile .label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.tile .value { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; margin-top: 3px; }
.tile .delta { font-size: 12px; margin-top: 2px; color: var(--muted); }
.tile .delta .up-bad { color: var(--bad-text); font-weight: 650; }
.tile .delta .up-good { color: var(--good-text); font-weight: 650; }

/* ---------- budget meters ---------- */
.budget-list { display: grid; gap: 15px; }
.brow .line1 { display: flex; align-items: baseline; gap: 8px; }
.brow .name { font-weight: 600; font-size: 13.5px; }
.brow .badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 1.5px 7px; border-radius: 999px; background: var(--chip); color: var(--ink-2);
}
.brow .badge.warn { background: var(--warn-track); }
.brow .badge.crit { background: var(--crit-track); }
.brow .nums { margin-left: auto; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.brow .nums strong { color: var(--ink); font-weight: 650; }
.meter { position: relative; height: 8px; border-radius: 4px; background: var(--track-blue); margin-top: 7px; }
.meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent-deep); max-width: 100%; }
.meter.warn { background: var(--warn-track); } .meter.warn .fill { background: var(--warn); }
.meter.crit { background: var(--crit-track); } .meter.crit .fill { background: var(--crit); }
.meter .pace { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.brow .left-note { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.pace-key { font-size: 11.5px; color: var(--muted); }
.pace-key .tick { display: inline-block; width: 1px; height: 10px; background: var(--muted); vertical-align: -1px; margin: 0 5px 0 2px; }

/* ---------- chart ---------- */
.toggle {
  border: 1px solid var(--border); background: none; color: var(--ink-2);
  font-size: 11.5px; border-radius: 999px; padding: 3px 10px; cursor: pointer;
}
.legend { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .stroke { width: 16px; height: 0; border-top: 2.5px solid; border-radius: 2px; }
.chart-holder { position: relative; }
.chart-holder:focus { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.tooltip {
  position: absolute; pointer-events: none; display: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 11px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  min-width: 130px;
}
.tooltip .t-date { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.tooltip .t-row .stroke { width: 12px; border-top: 2.5px solid; border-radius: 2px; }
.tooltip .t-row .v { font-weight: 650; color: var(--ink); margin-left: auto; font-variant-numeric: tabular-nums; }
.tooltip .t-row .s { color: var(--ink-2); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { text-align: right; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.data-table td:first-child { color: var(--ink); }
svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }

/* ---------- transactions ---------- */
.tx-table { width: 100%; border-collapse: collapse; }
.tx-table td { padding: 9px 6px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tx-table tr.tx-row { cursor: pointer; }
.tx-table tr.tx-row:hover td { background: var(--hover-wash); }
.tx-table tr:last-child td { border-bottom: 0; }
.tx-table .d { color: var(--muted); font-size: 12px; white-space: nowrap; width: 52px; }
.tx-table .m { font-weight: 600; font-size: 13.5px; }
.tx-table .m .note-ic { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; font-size: 11px; color: var(--accent-deep); font-weight: 650; vertical-align: 1px; }
.tx-table .cat { width: 140px; }
.chip {
  display: inline-block; font-size: 11px; font-weight: 600; color: var(--ink-2);
  background: var(--chip); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.chip.uncat { background: var(--warn-track); color: var(--ink); }
.tx-table .who { width: 34px; text-align: center; }
.mini-avatar {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; color: #fff; font-size: 10px; font-weight: 700;
}
.mini-avatar.blue { background: var(--avatar-blue); } .mini-avatar.violet { background: var(--avatar-violet); }
.mini-avatar.none { background: var(--chip); color: var(--muted); }
.tx-table .amt { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; width: 92px; }
.tx-table .amt.in { color: var(--good-text); }

/* ---------- forms ---------- */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], select, textarea {
  font: inherit; color: var(--ink); background: var(--page);
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--ink); color: var(--page); border: 0; border-radius: 999px;
  padding: 9px 18px; font-size: 13.5px; font-weight: 650; cursor: pointer;
}
.btn:hover { opacity: 0.88; }
.btn.secondary { background: none; color: var(--ink); border: 1px solid var(--border); }
.btn.danger { background: none; color: var(--bad-text); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.5; cursor: default; }
.form-row { display: flex; gap: 10px; }
.form-row .field { flex: 1; }
.form-err { color: var(--bad-text); font-size: 12.5px; margin: 4px 0 10px; min-height: 1em; }
.hint { font-size: 11.5px; color: var(--muted); }
.check { display: flex; gap: 7px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: none; color: var(--ink-2); padding: 6px 14px; font-size: 12.5px; cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--page); font-weight: 650; }

/* ---------- auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card { padding: 26px; }
.auth-card h1 { font-size: 20px; font-weight: 650; margin-bottom: 2px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.auth-switch { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.auth-switch a { color: var(--accent-deep); cursor: pointer; text-decoration: none; font-weight: 600; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.42); z-index: 40;
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; padding: 22px;
}
.modal h3 { font-size: 15px; font-weight: 650; margin-bottom: 14px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal .actions .left { margin-right: auto; }

/* comments */
.comments { border-top: 1px solid var(--grid); margin-top: 16px; padding-top: 12px; }
.comments h4 { font-size: 12px; font-weight: 650; color: var(--ink-2); margin-bottom: 8px; }
.comment { display: flex; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.comment .body { background: var(--chip); border-radius: 10px; padding: 6px 10px; }
.comment .meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; }

/* splits */
.split-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.split-row select { flex: 1; }
.split-row input { width: 110px; }
.split-row .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; }

/* ---------- planned breakdown on dashboard ---------- */
.brow.has-plan { cursor: pointer; }
.plan-hint { color: var(--accent-deep); font-weight: 600; }
.plan-list { margin: 8px 0 2px 2px; border-left: 2px solid var(--grid); padding-left: 10px; display: grid; gap: 3px; }
.plan-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.plan-row span:last-child { font-variant-numeric: tabular-nums; }

/* ---------- budget editor ---------- */
.bud-row { border-bottom: 1px solid var(--grid); padding: 6px 0; }
.bud-row:last-child { border-bottom: 0; }
.bud-main { display: flex; align-items: center; gap: 8px; }
.bud-main .n { font-weight: 600; flex: 1; min-width: 0; }
.bud-main .spent { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bud-main .amt-in { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.bud-main .amt-in:disabled { color: var(--muted); background: var(--chip); }
.chev {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px;
  width: 22px; height: 22px; border-radius: 6px; transition: transform 0.12s; flex: none;
}
.chev:hover { background: var(--hover-wash); color: var(--ink); }
.chev.open { transform: rotate(90deg); }
.bud-lines { margin: 8px 0 4px 30px; display: grid; gap: 8px; justify-items: start; }
.line-row { display: flex; gap: 8px; align-items: center; width: 100%; }
.line-row input[type="text"]:first-child { flex: 1; }
.line-row .line-amt { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.line-row .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.line-row .x:hover { color: var(--bad-text); }
.bud-edit { width: 100%; border-collapse: collapse; }
.bud-edit td { padding: 8px 6px; border-bottom: 1px solid var(--grid); }
.bud-edit tr:last-child td { border-bottom: 0; }
.bud-edit .n { font-weight: 600; }
.bud-edit .amt-in { width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.bud-edit .spent { text-align: right; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bud-total { display: flex; justify-content: space-between; font-weight: 650; padding: 12px 6px 0; }

/* ---------- import ---------- */
.import-map { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.import-preview { max-height: 260px; overflow: auto; border: 1px solid var(--grid); border-radius: 10px; margin-top: 12px; }
.import-preview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.import-preview th { position: sticky; top: 0; background: var(--surface); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); color: var(--muted); }
.import-preview td { padding: 5px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.drop {
  border: 1.5px dashed var(--axis); border-radius: 12px; padding: 28px; text-align: center;
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.drop:hover, .drop.over { background: var(--hover-wash); }

/* ---------- recurring & bills ---------- */
.rec-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.rec-row:last-child { border-bottom: 0; }
.rec-row .date {
  flex: none; width: 44px; text-align: center; border: 1px solid var(--border); border-radius: 8px;
  padding: 3px 0; line-height: 1.15;
}
.rec-row .date .mo { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.rec-row .date .d { font-size: 15px; font-weight: 650; }
.rec-row .who { min-width: 0; display: grid; }
.rec-row .who .n { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-row .who .hint { font-size: 11px; }
.rec-row .price-up { font-size: 11px; color: var(--bad-text); font-weight: 600; }
.rec-row .amt { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rec-row.overdue .date { border-color: var(--warn); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--page); border-radius: 999px;
  padding: 9px 18px; font-size: 13px; font-weight: 600; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
#toast.show { opacity: 1; }

/* misc */
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 26px 10px; }
footer { margin-top: 22px; font-size: 11.5px; color: var(--muted); text-align: center; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .top-grid, .main-grid { grid-template-columns: 1fr; }
  .hero .value { font-size: 44px; }
}
@media (max-width: 520px) {
  .wrap { padding: 14px 12px 40px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile .value { font-size: 20px; }
  .tx-table .cat { display: none; }
  .form-row { flex-direction: column; gap: 0; }
}
