:root {
    --bg: #FFFDF5;
    --card: #FFFFFF;
    --yellow: #F6C445;
    --yellow-dark: #E5A900;
    --yellow-soft: #FFF4D0;
    --text: #1F2933;
    --muted: #6B7280;
    --border: #E5E7EB;
    --success: #3F9B6B;
    --danger: #D97757;
    --shadow: 0 2px 12px rgba(31, 41, 51, 0.06);
    --radius: 14px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}
body { min-height: 100vh; display: flex; flex-direction: column; }
body > .container, body > main { flex: 1 0 auto; }
body > .footer { flex-shrink: 0; margin-top: auto; }

a { color: var(--yellow-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 0 0 16px; font-weight: 600; }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.mt { margin-top: 16px; }
.inline { display: inline; }

/* Navbar */
.navbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 50;
}
.navbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    background: var(--yellow);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.nav-menu {
    display: flex;
    align-items: center;
    gap: 24px;
    flex: 1;
}
.nav-links {
    display: flex;
    gap: 6px;
    flex: 1;
}
.nav-links a {
    color: var(--muted);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.nav-links a:hover {
    background: var(--yellow-soft);
    color: var(--text);
    text-decoration: none;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Container */
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}
.container-narrow { max-width: 640px; }
@media (max-width: 900px) {
    .container-narrow { max-width: 100%; }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.actions { display: flex; gap: 8px; }

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.card-header h2 { margin: 0; }
.link { color: var(--yellow-dark); font-weight: 500; }

.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
}
.stat-label { color: var(--muted); font-size: 0.9rem; }
.stat-value { font-size: 1.6rem; font-weight: 600; }
.income { color: var(--success); }
.expense { color: var(--danger); }

.grid-2 {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
}
.grid-2 .card { margin-bottom: 0; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--yellow);
    color: var(--text);
}
.btn-primary:hover { background: var(--yellow-dark); color: #fff; }
.btn-ghost {
    border-color: var(--border);
    color: var(--text);
}
.btn-ghost:hover { background: var(--yellow-soft); }
.btn-danger {
    color: var(--danger);
    border-color: var(--border);
}
.btn-danger:hover { background: #FCEDE7; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--muted);
}
.form input,
.form select,
.form textarea {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.95rem;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--yellow);
    box-shadow: 0 0 0 3px rgba(246, 196, 69, 0.25);
}
.form textarea { resize: vertical; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.error { color: var(--danger); font-size: 0.85rem; }

/* Filters */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
}
.filters label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}
.filters input,
.filters select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 0.9rem;
    background: #fff;
    font-family: inherit;
}
.filter-actions { display: flex; gap: 8px; }
.filters .btn { padding: 8px 16px; font-size: 0.9rem; }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.data-table thead th {
    text-align: left;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--yellow-soft); }
.actions-cell { white-space: nowrap; display: flex; gap: 6px; justify-content: flex-end; }

/* Pills */
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border);
}
.pill-income { background: #EAF6F0; color: var(--success); border-color: #D4ECD9; }
.pill-expense { background: #FCEDE7; color: var(--danger); border-color: #F5D7CC; }

/* Quick actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.quick-action {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
}
.quick-action:hover {
    background: var(--yellow-soft);
    border-color: var(--yellow);
    text-decoration: none;
}
.qa-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--yellow);
    color: var(--text);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-danger { background: #FCEDE7; color: var(--danger); border-color: #F5D7CC; }
.alert-success { background: #EAF6F0; color: var(--success); border-color: #D4ECD9; }
.alert-info { background: var(--yellow-soft); color: var(--text); border-color: #F1E0A0; }

/* Auth */
.auth-bg {
    background: linear-gradient(160deg, var(--bg) 0%, var(--yellow-soft) 100%);
    min-height: 100vh;
}
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}
.auth-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 36px 32px;
    box-shadow: 0 8px 32px rgba(31, 41, 51, 0.08);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 8px;
}
.auth-brand h1 { margin: 0; font-size: 1.4rem; }

/* Empty */
.empty {
    padding: 32px;
    text-align: center;
    color: var(--muted);
}

/* Chart */
.chart-wrapper {
    position: relative;
    height: 320px;
}

/* Error */
.error-card { padding: 48px 24px; }
.error-code {
    font-size: 4rem;
    font-weight: 700;
    color: var(--yellow);
    margin-bottom: 8px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 10px 16px;
    color: var(--muted);
    font-size: 0.75rem;
    background: transparent;
    border: none;
}

/* Mobile menu toggle (hidden on desktop) */
.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 38px;
    cursor: pointer;
    padding: 0;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}
.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    position: relative;
}
.nav-toggle span::before,
.nav-toggle span::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: var(--text);
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }

/* Responsive */
@media (max-width: 768px) {
    .navbar { padding: 8px 0; }
    .navbar-inner { padding: 0 16px; gap: 12px; flex-wrap: nowrap; position: relative; }
    .brand { font-size: 1rem; gap: 8px; flex-shrink: 0; }
    .nav-toggle { display: inline-flex; }

    .nav-menu {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        right: 12px;
        left: auto;
        min-width: 220px;
        max-width: calc(100vw - 24px);
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: 0 12px 28px rgba(31, 41, 51, 0.12);
        padding: 8px;
        flex-direction: column;
        gap: 2px;
        z-index: 60;
    }
    .navbar.open .nav-menu { display: flex; }

    .nav-menu .nav-links {
        display: flex;
        flex-direction: column;
        gap: 2px;
        width: 100%;
        flex: none;
    }
    .nav-menu .nav-links a { padding: 10px 12px; border-radius: var(--radius-sm); }

    .nav-menu .nav-user {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding-top: 8px;
        margin-top: 6px;
        border-top: 1px solid var(--border);
    }
    .nav-menu .nav-user .muted {
        padding: 4px 12px 0;
        font-size: 0.8rem;
        word-break: break-all;
    }
    .nav-menu .nav-user form { display: block; padding: 0 4px 4px; }
    .nav-menu .nav-user button { width: 100%; }

    .container { padding: 20px 16px 40px; }
    .cards { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: stretch; }
    .actions-cell { flex-direction: column; }
    .data-table { font-size: 0.85rem; }
    h1 { font-size: 1.35rem; }
}
