/* stats — three themes (dark / dim / light), mint accent. System fonts only (CSP: nothing external). */
:root, :root[data-theme="dark"] {
  --bg: #12161d;
  --panel: #1a1f29;
  --panel-2: #212734;
  --hover: #262d3b;
  --line: #2a3140;
  --text: #e6e9ef;
  --muted: #8a93a3;
  --dim: #636c7b;
  --accent: #3ecfb2;
  --accent-ink: #0b2a24;
  --accent-soft: rgba(62, 207, 178, .13);
  --pos: #34c98a;
  --pos-soft: rgba(52, 201, 138, .12);
  --neg: #ff6b6b;
  --neg-soft: rgba(255, 107, 107, .12);
  --warn: #f2b441;
  --warn-soft: rgba(242, 180, 65, .14);
  --info: #6aa8ff;
  --shadow: 0 1px 0 rgba(255, 255, 255, .02), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
:root[data-theme="dim"] {
  --bg: #232a35;
  --panel: #2c3442;
  --panel-2: #343d4d;
  --hover: #3a4456;
  --line: #3d4757;
  --text: #eef1f5;
  --muted: #a3acba;
  --dim: #7d8797;
  --accent: #47d6b9;
  --accent-ink: #0b2a24;
  --accent-soft: rgba(71, 214, 185, .15);
  --pos: #45d496;
  --pos-soft: rgba(69, 212, 150, .14);
  --neg: #ff7b7b;
  --neg-soft: rgba(255, 123, 123, .14);
  --warn: #f5c15c;
  --warn-soft: rgba(245, 193, 92, .16);
  --info: #7db4ff;
  --shadow: 0 8px 24px rgba(0, 0, 0, .18);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f6f8fa;
  --hover: #eef2f5;
  --line: #e2e7ec;
  --text: #1c2430;
  --muted: #6b7685;
  --dim: #98a1ad;
  --accent: #0f9f86;
  --accent-ink: #ffffff;
  --accent-soft: rgba(15, 159, 134, .10);
  --pos: #12915f;
  --pos-soft: rgba(18, 145, 95, .09);
  --neg: #e0484f;
  --neg-soft: rgba(224, 72, 79, .08);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, .10);
  --info: #2f6fd6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 18px rgba(16, 24, 40, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }

.btn { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 14px; cursor: pointer;
  font-weight: 600; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.ghost { background: transparent; }

/* ---------- top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 22px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; letter-spacing: .02em; }
.brand .dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; }
.themes { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.themes button { width: 30px; height: 26px; border: 0; background: transparent; border-radius: 7px; cursor: pointer;
  display: grid; place-items: center; color: var(--muted); }
.themes button:hover { color: var(--text); }
.themes button.on { background: var(--accent-soft); color: var(--accent); }
.themes svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.themes svg .fill { fill: currentColor; stroke: none; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 272px 1fr; min-height: calc(100vh - 58px); }
.side { border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 58px; height: calc(100vh - 58px);
  overflow-y: auto; }
.side-total { padding: 4px 8px 16px; }
.label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.side-sum { font-size: 24px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.wlist { display: flex; flex-direction: column; gap: 6px; }
.wcard { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: 12px; padding: 10px 12px 10px 14px; cursor: pointer; position: relative; }
.wcard:hover { background: var(--hover); }
.wcard.on { background: var(--panel); border-color: var(--line); box-shadow: var(--shadow); }
.wcard.on::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px;
  background: var(--accent); }
.wcard .n { font-weight: 700; font-size: 14px; }
.wcard .b { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; margin-top: 1px; }
.wcard .a { font-size: 11.5px; color: var(--dim); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.wcard .p { font-size: 11.5px; color: var(--muted); }

.main { padding: 22px 28px 60px; min-width: 0; }
.err { background: var(--neg-soft); border: 1px solid var(--neg); color: var(--neg); padding: 10px 14px; border-radius: 10px;
  margin-bottom: 16px; }

/* ---------- wallet header */
.whead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.whead h1 { margin: 0; font-size: 24px; font-weight: 800; }
.whead .addrs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.chip { font-size: 11.5px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 9px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px;
  flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 600; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- summary cards */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.card .v { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.card .s { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.card.hero .v { font-size: 28px; }
.bar { height: 6px; border-radius: 6px; background: var(--neg-soft); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--pos); border-radius: 6px; }

/* ---------- tabs + panels */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { border: 0; background: transparent; padding: 9px 14px; cursor: pointer; color: var(--muted); font-weight: 650;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .cnt { font-size: 11.5px; color: var(--dim); margin-left: 5px; font-weight: 600; }
.subtabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; cursor: pointer;
  font-size: 12.5px; color: var(--muted); font-weight: 600; }
.pill.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 14px; white-space: nowrap; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line); background: var(--panel-2); }
td { border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
.r { text-align: right; }
.tok { font-weight: 700; }
.route { color: var(--muted); font-size: 12.5px; }
.when { color: var(--muted); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 6px;
  vertical-align: 1px; letter-spacing: .02em; }
.tag.est { background: var(--warn-soft); color: var(--warn); }
.tag.lp { background: var(--accent-soft); color: var(--accent); }
.tag.bad { background: var(--neg-soft); color: var(--neg); }
.tag.open { background: var(--panel-2); color: var(--muted); }
.info { cursor: help; color: var(--dim); margin-left: 6px; font-size: 12px; }
.more { display: block; margin: 12px auto 0; }
.empty { color: var(--muted); padding: 28px 16px; text-align: center; }

/* ---------- expenses list */
.rows { padding: 6px 0; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); }
.row .k b { color: var(--text); font-weight: 600; }
.row.total { background: var(--panel-2); font-weight: 800; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login { width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px;
  box-shadow: var(--shadow); }
.login .brand { margin-bottom: 22px; }
.login label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.pw { display: flex; gap: 6px; margin-bottom: 14px; }
.pw input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  padding: 9px 11px; font-size: 14px; }
.pw input:focus { outline: none; border-color: var(--accent); }
.pw button { background: transparent; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); padding: 0 10px;
  cursor: pointer; font-size: 12px; }
.login .btn { width: 100%; padding: 10px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.msg { color: var(--neg); font-size: 13px; margin-top: 10px; min-height: 18px; }

@media (max-width: 1100px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } .two { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .wlist { flex-direction: row; overflow-x: auto; }
  .wcard { min-width: 170px; }
  .main { padding: 18px 14px 40px; }
  .top { padding: 10px 14px; }
}
