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

:root {
    --bg: #06070a;
    --bg-elevated: #0d0f14;
    --bg-card: #111318;
    --bg-card-hover: #161920;
    --accent: #34d399;
    --accent-dim: #059669;
    --accent-glow: rgba(52, 211, 153, 0.08);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.1);
    --amber: #fbbf24;
    --blue: #60a5fa;
    --text-primary: #e8eaed;
    --text-secondary: #8b8f98;
    --text-muted: #5a5e68;
    --border: #1a1d25;
    --border-hover: #252830;
    --sidebar-w: 240px;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        linear-gradient(rgba(52, 211, 153, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(52, 211, 153, 0.015) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* ─── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 36px;
    padding: 0 4px;
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo span { color: var(--accent); }

.sidebar-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid rgba(52, 211, 153, 0.15);
    padding: 3px 10px;
    border-radius: 12px;
    animation: pulse-badge 3s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(52, 211, 153, 0.1);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.15s ease;
}

.back-link:hover { color: var(--text-secondary); }

/* ─── Main Content ─────────────────────────────────────────────────── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 32px 40px;
    position: relative;
    z-index: 1;
    max-width: 1400px;
}

.header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
}

.page-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.8px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* ─── KPI Cards ────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.2s ease;
}

.kpi-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.kpi-balance {
    border-color: rgba(52, 211, 153, 0.15);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(52, 211, 153, 0.03) 100%);
}

.kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.kpi-value {
    font-family: 'DM Mono', 'Space Grotesk', monospace;
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.kpi-positive { color: var(--accent); }
.kpi-negative { color: var(--red); }

.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* ─── Chart ────────────────────────────────────────────────────────── */
.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.chart-label {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 4px 10px;
    border-radius: 6px;
}

.chart-container {
    height: 280px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ─── Split Layout ─────────────────────────────────────────────────── */
.split-layout {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
}

/* ─── Transactions ─────────────────────────────────────────────────── */
.transactions-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-group {
    display: flex;
    gap: 4px;
}

.filter-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.filter-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-elevated);
}

.filter-btn.active {
    color: var(--accent);
    background: var(--accent-glow);
    border-color: rgba(52, 211, 153, 0.15);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 16px;
    transition: border-color 0.15s ease;
}

.search-bar:focus-within {
    border-color: rgba(52, 211, 153, 0.3);
}

.search-bar svg { color: var(--text-muted); flex-shrink: 0; }

.search-bar input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    width: 100%;
    outline: none;
}

.search-bar input::placeholder { color: var(--text-muted); }

.txn-list {
    display: flex;
    flex-direction: column;
    max-height: 480px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.txn-list::-webkit-scrollbar { width: 4px; }
.txn-list::-webkit-scrollbar-track { background: transparent; }
.txn-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.txn-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s ease;
}

.txn-item:last-child { border-bottom: none; }
.txn-item:hover { background: var(--bg-elevated); }

.txn-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.txn-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.txn-type-dot.revenue { background: var(--accent); }
.txn-type-dot.expense { background: var(--red); }
.txn-type-dot.transfer { background: var(--blue); }

.txn-info {
    min-width: 0;
}

.txn-desc {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.txn-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.txn-category {
    display: inline-block;
    font-size: 10px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.txn-right {
    text-align: right;
    flex-shrink: 0;
    margin-left: 12px;
}

.txn-amount {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
}

.txn-amount.positive { color: var(--accent); }
.txn-amount.negative { color: var(--red); }
.txn-amount.neutral { color: var(--blue); }

.txn-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.txn-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-top: 16px;
}

.page-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-info { font-size: 12px; color: var(--text-muted); }

/* ─── Digest ───────────────────────────────────────────────────────── */
.digest-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    align-self: start;
}

.digest-section .section-title { margin-bottom: 20px; }

.digest-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.digest-block {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.digest-block:last-child { border-bottom: none; padding-bottom: 0; }

.digest-block-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.digest-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.digest-metric-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.digest-metric-value {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
}

.anomaly-item {
    background: rgba(248, 113, 113, 0.05);
    border: 1px solid rgba(248, 113, 113, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.anomaly-item:last-child { margin-bottom: 0; }

.anomaly-desc {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.anomaly-detail {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.expense-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.expense-bar-label {
    font-size: 12px;
    color: var(--text-secondary);
    width: 120px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-bar-track {
    flex: 1;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.expense-bar-fill {
    height: 100%;
    background: var(--red);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.expense-bar-value {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    width: 70px;
    text-align: right;
    flex-shrink: 0;
}

.runway-highlight {
    background: var(--accent-glow);
    border: 1px solid rgba(52, 211, 153, 0.12);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.runway-days {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 40px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.runway-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.runway-burn {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

/* ─── Loading State ────────────────────────────────────────────────── */
.loading-state {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.no-data {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ─── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .split-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        width: 60px;
        padding: 16px 8px;
    }

    .sidebar-header { justify-content: center; }
    .sidebar-badge, .nav-item span, .back-link span { display: none; }

    .nav-item {
        justify-content: center;
        padding: 10px;
    }

    .main {
        margin-left: 60px;
        padding: 20px 16px;
    }

    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .kpi-value { font-size: 22px; }
    .page-title { font-size: 22px; }
}
