/* Rejo Finance Dashboard — Clean Light Theme */
:root {
    --bg: #f5f5f7;
    --bg-card: #ffffff;
    --bg-hover: #f0f0f5;
    --border: #e5e5ea;
    --text: #1d1d1f;
    --text-dim: #86868b;
    --accent: #6366f1;
    --accent-light: rgba(99,102,241,0.08);
    --green: #22c55e;
    --green-bg: rgba(34,197,94,0.08);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,0.08);
    --blue: #3b82f6;
    --orange: #f97316;
    --purple: #a855f7;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* Top Bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 100%;
}
.logo-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 17px; color: white;
    flex-shrink: 0;
}
.logo-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}
.nav-links a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 14px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.nav-links a:hover {
    color: var(--text);
    background: var(--bg-hover);
}
.nav-links a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar-date {
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
}
.btn-sync {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-sync:hover {
    background: var(--accent);
    color: white;
}
.btn-sync:disabled {
    opacity: 0.6;
    cursor: wait;
}
.sync-dropdown {
    position: relative;
}
.sync-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 180px;
    z-index: 200;
    padding: 4px;
}
.sync-dropdown.open .sync-menu { display: block; }
.sync-menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
}
.sync-menu button:hover { background: var(--bg-hover); }
.sync-menu button:disabled { opacity: 0.5; cursor: wait; }
.sync-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.sync-icon {
    font-size: 14px;
    display: inline-block;
}
.sync-icon.spinning {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Main */
main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px 28px 60px;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }

/* KPI Row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
}
.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.kpi-value {
    font-size: 22px;
    font-weight: 700;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.kpi-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Positive / Negative */
.positive { color: var(--green); }
.negative { color: var(--red); }

/* Charts Row */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 16px;
}
.chart-card canvas { max-height: 300px; }

/* Table Card */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.table-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}
.table-card .table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.table-card .table-header h3 { margin-bottom: 0; }
.table-scroll { overflow-x: auto; }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-dim);
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
th.right, td.right { text-align: right; }
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
tbody tr:hover { background: var(--bg-hover); }
.total-row td {
    background: var(--bg);
    border-top: 2px solid var(--border);
    font-weight: 600;
}
.section-row td {
    background: var(--accent-light);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--accent);
    padding: 8px 14px;
}
.sub-row td { padding-left: 28px; }

/* Wallet Cards */
.wallet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.wallet-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.wallet-card .wallet-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.wallet-card .wallet-balance {
    font-size: 20px;
    font-weight: 700;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.wallet-card .wallet-flows {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 12px;
}
.wallet-card .wallet-in { color: var(--green); }
.wallet-card .wallet-out { color: var(--red); }

/* Filters */
.filters {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filters select, .filters input {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}
.filters select:focus, .filters input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: #4f46e5; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* Metric Cards (analytics) */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
}
.metric-card .metric-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.metric-card .metric-value {
    font-size: 28px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.metric-card .metric-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Progress Bar */
.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}
.progress-bar .progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

/* Category bar (horizontal) */
.cat-bar {
    display: flex;
    gap: 2px;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}
.cat-bar .cat-segment { min-width: 2px; }
.cat-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 12px;
}
.cat-legend .cat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cat-legend .cat-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Transaction category tag */
.cat-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg);
    color: var(--text-dim);
}

/* Wiki page */
.wiki-page {
    max-width: 860px;
    margin: 0 auto;
}
.wiki-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 24px;
}
.wiki-header h1 {
    font-size: 24px;
    font-weight: 700;
}
.wiki-updated {
    font-size: 12px;
    color: var(--text-dim);
}
.wiki-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 36px;
    box-shadow: var(--shadow);
    line-height: 1.7;
}
.wiki-content h1 { display: none; }
.wiki-content h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 32px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.wiki-content h2:first-child { margin-top: 0; }
.wiki-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0 8px;
    color: var(--accent);
}
.wiki-content p { margin: 8px 0; }
.wiki-content ul, .wiki-content ol {
    margin: 8px 0;
    padding-left: 24px;
}
.wiki-content li { margin: 4px 0; }
.wiki-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}
.wiki-content th {
    background: var(--bg);
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border: 1px solid var(--border);
}
.wiki-content td {
    padding: 8px 14px;
    border: 1px solid var(--border);
}
.wiki-content code {
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
.wiki-content strong { color: var(--text); }
.wiki-content del { color: var(--text-dim); }
.wiki-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}
.wiki-content em { color: var(--text-dim); }

/* Responsive */
@media (max-width: 1024px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: 1fr; }
    main { padding: 16px; }
}
@media (max-width: 768px) {
    .nav-links a { padding: 0 10px; font-size: 13px; }
    .topbar { padding: 0 16px; }
    .logo-text { display: none; }
}
@media (max-width: 600px) {
    .kpi-row { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
    .kpi-value { font-size: 18px; }
    td, th { padding: 8px 10px; font-size: 12px; }
    .wallet-grid { grid-template-columns: 1fr; }
}
