/* ---------------------------------------------------------------- tokens */
:root {
  --bg:        #f4f5f3;
  --surface:   #ffffff;
  --surface-2: #eceeeb;
  --text:      #161c1f;
  --text-2:    #58646a;
  --line:      #dde2df;
  --line-2:    #b5bfba;
  --accent:    #0c6e77;
  --accent-wash:#dcecee;
  --good:      #1d7a4c;
  --bad:       #a8392a;
  --warn:      #8f5c0e;
  --warn-wash: #f5e8d2;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(16,24,28,.06), 0 4px 14px rgba(16,24,28,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #11161a;
    --surface:   #171e22;
    --surface-2: #1d252a;
    --text:      #dde4e5;
    --text-2:    #8c989e;
    --line:      #262f35;
    --line-2:    #3c474e;
    --accent:    #45b8bf;
    --accent-wash:#11363a;
    --good:      #4cb87d;
    --bad:       #e07a66;
    --warn:      #d79a42;
    --warn-wash: #392b12;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #11161a; --surface: #171e22; --surface-2: #1d252a;
  --text: #dde4e5; --text-2: #8c989e; --line: #262f35; --line-2: #3c474e;
  --accent: #45b8bf; --accent-wash: #11363a;
  --good: #4cb87d; --bad: #e07a66; --warn: #d79a42; --warn-wash: #392b12;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- sign in */
body.centered { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.signin-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  padding: 40px 36px; max-width: 420px; text-align: center;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 20px;
}
.signin-card h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
.lede { color: var(--text-2); font-size: .94rem; margin: 0 0 26px; }
.gbtn-wrap { display: flex; justify-content: center; min-height: 44px; }
.fineprint { color: var(--text-2); font-size: .78rem; margin: 22px 0 0; }
.msg { font-size: .88rem; margin: 14px 0 0; color: var(--text-2); }
.msg.err { color: var(--bad); }

/* ---------------------------------------------------------------- shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand h1 { font-size: 1.02rem; }
.topbar .brand-mark { width: 28px; height: 28px; font-size: 16px; border-radius: 7px; }
.spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 9px; font-size: .86rem; color: var(--text-2); }
.userchip img { width: 28px; height: 28px; border-radius: 50%; }

.tabs { display: flex; gap: 2px; padding: 0 20px; background: var(--surface);
        border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .9rem; color: var(--text-2);
  padding: 11px 14px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 80px; }
.panel { display: none; }
.panel.active { display: block; }

/* ---------------------------------------------------------------- pieces */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 18px; }
.card h2 { font-size: .96rem; margin: 0 0 14px; letter-spacing: -.005em; }
.card h2 .sub { font-weight: 400; color: var(--text-2); font-size: .85rem; margin-left: 8px; }

.grid { display: grid; gap: 18px; }
.grid.tiles  { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }
.grid.charts { grid-template-columns: 1.55fr 1fr; }
@media (max-width: 900px) { .grid.charts { grid-template-columns: 1fr; } }

.tile { background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: .73rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); }
.tile .value { font-size: 1.6rem; font-weight: 650; margin-top: 5px; letter-spacing: -.02em; }
.tile .foot  { font-size: .78rem; color: var(--text-2); margin-top: 3px; }
.tile.in  .value { color: var(--good); }
.tile.out .value { color: var(--bad); }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .75rem;
              color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
input, select, button, textarea { font: inherit; }
input[type=text], input[type=date], input[type=number], input[type=month], select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 9px; font-size: .88rem;
}
input:focus-visible, select:focus-visible, button:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn {
  appearance: none; cursor: pointer; border-radius: 7px; font-size: .88rem;
  padding: 7px 14px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.checkbox { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--text-2); }

/* --------------------------------------------------------------- upload */
.drop {
  border: 1.5px dashed var(--line-2); border-radius: var(--radius);
  padding: 22px; text-align: center; background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-wash); }
.drop p { margin: 6px 0 0; color: var(--text-2); font-size: .87rem; }

.note { border-radius: 8px; padding: 11px 14px; font-size: .88rem; margin-top: 14px; }
.note.ok   { background: var(--accent-wash); border-left: 3px solid var(--accent); }
.note.err  { background: var(--warn-wash);   border-left: 3px solid var(--bad); }
.note ul { margin: 7px 0 0; padding-left: 18px; }
.note code { font-size: .85em; }

/* ---------------------------------------------------------------- charts */
.chart-box { position: relative; height: 290px; }
.legend { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.legend-row { display: grid; grid-template-columns: 11px 1fr auto auto;
              gap: 9px; align-items: center; font-size: .85rem; }
.swatch { width: 11px; height: 11px; border-radius: 3px; }
.legend-row .amt { font-weight: 600; }
.legend-row .pct { color: var(--text-2); font-size: .8rem; min-width: 38px; text-align: right; }

/* ---------------------------------------------------------------- tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
             background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .87rem; min-width: 760px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: .71rem; text-transform: uppercase; letter-spacing: .07em;
           color: var(--text-2); background: var(--surface-2); font-weight: 600;
           position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.amt { text-align: right; font-weight: 600; white-space: nowrap; }
td.amt.credit { color: var(--good); }
td.amt.debit  { color: var(--bad); }
td.narr { max-width: 340px; }
td.narr .payee { font-weight: 600; }
td.narr .full  { color: var(--text-2); font-size: .78rem; display: block;
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem;
        padding: 2px 8px; border-radius: 999px; background: var(--surface-2);
        border: 1px solid var(--line); }
.pill.review { background: var(--warn-wash); border-color: var(--warn); color: var(--warn); }
select.cat { font-size: .82rem; padding: 4px 6px; max-width: 170px; }

.empty { text-align: center; color: var(--text-2); padding: 34px 16px; font-size: .9rem; }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--line-2);
           border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
           vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.list { display: flex; flex-direction: column; gap: 1px; }
.list-row { display: grid; grid-template-columns: 1fr auto; gap: 12px;
            padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: .87rem; }
.list-row:last-child { border-bottom: 0; }
.list-row .meta { color: var(--text-2); font-size: .79rem; }
