/* Mobile-first: one column, a bottom tab bar within thumb reach, large tap targets.
   Colours are tokens so dark mode only redefines them. */
:root {
    --bg: #f5f6f4;
    --surface: #ffffff;
    --fg: #1d2420;
    --muted: #5f6b64;
    --line: #dfe3df;
    --accent: #1f6f5c;
    --accent-fg: #ffffff;
    --positive: #1f7a46;
    --negative: #b3261e;
    --warn: #8a5a00;
    --warn-bg: #fbf0d9;
    --ok-bg: #e2f2e8;
    --radius: 12px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111513;
        --surface: #1a201d;
        --fg: #e7ece9;
        --muted: #9aa7a0;
        --line: #2c3530;
        --accent: #5cc3a6;
        --accent-fg: #0d1a16;
        --positive: #6fd19a;
        --negative: #f2857b;
        --warn: #e8b85a;
        --warn-bg: #3a2c10;
        --ok-bg: #18342a;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

h1 { font-size: 1.6rem; margin: 0.5rem 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin: 1.5rem 0 0.5rem; color: var(--muted); font-weight: 600; }
h1:focus { outline: none; }

/* Layout */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 1rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; color: var(--fg); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }

.content {
    flex: 1;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    padding: 0.5rem 1rem calc(5.5rem + env(safe-area-inset-bottom, 0px));
}

.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 5;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar a {
    flex: 1;
    text-align: center;
    padding: 0.9rem 0.25rem;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.tabbar a.active { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* Surfaces */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
}

.panel h2 { margin-top: 0; }
.narrow { max-width: 24rem; margin: 2rem auto; }

.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin: 0; }
.figures dt { font-size: 0.8rem; color: var(--muted); }
.figures dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.row { display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 1rem; }
.list > li + li { border-top: 1px solid var(--line); }
.grow { flex: 1; min-width: 0; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; }
.title { font-weight: 600; color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
a.title:hover { text-decoration: underline; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.note { padding: 0.5rem 1rem; font-size: 0.9rem; background: var(--ok-bg); }
.note.error { background: transparent; }
.day { margin-top: 1.25rem; }
.plain { padding-left: 1.2rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.empty { color: var(--muted); padding: 1rem 0; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0.75rem; }
.error { color: var(--negative); }

.chip { font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; margin-left: 0.35rem; background: var(--line); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--positive); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

/* Forms */
.form { display: flex; flex-direction: column; }
label { font-size: 0.9rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }

input, select {
    font: inherit;
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--fg);
}

select.filter { margin-bottom: 0.5rem; }

button, .button {
    font: inherit;
    font-weight: 600;
    display: inline-block;
    text-align: center;
    text-decoration: none;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--fg);
    cursor: pointer;
}

button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); margin-top: 0.5rem; }
button.small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
button.danger { color: var(--negative); border-color: var(--negative); }
button.link { border: 0; background: none; color: var(--accent); padding: 0.5rem 0; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Blazor's own UI (from the template) */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    color: #1d2420;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Something went wrong on this page."; }

.loading-progress { position: absolute; display: block; width: 6rem; height: 6rem; inset: 20vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: var(--line); stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 2.5rem) 0 auto 0; color: var(--muted); }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

@media (prefers-reduced-motion: reduce) {
    .loading-progress circle:last-child { transition: none; }
}
