:root {
    --bg: #0f1115;
    --panel: #181b22;
    --panel-2: #1f2430;
    --text: #e7e9ee;
    --muted: #9aa3b2;
    --border: #2a3040;
    --accent: #4ade80;
    --accent-ink: #052e16;
    --warn: #fbbf24;
    --danger: #f87171;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
}

.wrap {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px;
    flex: 1;
}

.center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
}

.card + .card {
    margin-top: 18px;
}

h1 {
    font-size: 22px;
    margin: 0 0 4px;
}

h2 {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin: 0 0 14px;
}

.muted {
    color: var(--muted);
}

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type=email] {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-size: 15px;
}

button, .btn {
    display: inline-block;
    border: 0;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    font-family: inherit;
    padding: 12px 18px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    text-decoration: none;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.brand {
    font-weight: 700;
    letter-spacing: -.01em;
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    word-break: break-all;
    user-select: all;
}

.notice {
    background: rgba(74, 222, 128, .1);
    border: 1px solid rgba(74, 222, 128, .4);
    color: var(--accent);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.stat .k {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}

.stat .v {
    font-size: 22px;
    font-weight: 700;
    margin-top: 6px;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.month-nav-label {
    font-size: 14px;
    font-weight: 600;
    min-width: 92px;
    text-align: center;
    white-space: nowrap;
}

.month-nav-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    text-decoration: none;
    font-size: 16px;
    line-height: 1;
}

.month-nav-arrow:hover {
    border-color: var(--accent);
}

.month-nav-arrow.is-disabled {
    color: var(--border);
    cursor: default;
}

/* Category breakdown — progress-bar rows */
.cat-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cat-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 6px;
}

.cat-name {
    font-weight: 600;
}

.cat-amounts {
    font-size: 13px;
    white-space: nowrap;
}

.cat-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--panel-2);
    overflow: hidden;
}

.cat-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .3s ease;
}

.cat-bar-fill.is-ok { background: var(--accent); }
.cat-bar-fill.is-warn { background: var(--warn); }
.cat-bar-fill.is-over { background: var(--danger); }

.cat-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-top: 5px;
    font-size: 12px;
}

.cat-pct { font-weight: 600; }
.cat-pct.is-ok { color: var(--accent); }
.cat-pct.is-warn { color: var(--warn); }
.cat-pct.is-over { color: var(--danger); }

/* Transactions table */
.tx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.tx-table th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    padding: 6px 8px;
}

.tx-table td {
    padding: 8px;
    border-top: 1px solid var(--border);
}

.tx-table .ta-right { text-align: right; }
.tx-table .tx-date { color: var(--muted); white-space: nowrap; }
.tx-table .tx-amount { white-space: nowrap; }
.tx-table .tx-amount.is-credit { color: var(--accent); }

/* On phones, collapse each transaction row into a labelled card */
@media (max-width: 640px) {
    .card { padding: 20px; }
    .wrap { padding: 20px 14px; }

    .tx-table thead { display: none; }

    .tx-table,
    .tx-table tbody,
    .tx-table tr,
    .tx-table td {
        display: block;
        width: 100%;
    }

    .tx-table tr {
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--panel-2);
        padding: 4px 2px;
        margin-bottom: 10px;
    }

    .tx-table td {
        border: 0;
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 16px;
        padding: 6px 12px;
        text-align: right;
    }

    .tx-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 600;
        text-align: left;
    }
}
