/* Border-box everywhere. Without it, width:100% means 100% of the CONTENT box and any
   padding is added on top, so a full-width control overflows its container. Buttons default to
   border-box in browsers but anchors do not, which is why anchor-styled buttons broke while
   visually identical <button> elements did not. */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --bg: #0b1020;
    --bg-elevated: #141b2e;
    --bg-panel: #161e33;
    --border: #26304a;
    --text: #eef2fb;
    --text-muted: #93a0bd;
    --accent: #5b8cff;
    --accent-strong: #3f6fe6;
    --positive: #37d99a;
    --negative: #ff6b7d;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

html, body {
    background: radial-gradient(1200px 600px at 80% -10%, #1a2b45 0, transparent 60%), var(--bg);
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
}

h1:focus {
    outline: none;
}

.shell {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

    .brand em {
        color: var(--accent);
        font-style: normal;
    }

.actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.6rem 1.05rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}

    .btn:disabled {
        opacity: 0.55;
        cursor: default;
    }

    .btn:not(:disabled):active {
        transform: translateY(1px);
    }

.btn-primary {
    background: var(--accent);
    color: #0b1020;
}

    .btn-primary:not(:disabled):hover {
        background: var(--accent-strong);
        color: #fff;
    }

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

    .btn-ghost:not(:disabled):hover {
        color: var(--text);
        border-color: var(--accent);
    }

.alert {
    background: rgba(255, 107, 125, 0.12);
    border: 1px solid rgba(255, 107, 125, 0.4);
    color: #ffd7dc;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.empty-state {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2.5rem 2rem;
    text-align: center;
}

    .empty-state h1 {
        font-size: 1.7rem;
        margin: 0 0 0.75rem;
        letter-spacing: -0.02em;
    }

    .empty-state p {
        color: var(--text-muted);
        max-width: 42ch;
        margin: 0 auto;
        line-height: 1.6;
    }

.hero {
    background: linear-gradient(150deg, #1b2743 0, var(--bg-elevated) 55%);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2.25rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.hero-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.hero-amount {
    font-size: 3.4rem;
    font-weight: 750;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

    .hero-amount.positive {
        color: var(--positive);
    }

    .hero-amount.negative {
        color: var(--negative);
    }

    .hero-amount.muted {
        color: var(--text-muted);
    }

.tag {
    display: inline-block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--border);
    color: var(--text-muted);
    vertical-align: middle;
    margin-left: 0.5rem;
}

.tag-accent {
    background: rgba(91, 140, 255, 0.18);
    color: var(--accent);
}

.hero-sub {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem 1.5rem 0.75rem;
    margin-bottom: 1.5rem;
}

    .panel h2 {
        font-size: 1.05rem;
        margin: 0 0 1rem;
        color: var(--text);
    }

.series-list, .txn-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.series-item {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

    .series-item:last-child {
        border-bottom: none;
    }

    .series-item.highlight {
        border-left: 3px solid var(--accent);
        padding-left: 0.85rem;
        margin-left: -0.85rem;
    }

    .series-item.selectable {
        cursor: pointer;
        border-radius: 8px;
        transition: background 0.12s ease;
    }

        .series-item.selectable:hover {
            background: rgba(255, 255, 255, 0.03);
        }

.radio {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    margin-right: 0.55rem;
    vertical-align: -2px;
    position: relative;
}

    .radio.on {
        border-color: var(--accent);
    }

        .radio.on::after {
            content: "";
            position: absolute;
            inset: 2px;
            border-radius: 50%;
            background: var(--accent);
        }

.btn-small {
    margin: 0.75rem 0 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.82rem;
}

.series-main {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

.series-amount {
    color: var(--positive);
}

.series-detail {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.txn-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}

    .txn-item:last-child {
        border-bottom: none;
    }

.txn-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.txn-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.txn-category {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: capitalize;
}

.txn-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.txn-amount {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--negative);
}

    .txn-amount.pos {
        color: var(--positive);
    }

.pos {
    color: var(--positive);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor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kuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}
/* ---- Auth pages ---- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

    .auth-card .brand {
        display: block;
        margin-bottom: 1.5rem;
    }

    .auth-card h1 {
        font-size: 1.5rem;
        margin: 0 0 0.35rem;
    }

.auth-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 1.5rem;
}

.auth-alt {
    margin: 1.25rem 0 0;
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: center;
}

    .auth-alt a {
        color: var(--accent);
        text-decoration: none;
    }

        .auth-alt a:hover {
            text-decoration: underline;
        }

.field {
    display: block;
    margin-bottom: 1rem;
}

    .field > span {
        display: block;
        font-size: 0.82rem;
        color: var(--text-muted);
        margin-bottom: 0.35rem;
    }

.input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
}

    .input:focus {
        outline: none;
        border-color: var(--accent);
    }

.field-error {
    display: block;
    color: var(--negative);
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
    margin-top: 0.5rem;
}

.logout-form {
    display: inline;
}

/* ---- Billing / trial ---- */

.auth-card-wide {
    max-width: 560px;
}

.banner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 0.75rem;
    background: rgba(91, 140, 255, 0.12);
    border: 1px solid rgba(91, 140, 255, 0.4);
    color: #dbe6ff;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.banner-note {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.85rem;
}

.plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 0.5rem;
}

.plan {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.1rem 1.1rem;
}

.plan-featured {
    border-color: var(--accent);
}

.plan-badge {
    position: absolute;
    top: -0.6rem;
    right: 0.9rem;
    background: var(--accent);
    color: #0b1020;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.plan-name {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.plan-price {
    font-size: 2rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}

    .plan-price small {
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-muted);
    }

.plan-note {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 0.75rem;
    min-height: 2.2em;
}

.signout-row {
    text-align: center;
    margin-top: 0.5rem;
}

/* ---- Include-income toggle ---- */

.toggle {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin-top: 1rem;
    cursor: pointer;
    user-select: none;
    /* Comfortable target on a phone without stretching the whole hero. */
    min-height: 44px;
}

    .toggle input {
        /* Hidden visually but still focusable and reachable by a screen reader. */
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }

.toggle-track {
    position: relative;
    flex: 0 0 auto;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: var(--border);
    border: 1px solid var(--border);
    transition: background .15s ease, border-color .15s ease;
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform .15s ease, background .15s ease;
}

.toggle input:checked + .toggle-track {
    background: rgba(55, 217, 154, .25);
    border-color: var(--positive);
}

    .toggle input:checked + .toggle-track .toggle-thumb {
        transform: translateX(18px);
        background: var(--positive);
    }

.toggle input:focus-visible + .toggle-track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.toggle input:disabled + .toggle-track {
    opacity: .55;
}

.toggle-label {
    color: var(--text-muted);
    font-size: .88rem;
}

.panel-note {
    color: var(--text-muted);
    font-size: .84rem;
    margin: 0 0 .75rem;
    font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
    .toggle-track, .toggle-thumb {
        transition: none;
    }
}

.oauth-actions {
    margin-top: 1.25rem;
}

    .oauth-actions .btn {
        display: inline-block;
        text-decoration: none;
    }
