:root {
    --bg: #0b0b0b;
    --surface: #141414;
    --surface-2: #1c1c1c;
    --fg: #fafafa;
    --muted: #a3a3a3;
    --border: #262626;
    --accent: #22c55e;
    --accent-fg: #06210f;
    --danger: #ef4444;
    --radius: 10px;
    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.boot-loading {
    display: grid;
    place-items: center;
    height: 100vh;
    color: var(--muted);
}

a {
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* ---------- Landing / Auth ---------- */

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 2rem 1rem;
}

@media (min-width: 900px) {
    .auth-shell {
        grid-template-columns: 1.1fr 0.9fr;
        gap: 3rem;
        max-width: 1100px;
        margin: 0 auto;
        place-items: center;
    }
}

.auth-pitch h1 {
    font-size: clamp(2rem, 4.5vw, 3rem);
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
}

.auth-pitch p {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 30rem;
    margin: 0 0 1.5rem;
}

.auth-pitch ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.6rem;
    color: var(--muted);
}

.auth-pitch li::before {
    content: "✓ ";
    color: var(--accent);
    font-weight: 700;
}

.auth-card {
    width: 100%;
    max-width: 24rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.auth-card h2 {
    margin: 0 0 1.25rem;
    font-size: 1.4rem;
}

.field {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.field label {
    font-size: 0.85rem;
    color: var(--muted);
}

.field input,
.field select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--fg);
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    font-family: inherit;
}

.field input:focus,
.field select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    border-radius: 8px;
    padding: 0.7rem 1.1rem;
    font-size: 0.98rem;
    font-weight: 600;
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    width: auto;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    font: inherit;
    text-decoration: underline;
}

.form-switch {
    text-align: center;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.error-msg {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.success-msg {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #86efac;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ---------- App shell ---------- */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand .dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

.nav-tabs {
    display: flex;
    gap: 0.25rem;
}

.nav-tabs button {
    background: none;
    border: none;
    color: var(--muted);
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    font-size: 0.95rem;
}

.nav-tabs button.active {
    background: var(--surface-2);
    color: var(--fg);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
}

.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.6rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 1.5rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.stat-card .value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.dashboard-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1.1fr 0.9fr;
    }
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 1.05rem;
}

.category-row {
    display: grid;
    grid-template-columns: 7rem 1fr 4rem;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
    font-size: 0.9rem;
}

.category-row .bar-track {
    background: var(--surface-2);
    border-radius: 999px;
    height: 0.55rem;
    overflow: hidden;
}

.category-row .bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

.category-row .amount {
    text-align: right;
    color: var(--muted);
}

.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    height: 160px;
    padding-top: 0.5rem;
}

.trend-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    gap: 0.35rem;
}

.trend-bar {
    width: 100%;
    max-width: 28px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
}

.trend-label {
    font-size: 0.65rem;
    color: var(--muted);
    white-space: nowrap;
}

.empty-state {
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1.5rem 0;
}

.tx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.tx-table th {
    text-align: left;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.tx-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.tx-table tr:last-child td {
    border-bottom: none;
}

.category-pill {
    display: inline-block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
    font-size: 0.78rem;
    color: var(--fg);
}

.tx-delete {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
}

.tx-delete:hover {
    color: var(--danger);
}

.add-expense-form {
    max-width: 32rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

.profile-card {
    max-width: 28rem;
    display: grid;
    gap: 1rem;
}

.profile-row {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.profile-row .label {
    color: var(--muted);
}

.banner {
    background: rgba(239, 68, 68, 0.12);
    border-bottom: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 0.7rem 1.5rem;
    font-size: 0.9rem;
    text-align: center;
}
