@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
    --bg:            #0e0e10;
    --bg-2:          #141416;
    --surface:       #1a1a1f;
    --surface-2:     #222228;
    --surface-3:     #2a2a32;
    --border:        #2e2e36;
    --border-2:      #3a3a44;
    --text:          #f0f0f2;
    --text-2:        #9494a0;
    --text-3:        #56565e;
    --primary:       #4f8ef7;
    --primary-hover: #3b7ef6;
    --primary-dim:   rgba(79,142,247,.12);
    --success:       #34c76a;
    --success-dim:   rgba(52,199,106,.1);
    --danger:        #f74f4f;
    --danger-dim:    rgba(247,79,79,.1);
    --radius:        6px;
    --radius-sm:     4px;
    --shadow:        0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
    --shadow-sm:     0 1px 2px rgba(0,0,0,.3);
    --font:          'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Base ───────────────────────────────────────────────────── */
html { font-size: 14px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth layout ────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg);
}

.auth-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 380px;
    padding: 2rem;
}

.auth-logo {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 7px;
}

.auth-logo-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
}

.auth-box h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.auth-sub {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 1.5rem;
}

/* ── Form elements ──────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

input::placeholder { color: var(--text-3); }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2356565e' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    padding-right: 28px;
    cursor: pointer;
}

select option {
    background: var(--surface-2);
    color: var(--text);
}

textarea { height: auto; padding: 8px 10px; resize: vertical; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    text-decoration: none;
    color: #fff;
}

.btn-ghost-danger {
    background: none;
    color: var(--text-2);
    border: 1px solid var(--border);
    padding: 0 10px;
    height: 28px;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s, border-color .15s;
}

.btn-ghost-danger:hover {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: var(--danger);
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.alert-error {
    background: var(--danger-dim);
    border: 1px solid rgba(247,79,79,.25);
    color: var(--danger);
}

.alert-success {
    background: var(--success-dim);
    border: 1px solid rgba(52,199,106,.25);
    color: var(--success);
}

/* ── Auth footer ────────────────────────────────────────────── */
.auth-footer {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-2);
    text-align: center;
}

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-brand {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
}

.topbar-brand-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.topbar-spacer { flex: 1; }

.topbar-user {
    font-size: 12px;
    color: var(--text-2);
}

.topbar-logout {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    font-family: var(--font);
    transition: background .15s, color .15s, border-color .15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.topbar-logout:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-2);
    text-decoration: none;
}

/* ── Page shell ─────────────────────────────────────────────── */
.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-header { margin-bottom: 1.5rem; }

.page-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.page-sub {
    font-size: 13px;
    color: var(--text-2);
    margin-top: 2px;
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-card.is-primary {
    border-color: rgba(79,142,247,.35);
    background: var(--primary-dim);
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1;
}

.stat-card.is-primary .stat-value { color: var(--primary); }
.stat-value.is-income  { color: var(--success); }
.stat-value.is-expense { color: var(--danger); }

/* ── Content grid ───────────────────────────────────────────── */
.content-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}

/* ── Panel ──────────────────────────────────────────────────── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.panel-head {
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.panel-meta {
    font-size: 12px;
    color: var(--text-3);
}

.panel-body { padding: 1.25rem; }

/* ── Form inside panel ──────────────────────────────────────── */
.tx-form .form-group { margin-bottom: .875rem; }
.tx-form .btn-primary { margin-top: .25rem; }

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

/* ── Chart ──────────────────────────────────────────────────── */
.chart-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1.25rem 1rem;
}

.chart-wrap {
    width: 180px;
    height: 180px;
    position: relative;
    flex-shrink: 0;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.25rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-2);
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-swatch.income  { background: var(--success); }
.legend-swatch.expense { background: var(--danger); }

.legend-pct {
    font-weight: 600;
    color: var(--text);
    margin-left: 2px;
}

/* ── Transaction list ───────────────────────────────────────── */
.tx-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

.tx-row:last-child { border-bottom: none; }
.tx-row:hover { background: var(--surface-2); }

.tx-badge {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.tx-badge.income  { background: var(--success-dim); color: var(--success); }
.tx-badge.expense { background: var(--danger-dim);  color: var(--danger); }

.tx-info { flex: 1; min-width: 0; }

.tx-desc {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-meta {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
}

.tx-amount {
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 90px;
    text-align: right;
}

.tx-amount.income  { color: var(--success); }
.tx-amount.expense { color: var(--danger); }

.tx-actions { flex-shrink: 0; }

.tx-empty {
    padding: 3rem 1.25rem;
    text-align: center;
    font-size: 13px;
    color: var(--text-3);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .stat-grid      { grid-template-columns: 1fr; gap: .75rem; }
    .content-grid   { grid-template-columns: 1fr; }
    .page           { padding: 1.25rem 1rem; }
    .topbar         { padding: 0 1rem; }
    .topbar-user    { display: none; }
}