/* ========================================
   EVE Online ISK Audit — Professional CSS
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- CSS Variables --- */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Dark theme (default — EVE vibes) */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-card-hover: #1e2538;
    --bg-elevated: #242b3d;
    --bg-input: #151b2b;

    --text-primary: #e8ecf4;
    --text-secondary: #8892a8;
    --text-muted: #5a6478;

    --border-color: #2a3146;
    --border-light: #1e2538;

    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-hover: #2563eb;

    --income: #10b981;
    --income-bg: rgba(16, 185, 129, 0.1);
    --income-glow: rgba(16, 185, 129, 0.2);

    --expense: #ef4444;
    --expense-bg: rgba(239, 68, 68, 0.1);
    --expense-glow: rgba(239, 68, 68, 0.2);

    --warning: #f59e0b;
    --info: #06b6d4;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme */
body.light {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fa;
    --bg-elevated: #f0f2f5;
    --bg-input: #f0f2f5;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border-color: #e5e7eb;
    --border-light: #f0f2f5;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.05);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

/* Ambient background effect */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(59, 130, 246, 0.06), transparent),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(16, 185, 129, 0.04), transparent);
    pointer-events: none;
}

body.light .ambient-bg {
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(59, 130, 246, 0.04), transparent),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(16, 185, 129, 0.02), transparent);
}

/* --- Top Navigation --- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    gap: 1rem;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar-center { flex: 1; display: flex; justify-content: center; }

.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
}
.logo-title { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.logo-sub { display: block; font-size: 0.65rem; color: var(--text-muted); font-weight: 400; letter-spacing: 0.05em; text-transform: uppercase; }

.char-badge {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.35rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 100px;
}
.char-avatar {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    border-radius: 50%;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
}
.char-name { font-weight: 600; font-size: 0.85rem; }
.char-corp { display: block; font-size: 0.65rem; color: var(--text-muted); }

.period-selector { display: flex; gap: 2px; background: var(--bg-card); border-radius: var(--radius-sm); padding: 2px; }
.period-btn {
    padding: 0.35rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}
.period-btn:hover { color: var(--text-primary); }
.period-btn.active { background: var(--accent); color: white; }

.icon-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }

/* --- Main Content --- */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- KPI Cards --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.kpi-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.kpi-icon {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    flex-shrink: 0;
}
.kpi-balance .kpi-icon { background: var(--accent-glow); color: var(--accent); }
.kpi-income .kpi-icon { background: var(--income-bg); color: var(--income); }
.kpi-expense .kpi-icon { background: var(--expense-bg); color: var(--expense); }
.kpi-net .kpi-icon { background: rgba(6, 182, 212, 0.1); color: var(--info); }

.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.kpi-value { font-size: 1.5rem; font-weight: 800; font-family: var(--font-mono); letter-spacing: -0.02em; line-height: 1.2; }
.kpi-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

.kpi-balance .kpi-value { color: var(--accent); }
.kpi-income .kpi-value { color: var(--income); }
.kpi-expense .kpi-value { color: var(--expense); }
.kpi-net .kpi-value.positive { color: var(--income); }
.kpi-net .kpi-value.negative { color: var(--expense); }

/* --- Chart Cards --- */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}
.charts-row:nth-child(even) { grid-template-columns: 1fr 2fr; }

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all var(--transition);
}
.chart-card:hover { border-color: rgba(59, 130, 246, 0.3); }

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}
.chart-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.chart-header h3 i { color: var(--accent); font-size: 0.85rem; }
.chart-hint { font-size: 0.75rem; color: var(--text-muted); }

.chart-body { position: relative; height: 280px; }
.chart-body canvas { width: 100% !important; height: 100% !important; }

/* --- Category Section --- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-header h2 i { color: var(--accent); }

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.cat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition);
    cursor: default;
}
.cat-card:hover { background: var(--bg-card-hover); transform: translateX(2px); }

.cat-left { display: flex; flex-direction: column; }
.cat-name { font-weight: 600; font-size: 0.9rem; }
.cat-count { font-size: 0.75rem; color: var(--text-muted); }
.cat-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
}
.cat-amount.income { color: var(--income); }
.cat-amount.expense { color: var(--expense); }

.cat-bar {
    height: 3px;
    border-radius: 2px;
    margin-top: 0.5rem;
    background: var(--border-light);
    overflow: hidden;
}
.cat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}
.cat-bar-fill.income { background: var(--income); }
.cat-bar-fill.expense { background: var(--expense); }

/* --- Transaction Table --- */
.table-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.table-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.search-box i {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.search-box input {
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    width: 220px;
    transition: all var(--transition);
}
.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.table-controls select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
}
.table-controls select:focus {
    outline: none;
    border-color: var(--accent);
}

.table-wrapper {
    overflow-x: auto;
    margin: 1rem -0.25rem 0;
}

#txTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
#txTable thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-card);
}
#txTable thead th.sortable { cursor: pointer; user-select: none; }
#txTable thead th.sortable:hover { color: var(--accent); }
#txTable thead th.num-col { text-align: right; }

#txTable tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
#txTable tbody tr:hover { background: var(--bg-card-hover); }

#txTable tbody td {
    padding: 0.65rem 1rem;
    vertical-align: middle;
}
#txTable tbody td.num-col {
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.85rem;
}

.tx-amount-positive { color: var(--income); }
.tx-amount-negative { color: var(--expense); }

.tx-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}
.tx-category-badge i { font-size: 0.7rem; }

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pagination { display: flex; gap: 4px; }
.page-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* --- Modal --- */

/* Import steps */
.import-steps {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.import-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.step-num {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.import-step kbd {
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}
.import-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 700px;
    box-shadow: var(--shadow-lg);
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-head h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.modal-head h3 i { color: var(--accent); }
.modal-close {
    width: 32px; height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--expense-bg); color: var(--expense); }

.modal-body { padding: 1.5rem; }
.modal-body p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 0.75rem; }
.modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    resize: vertical;
    transition: border var(--transition);
}
.modal-body textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text-primary); }

/* --- Footer --- */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    max-width: 1400px;
    margin: 0 auto;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Responsive: Tablet (≤1200px) --- */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-row, .charts-row:nth-child(even) { grid-template-columns: 1fr; }
}

/* --- Responsive: Mobile (≤768px) --- */
@media (max-width: 768px) {
    /* ── Topbar: 2-row layout on mobile ── */
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 0.5rem 0.75rem;
        gap: 0.4rem;
    }
    .topbar-left {
        order: 1;
        flex-shrink: 0;
    }
    .topbar-center {
        order: 3;
        flex: 1 1 100%;
        justify-content: flex-start;
        min-width: 0;
    }
    .topbar-right {
        order: 2;
        margin-left: auto;
        gap: 0.4rem;
        flex-shrink: 0;
    }

    .logo-title { font-size: 0.85rem; }
    .logo-sub { display: none; }
    .logo-icon { width: 28px; height: 28px; font-size: 0.8rem; border-radius: 8px; }

    /* Character badge — minimal */
    .char-badge {
        padding: 0.2rem 0.6rem;
        gap: 0.35rem;
        max-width: 100%;
    }
    .char-avatar { width: 20px; height: 20px; font-size: 0.6rem; }
    .char-name { font-size: 0.72rem; }
    .char-corp { display: none; }

    /* Period buttons — smaller */
    .period-selector { padding: 1px; }
    .period-btn { padding: 0.2rem 0.45rem; font-size: 0.68rem; }

    /* Icon buttons — compact */
    .icon-btn { width: 30px; height: 30px; font-size: 0.78rem; }

    /* ── Main content ── */
    .main-content { padding: 0.6rem; gap: 0.6rem; }

    /* KPI — 2 columns, compact */
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .kpi-card { padding: 0.7rem; gap: 0.5rem; }
    .kpi-icon { width: 30px; height: 30px; font-size: 0.8rem; border-radius: var(--radius-sm); }
    .kpi-value { font-size: 1rem; }
    .kpi-label { font-size: 0.6rem; }
    .kpi-sub { font-size: 0.65rem; }

    /* Charts — single column, shorter */
    .charts-row, .charts-row:nth-child(even) { grid-template-columns: 1fr; gap: 0.6rem; }
    .chart-card { padding: 0.85rem; }
    .chart-body { height: 180px; }
    .chart-header { margin-bottom: 0.6rem; padding-bottom: 0.5rem; }
    .chart-header h3 { font-size: 0.82rem; }
    .chart-hint { font-size: 0.68rem; }

    /* EVE overview — stack */
    .eve-overview-body { flex-direction: column; padding: 0.85rem; gap: 0.85rem; }
    .eve-donut-wrap { width: 160px; height: 160px; margin: 0 auto; }
    .eve-donut-amount { font-size: 1.2rem; }
    .eve-tabs { padding: 0 0.6rem; }
    .eve-tab { padding: 0.5rem 0.65rem; font-size: 0.72rem; gap: 0.3rem; }
    .eve-tab i { font-size: 0.7rem; }
    .eve-summary-panel { gap: 0; }
    .eve-summary-row { padding: 0.45rem 0; }
    .eve-summary-label { font-size: 0.8rem; }
    .eve-summary-value { font-size: 0.9rem; }
    .eve-panel-title { font-size: 0.72rem; margin-bottom: 0.6rem; }
    .eve-legend-item { font-size: 0.72rem; }
    .eve-legend-pct { font-size: 0.72rem; min-width: 36px; }
    .eve-legend-amount { font-size: 0.68rem; min-width: 60px; }

    /* Category grid — single column */
    .category-grid { grid-template-columns: 1fr; gap: 0.5rem; }
    .cat-card { padding: 0.65rem 0.85rem; }
    .cat-name { font-size: 0.82rem; }
    .cat-count { font-size: 0.68rem; }
    .cat-amount { font-size: 0.85rem; }

    /* Table section */
    .table-section { padding: 0.85rem; }
    .tab-table-wrap { padding: 0.85rem; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.6rem; }
    .section-header h2 { font-size: 0.95rem; }
    .table-controls { flex-wrap: wrap; gap: 0.4rem; width: 100%; }
    .search-box { flex: 1; min-width: 0; }
    .search-box input { width: 100%; font-size: 0.78rem; padding: 0.4rem 0.6rem 0.4rem 2rem; }
    .search-box i { left: 0.6rem; font-size: 0.78rem; }
    .table-controls select { font-size: 0.78rem; padding: 0.4rem 0.5rem; flex: 1; }

    #txTable { font-size: 0.78rem; }
    #txTable thead th { padding: 0.5rem 0.6rem; font-size: 0.68rem; }
    #txTable tbody td { padding: 0.5rem 0.6rem; }
    #txTable tbody td.num-col { font-size: 0.78rem; }
    .tx-category-badge { font-size: 0.65rem; padding: 0.15rem 0.45rem; gap: 0.25rem; }
    .tx-category-badge i { font-size: 0.62rem; }

    .table-footer { flex-direction: column; gap: 0.5rem; font-size: 0.72rem; }
    .page-btn { width: 28px; height: 28px; font-size: 0.72rem; }

    /* ── Import Modal — mobile optimized ── */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal-box {
        max-width: 100%;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
    }
    .modal-head { padding: 1rem 1.25rem; }
    .modal-head h3 { font-size: 0.9rem; }
    .modal-body {
        padding: 1rem 1.25rem;
        overflow-y: auto;
        flex: 1;
    }
    .modal-body textarea {
        font-size: 0.72rem;
        min-height: 120px;
    }
    .import-steps { gap: 0.4rem; margin-bottom: 0.75rem; }
    .import-step { font-size: 0.78rem; gap: 0.5rem; }
    .step-num { width: 20px; height: 20px; font-size: 0.68rem; }
    .import-step kbd { font-size: 0.7rem; padding: 0.1rem 0.3rem; }
    .import-note { font-size: 0.7rem; }
    .modal-foot { padding: 0.75rem 1.25rem; }
    .btn { padding: 0.45rem 1rem; font-size: 0.8rem; }

    /* Footer */
    .footer { padding: 1.25rem 0.6rem 1rem; }
    .footer-inner { padding: 0.4rem 0.85rem; gap: 0.5rem; }
    .footer-crown { font-size: 1rem; }
    .footer-text { font-size: 0.75rem; }
    .footer-sub { font-size: 0.62rem; gap: 0.35rem; }
}

/* --- Responsive: Small phones (≤480px) --- */
@media (max-width: 480px) {
    .topbar { padding: 0.4rem 0.5rem; gap: 0.3rem; }
    .logo-title { font-size: 0.78rem; }
    .logo-icon { width: 24px; height: 24px; font-size: 0.7rem; border-radius: 6px; }

    .char-name { font-size: 0.65rem; }
    .char-avatar { width: 18px; height: 18px; font-size: 0.55rem; }

    .period-btn { padding: 0.18rem 0.35rem; font-size: 0.62rem; }
    .icon-btn { width: 26px; height: 26px; font-size: 0.7rem; }

    .main-content { padding: 0.4rem; gap: 0.5rem; }

    .kpi-grid { gap: 0.4rem; }
    .kpi-card { padding: 0.55rem; gap: 0.4rem; }
    .kpi-icon { width: 26px; height: 26px; font-size: 0.7rem; }
    .kpi-value { font-size: 0.88rem; }
    .kpi-label { font-size: 0.55rem; }

    .chart-body { height: 160px; }
    .chart-card { padding: 0.7rem; }

    .eve-donut-wrap { width: 130px; height: 130px; }
    .eve-donut-amount { font-size: 1rem; }

    .cat-card { padding: 0.55rem 0.7rem; }
    .cat-name { font-size: 0.75rem; }
    .cat-amount { font-size: 0.78rem; }

    .table-section { padding: 0.65rem; }
    #txTable { font-size: 0.72rem; }
    #txTable thead th { padding: 0.4rem 0.5rem; font-size: 0.62rem; }
    #txTable tbody td { padding: 0.4rem 0.5rem; }
}

/* --- EVE-style Overview Section --- */
.eve-overview {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* --- Tab Panels --- */
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
}
.tab-table-wrap {
    padding: 1.25rem;
}
.tab-table-wrap .section-header {
    margin-bottom: 0.75rem;
}

.eve-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    padding: 0 1.25rem;
    gap: 0;
}
.eve-tab {
    padding: 0.85rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
}
.eve-tab:hover { color: var(--text-primary); }
.eve-tab.active {
    color: var(--accent);
}
.eve-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
}
.eve-tab i { font-size: 0.78rem; }

.eve-overview-body {
    display: flex;
    align-items: stretch;
    padding: 1.5rem;
    gap: 2.5rem;
}

.eve-donut-wrap {
    position: relative;
    width: 280px;
    height: 280px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.eve-donut-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}
.eve-donut-center {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.eve-donut-amount {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.eve-donut-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

.eve-summary-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.eve-panel-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 1rem;
}

.eve-summary-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0;
}
.eve-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.eve-dot.green { background: var(--income); box-shadow: 0 0 6px var(--income-glow); }
.eve-dot.red { background: var(--expense); box-shadow: 0 0 6px var(--expense-glow); }
.eve-summary-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
}
.eve-summary-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.05rem;
}
.income-row .eve-summary-value { color: var(--income); }
.expense-row .eve-summary-value { color: var(--expense); }

.eve-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.5rem 0;
}

.eve-legend {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.eve-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}
.eve-legend-color {
    width: 10px; height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.eve-legend-name {
    flex: 1;
    color: var(--text-secondary);
}
.eve-legend-pct {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 42px;
    text-align: right;
}
.eve-legend-amount {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 80px;
    text-align: right;
}

/* ── FLOATING KOPI BUTTON — Radar Style ── */
.kopi-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: #be1e2d;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(190, 30, 45, 0.3);
}
.kopi-float:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(190, 30, 45, 0.5);
}
.kopi-float:hover .kopi-ring {
    animation: none;
    opacity: 0;
}
.kopi-float img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
    pointer-events: none;
    position: relative;
    z-index: 1;
}

/* Radar rings */
.kopi-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1.5px solid rgba(190, 30, 45, 0.6);
    animation: radar-ping 2.5s ease-out infinite;
    pointer-events: none;
}
.kopi-r2 { animation-delay: 0.8s; }
.kopi-r3 { animation-delay: 1.6s; }

@keyframes radar-ping {
    0%   { transform: scale(1); opacity: 0.8; border-width: 2px; }
    50%  { opacity: 0.3; }
    100% { transform: scale(2.2); opacity: 0; border-width: 0.5px; }
}

@media (max-width: 720px) {
    .kopi-float {
        bottom: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
    }
    .kopi-float img { width: 20px; height: 20px; }
}
.footer {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
    margin-top: 1rem;
}
.footer-inner {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    border-radius: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    position: relative;
}
.footer-inner::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 100px;
    background: linear-gradient(135deg, var(--accent), var(--income), var(--accent));
    z-index: -1;
    opacity: 0.3;
}
.footer-crown {
    font-size: 1.2rem;
    animation: crownBob 2s ease-in-out infinite;
    display: inline-block;
}
.footer-crown:nth-child(3) { animation-delay: 0.3s; }
.footer-text {
    font-weight: 700;
    font-size: 0.9rem;
    background: linear-gradient(90deg, var(--accent), var(--income), var(--warning), var(--accent));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}
.footer-sub {
    margin-top: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.footer-sep { opacity: 0.4; }

@keyframes crownBob {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-3px) rotate(5deg); }
}
@keyframes shimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

/* --- Responsive for EVE Overview --- */
@media (max-width: 900px) {
    .eve-overview-body {
        flex-direction: column;
        align-items: center;
    }
    .eve-donut-wrap { width: 220px; height: 220px; }
    .eve-donut-amount { font-size: 1.4rem; }
    .eve-summary-panel { width: 100%; }
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.kpi-card, .chart-card, .cat-card, .table-section {
    animation: fadeIn 0.4s ease both;
}
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }

/* --- Category Detail Panel --- */
.cat-card.active {
    border-color: var(--accent) !important;
    background: var(--accent-glow) !important;
    box-shadow: var(--shadow-glow);
}

.cat-detail-wrap {
    margin-top: 0.75rem;
}

.cat-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
    box-shadow: var(--shadow-glow);
}

.cat-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-elevated);
}

.cat-detail-title {
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
}

.cat-detail-count {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.cat-detail-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1rem;
}
.cat-detail-close:hover {
    border-color: var(--expense);
    color: var(--expense);
    background: var(--expense-bg);
}

.cat-detail-summary {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.cat-detail-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.cat-detail-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.cat-detail-stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.cat-detail-stat-value.income { color: var(--income); }
.cat-detail-stat-value.expense { color: var(--expense); }

.cat-detail-table-wrap {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.cat-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.cat-detail-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}
.cat-detail-table thead th.num-col { text-align: right; }

.cat-detail-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
.cat-detail-table tbody tr:hover { background: var(--bg-card-hover); }

.cat-detail-table tbody td {
    padding: 0.6rem 1rem;
    vertical-align: middle;
}
.cat-detail-table tbody td.num-col {
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.85rem;
}

/* --- Responsive: mobile for category detail --- */
@media (max-width: 768px) {
    .cat-detail-summary {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0.75rem 0.85rem;
    }
    .cat-detail-stat { min-width: 80px; }
    .cat-detail-header { padding: 0.75rem 0.85rem; }
    .cat-detail-title { font-size: 0.9rem; }
    .cat-detail-table thead th { padding: 0.5rem 0.6rem; font-size: 0.68rem; }
    .cat-detail-table tbody td { padding: 0.5rem 0.6rem; font-size: 0.78rem; }
    .cat-detail-table-wrap { max-height: 300px; }
}
