/* Net Worth — base styles. System fonts only (strict CSP, no external requests). */
:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F7F9FE;
  --ink: #111827;
  --muted: #5B6472;
  --line: #E3E6EB;
  --line-2: #EEF0F4;
  --accent: #1D4ED8;
  --accent-ink: #FFFFFF;
  --accent-soft: #E8EEFC;
  --accent-soft-ink: #1E3A8A;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --warn-ink: #78350F;
  --hero: #111827;
  --hero-ink: #FFFFFF;
  --hero-muted: #CBD5E1;
  --hero-accent: #93C5FD;
  --nav-bg: #0F172A;
  --nav-ink: #CBD5E1;
  --nav-active: #1E293B;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1020;
    --surface: #121A2E;
    --surface-2: #17213A;
    --ink: #E5E9F2;
    --muted: #9AA4B6;
    --line: #243049;
    --line-2: #1C2740;
    --accent: #6B8EF5;
    --accent-ink: #0B1020;
    --accent-soft: #1C2A52;
    --accent-soft-ink: #BBD0FF;
    --warn: #F59E0B;
    --warn-soft: #3A2A0B;
    --warn-ink: #FCD9A0;
    --hero: #1A2642;
    --hero-ink: #FFFFFF;
    --hero-muted: #B6C2D9;
    --hero-accent: #A7C4FF;
    --nav-bg: #070B16;
    --nav-ink: #AFB9CC;
    --nav-active: #18223A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidenav {
  width: 232px; flex: none; background: var(--nav-bg); color: var(--nav-ink);
  padding: 24px 14px; display: flex; flex-direction: column; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: #2563EB; display: grid; place-items: center; }
.brand-name { font-weight: 800; color: #FFFFFF; font-size: 15px; }
.brand-sub { font-size: 12px; color: #94A3B8; }
.sidenav nav { display: flex; flex-direction: column; gap: 2px; }
.sidenav nav a {
  display: block; padding: 11px 12px; border-radius: 8px; color: var(--nav-ink); font-size: 14px;
}
.sidenav nav a:hover { background: var(--nav-active); text-decoration: none; color: #FFFFFF; }
.sidenav nav a[aria-current="page"] { background: var(--nav-active); color: #FFFFFF; font-weight: 600; }
.sidenav .spacer { flex: 1; }
.sidenav form button {
  width: 100%; text-align: left; background: none; border: 0; color: var(--nav-ink); font: inherit;
  font-size: 14px; padding: 11px 12px; border-radius: 8px; cursor: pointer;
}
.sidenav form button:hover { background: var(--nav-active); color: #FFFFFF; }

.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 96px; }
.container { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.page-head .sub { font-size: 13px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.bottomnav { display: none; }

@media (max-width: 860px) {
  .sidenav { display: none; }
  .main { padding: 20px 16px 96px; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 10;
  }
  .bottomnav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px;
    font-size: 11px; font-weight: 600; color: var(--muted);
  }
  .bottomnav a[aria-current="page"] { color: var(--accent); }
  .bottomnav a:hover { text-decoration: none; }
  h1 { font-size: 22px; }
}

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 12px; }
.card-head .meta { font-size: 12px; color: var(--muted); }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
@media (max-width: 400px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.stat { gap: 6px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stat .hint { font-size: 13px; color: var(--muted); }
.stat.hero { background: var(--hero); border-color: var(--hero); color: var(--hero-ink); }
.stat.hero .label { color: var(--hero-muted); }
.stat.hero .hint { color: var(--hero-accent); font-weight: 600; }
.pos { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- bars ---- */
.bar { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.catrow { display: flex; flex-direction: column; gap: 6px; color: inherit; border-radius: 8px; }
a.catrow:hover, a.list-item:hover { text-decoration: none; }
a.catrow:hover .top span, a.list-item:hover .title { color: var(--accent); }
a.list-item { color: inherit; }
@media (max-width: 860px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid-stats .stat.hero { grid-column: 1 / -1; }
  .grid-stats .stat { padding: 16px; }
  .grid-stats .stat .value { font-size: 20px; }
}
.catrow .top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }

/* ---- lists & tables ---- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.list-item:first-child { border-top: 0; }
.list-item .main-col { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list-item .title { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.list-item .sub { font-size: 12px; color: var(--muted); }
.amount { font-weight: 700; white-space: nowrap; }
.amount.in { color: var(--accent); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 10px 8px; }
td { padding: 12px 8px; border-top: 1px solid var(--line-2); vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.is-archived td { color: var(--muted); }

/* ---- forms ---- */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .field .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field .help { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--warn); font-weight: 600; }
input[type="text"], input[type="date"], input[type="search"], input[type="number"], select, textarea {
  height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 15px;
  background: var(--surface); color: var(--ink); width: 100%; min-width: 0;
}
textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.has-error input, .has-error select { border-color: var(--warn); }
.seg { display: inline-flex; padding: 4px; background: var(--line-2); border-radius: 10px; gap: 4px; }
.seg label { display: inline-flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 18px; height: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--warn); }
.btn.small { height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.big { height: 52px; font-size: 16px; padding: 0 22px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 600; }
.linkbtn.danger { color: var(--warn); }

/* ---- notices ---- */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 14px; background: var(--accent-soft); color: var(--accent-soft-ink); }
.notice.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent-soft-ink); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.status { min-height: 20px; font-size: 14px; color: var(--muted); }
.status.is-error { color: var(--warn); font-weight: 600; }

/* ---- period switch ---- */
.period { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.period a { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 42px; color: var(--ink); }
.period a:hover { background: var(--line-2); text-decoration: none; }
.period span { font-size: 14px; font-weight: 600; padding: 0 6px; white-space: nowrap; }

/* ---- bare (login/setup) ---- */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.bare .card { width: 100%; max-width: 420px; gap: 18px; padding: 28px; }
.bare .brand-name { color: var(--ink); font-size: 18px; }
.bare .brand-sub { color: var(--muted); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }
details > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent); min-height: 32px; }

/* transactions table becomes a compact list on phones */
.m-meta { display: none; }
@media (max-width: 640px) {
  .tx-table thead, .tx-table .c-hide-m { display: none; }
  .tx-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; border-top: 1px solid var(--line-2); padding: 10px 0; }
  .tx-table td { border: 0; padding: 0; }
  .tx-table .m-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
  .accounts-table { min-width: 560px; }
}
