/* ═══════════════════════════════════════════════════════
   NN Gold Expense Tracker — Dark + Gold Theme
   Font: Prompt (Google Fonts)
   ═══════════════════════════════════════════════════════ */

:root {
    --bg: #0D0D0D;
    --bg-elevated: #1A1A1A;
    --bg-card: #1E1E1E;
    --bg-input: #252525;
    --gold: #D4AF37;
    --gold-light: #E5C158;
    --gold-dark: #C5A028;
    --text: #E8E8E8;
    --text-muted: #888;
    --text-dim: #555;
    --border: #333;
    --border-light: #2A2A2A;
    --income: #22C55E;
    --income-bg: rgba(34, 197, 94, 0.1);
    --expense: #EF4444;
    --expense-bg: rgba(239, 68, 68, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --nav-h: 56px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Prompt', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
svg { display: inline-block; vertical-align: middle; }

/* ─── Navbar ────────────────────────────────────────────── */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 1000;
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
    font-size: 17px;
    margin-right: auto;
}

.nav-logo {
    width: 26px; height: 26px;
    color: var(--gold);
}

.gold-text { color: var(--gold); }

.app-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text);
}
.nav-toggle svg { width: 24px; height: 24px; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(232,232,232,0.7);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-links a svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-links a:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.nav-links a.active { background: var(--gold); color: var(--bg); font-weight: 600; }

.nav-links a.nav-logout { color: var(--text-muted); margin-left: 8px; }
.nav-links a.nav-logout:hover { color: var(--expense); }

/* ─── Content ───────────────────────────────────────────── */
.content {
    padding: calc(var(--nav-h) + 16px) 16px 32px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ─── Flash Messages ────────────────────────────────────── */
.flash-msg {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--gold);
    color: var(--gold-light);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    text-align: center;
}

/* ─── Login ─────────────────────────────────────────────── */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - var(--nav-h) - 48px);
    padding-top: 0;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo {
    color: var(--gold);
    margin-bottom: 16px;
}
.login-logo svg { width: 56px; height: 56px; }

.login-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
}
.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-form {
    text-align: left;
}

.login-hint {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-dim);
}
.login-hint strong { color: var(--gold); }

/* ─── Forms ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.input-icon { width: 16px; height: 16px; }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--gold);
}

.form-group input::placeholder { color: var(--text-dim); }

.form-row {
    display: flex;
    gap: 12px;
}
.form-row .form-group { flex: 1; }

/* Date/time inputs dark theme */
.form-group input[type="date"],
.form-group input[type="time"] {
    color-scheme: dark;
}

/* ─── Type Toggle ───────────────────────────────────────── */
.type-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.type-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
    position: relative;
    background: var(--bg-input);
    color: var(--text-muted);
}

.type-option svg { width: 20px; height: 20px; }
.type-option input { position: absolute; opacity: 0; }

.type-option.type-expense.active {
    border-color: var(--expense);
    color: var(--expense);
    background: var(--expense-bg);
}
.type-option.type-income.active {
    border-color: var(--income);
    color: var(--income);
    background: var(--income-bg);
}

/* ─── File Upload ───────────────────────────────────────── */
.file-upload {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: var(--bg-input);
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s;
    position: relative;
}
.file-upload:hover { border-color: var(--gold); }
.file-upload svg { width: 22px; height: 22px; color: var(--gold); flex-shrink: 0; }
.file-label { font-size: 14px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-upload input { position: absolute; opacity: 0; width: 100%; height: 100%; left: 0; top: 0; cursor: pointer; }

.slip-preview {
    margin-top: 10px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-width: 200px;
}
.slip-preview img { width: 100%; height: auto; display: block; }

/* ─── Buttons ───────────────────────────────────────────── */
.btn-submit,
.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.2s;
    font-family: inherit;
}
.btn-submit:hover,
.btn-login:hover { opacity: 0.9; }

.btn-icon { width: 20px; height: 20px; }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}
.card-icon { width: 20px; height: 20px; color: var(--gold); }

/* ─── Page Header ───────────────────────────────────────── */
.page-header {
    margin-bottom: 16px;
}
.page-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 600;
}
.page-icon { width: 24px; height: 24px; color: var(--gold); }
.page-date {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ─── Transaction List (recorder) ───────────────────────── */
.txn-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.txn-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
}
.txn-item.income { border-left-color: var(--income); }
.txn-item.expense { border-left-color: var(--expense); }

.txn-icon-wrap {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.txn-item.income .txn-icon-wrap { background: var(--income-bg); color: var(--income); }
.txn-item.expense .txn-icon-wrap { background: var(--expense-bg); color: var(--expense); }
.txn-icon-wrap svg { width: 18px; height: 18px; }

.txn-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.txn-desc {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.txn-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.txn-amount {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}
.txn-amount.income { color: var(--income); }
.txn-amount.expense { color: var(--expense); }

/* ─── Empty State ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Summary Cards (owner) ─────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.summary-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.summary-icon svg { width: 22px; height: 22px; }
.income-card .summary-icon { background: var(--income-bg); color: var(--income); }
.expense-card .summary-icon { background: var(--expense-bg); color: var(--expense); }
.balance-card .summary-icon { background: rgba(212,175,55,0.15); color: var(--gold); }

.summary-info { display: flex; flex-direction: column; }
.summary-label { font-size: 12px; color: var(--text-muted); }
.summary-value { font-size: 18px; font-weight: 700; color: var(--text); }

/* ─── Chart ─────────────────────────────────────────────── */
.chart-container {
    overflow-x: auto;
    padding-bottom: 8px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    min-height: 180px;
    height: 200px;
    padding-top: 20px;
}

.bar-item {
    flex: 1;
    min-width: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.bar-wrap {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
}

.bar {
    width: 70%;
    max-width: 32px;
    min-height: 2px;
    background: linear-gradient(180deg, var(--expense), #b91c1c);
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: opacity 0.2s;
    cursor: default;
}
.bar:hover { opacity: 0.8; }

.bar-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--gold);
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid var(--border);
}
.bar:hover .bar-tooltip { opacity: 1; }

.bar-label {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* ─── Filters ───────────────────────────────────────────── */
.filter-card { padding: 14px; }

.filter-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
}
.filter-btn:hover { border-color: var(--gold); color: var(--text); }
.filter-btn.active {
    background: var(--gold);
    color: var(--bg);
    border-color: var(--gold);
    font-weight: 600;
}

.custom-date-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.custom-date-row .form-group { flex: 1; min-width: 120px; margin-bottom: 0; }
.custom-date-row .form-group label { font-size: 11px; }
.custom-date-row .form-group input { padding: 8px 10px; font-size: 14px; }
.apply-btn { padding: 9px 16px; margin-bottom: 0; height: fit-content; }

.filter-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding: 0 4px;
}
.filter-income { color: var(--income); font-weight: 600; }
.filter-expense { color: var(--expense); font-weight: 600; }

/* ─── Table ─────────────────────────────────────────────── */
.table-card { padding: 0; overflow: hidden; }

.table-scroll {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.txn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.txn-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.txn-table th {
    background: var(--bg-elevated);
    color: var(--gold);
    font-weight: 600;
    padding: 12px 14px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.txn-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

.txn-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.type-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.type-badge.income { background: var(--income-bg); color: var(--income); }
.type-badge.expense { background: var(--expense-bg); color: var(--expense); }

.amount-cell { font-weight: 700; }
.amount-cell.income { color: var(--income); }
.amount-cell.expense { color: var(--expense); }

.slip-indicator svg { width: 18px; height: 18px; color: var(--gold); }

.empty-row {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

/* ─── Lightbox ──────────────────────────────────────────── */
.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.lightbox.show { display: flex; }

.lightbox img {
    max-width: 95%;
    max-height: 90vh;
    border-radius: var(--radius);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px; right: 24px;
    color: var(--text);
    cursor: pointer;
    opacity: 0.7;
}
.lightbox-close svg { width: 32px; height: 32px; }
.lightbox-close:hover { opacity: 1; }

/* ─── Responsive ────────────────────────────────────────── */
@media (min-width: 768px) {
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .content {
        padding-top: calc(var(--nav-h) + 24px);
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (max-width: 767px) {
    .nav-toggle { display: block; }
    .nav-links {
        position: fixed;
        top: var(--nav-h);
        right: -100%;
        flex-direction: column;
        background: var(--bg-elevated);
        width: 200px;
        padding: 12px;
        gap: 4px;
        border-bottom-left-radius: var(--radius);
        box-shadow: var(--shadow-lg);
        border: 1px solid var(--border);
        transition: right 0.25s;
    }
    body.nav-open .nav-links { right: 0; }

    .app-subtitle { display: none; }
    .nav-brand { font-size: 15px; }

    .form-row { flex-direction: column; gap: 0; }
    .login-card { padding: 32px 20px; }
    .content { padding-left: 12px; padding-right: 12px; }

    .summary-value { font-size: 15px; }

    .custom-date-row { flex-direction: column; align-items: stretch; }
    .apply-btn { width: 100%; text-align: center; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }
