/* Finance - one quiet stylesheet. Light by default, dark when the system asks for it. */
:root {
    --bg: #f6f7f9; --panel: #ffffff; --ink: #1d2330; --muted: #6b7280; --line: #e3e6eb;
    --accent: #2f5d8a; --pos: #1f7a4d; --neg: #b3261e; --badge: #eef2f7; --hover: #f0f4f9;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
    :root { --bg: #14171c; --panel: #1c2027; --ink: #e6e8ec; --muted: #9aa1ad; --line: #2c313a;
            --accent: #7fb0e0; --pos: #5cc28d; --neg: #f07b72; --badge: #262b34; --hover: #232832; }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.4; }
a { color: var(--accent); text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); letter-spacing: .02em; }
.top nav { display: flex; gap: 16px; flex: 1; }
.top nav a { color: var(--muted); padding: 4px 0; }
.top nav a[aria-current="page"] { color: var(--ink); border-bottom: 2px solid var(--accent); }
.logout button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; }
main { padding: 20px 24px 48px; max-width: 1280px; margin: 0 auto; }

/* accounts */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.account { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--ink); }
.account:hover { background: var(--hover); }
.account.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.account .name { font-weight: 600; }
.account .bank, .account .asof { color: var(--muted); font-size: .8rem; }
.account .balance { font-size: 1.25rem; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* filters and summary */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters select, .filters input[type="search"], .filters button { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
.filters input[type="search"] { min-width: 240px; flex: 1; }
.filters button { background: var(--accent); color: #fff; border-color: var(--accent); cursor: pointer; padding: 6px 14px; }
.filters .check { color: var(--muted); font-size: .9rem; display: flex; gap: 6px; align-items: center; }
.summary { display: flex; flex-wrap: wrap; gap: 24px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; color: var(--muted); }
.summary .money { font-weight: 600; }

/* the table */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.pos { color: var(--pos); } .money.neg { color: var(--neg); } .money.zero { color: var(--muted); }
table.tx { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tx th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tx td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tx tr:last-child td { border-bottom: 0; }
.tx tr:hover td { background: var(--hover); }
.tx .num { text-align: right; }
.tx .date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.tx .payee { font-weight: 500; }
.tx .purpose { display: block; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.tx .none { color: var(--muted); font-style: italic; }
.tx tr.transfer .payee, .tx tr.transfer .money { opacity: .6; }
.tx tr.part td { padding-top: 2px; padding-bottom: 4px; border-bottom: 0; font-size: .9rem; }
.tx tr.part td:nth-child(3) { padding-left: 28px; }
.tx tr.total + tr.part td { border-top: 0; }
.tx .empty { text-align: center; color: var(--muted); padding: 24px; }
.badge { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 4px; background: var(--badge); color: var(--muted); font-size: .75rem; vertical-align: 1px; }
.pages { display: flex; gap: 16px; justify-content: center; margin-top: 16px; color: var(--muted); }

/* sign in, code, setup */
body.bare { display: grid; place-items: center; min-height: 100vh; }
.gate { width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.gate h1 { margin: 0 0 16px; font-size: 1.4rem; }
.gate form { display: flex; flex-direction: column; gap: 8px; }
.gate label { color: var(--muted); font-size: .9rem; }
.gate input[type="password"], .gate input[type="text"]:not(.sr-only) { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
.gate button { margin-top: 8px; font: inherit; padding: 8px 12px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
.gate .error { color: var(--neg); }
.gate.setup .qr { background: #fff; border-radius: 8px; margin: 8px 0; }
.gate.setup .qr svg { width: 100%; height: auto; display: block; }
.gate .key code { user-select: all; overflow-wrap: anywhere; }

@media (max-width: 720px) {
    .top { padding: 10px 16px; gap: 12px; }
    main { padding: 16px; }
    .tx th:nth-child(2), .tx td:nth-child(2) { display: none; }
}
