        /* ============================================
           Design System — CSS Variables
           ============================================ */
        :root {
            --primary: #1e293b;
            --primary-hover: #334155;
            --primary-light: #e2e8f0;
            --success: #059669;
            --success-light: #ecfdf5;
            --warning: #d97706;
            --warning-light: #fffbeb;
            --danger: #dc2626;
            --danger-light: #fef2f2;
            --info: #3b82f6;
            --info-light: #eff6ff;
            --accent-cyan: #06b6d4;

            --sidebar-bg: #0f172a;
            --sidebar-hover: #1e293b;
            --sidebar-active: #1e3a5f;
            --sidebar-text: #94a3b8;
            --sidebar-icon: #64748b;

            --bg: #f1f5f9;
            --card-bg: #ffffff;
            --border: #e2e8f0;
            --text: #0f172a;
            --text-secondary: #475569;
            --text-muted: #94a3b8;

            --radius-sm: 4px;
            --radius: 4px;
            --radius-lg: 6px;
            --shadow-sm: none;
            --shadow: none;
            --shadow-md: 0 2px 8px rgba(15,23,42,0.08);

            --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
            --font-mono: "SF Mono", "JetBrains Mono", "Consolas", monospace;

            --sidebar-width: 220px;
            --topbar-height: 48px;
        }

        /* ============================================
           Reset & Base
           ============================================ */
        * { margin: 0; padding: 0; box-sizing: border-box; }
        html { scroll-behavior: smooth; }
        body {
            display: flex;
            min-height: 100vh;
            background: var(--bg);
            font-family: var(--font);
            color: var(--text);
            line-height: 1.5;
            -webkit-font-smoothing: antialiased;
        }

        /* ============================================
           Layout: Sidebar + Main Area
           ============================================ */
        .sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.3);
            z-index: 99;
        }
        .sidebar-overlay.show { display: block; }

        .sidebar {
            width: var(--sidebar-width);
            background: var(--sidebar-bg);
            color: var(--sidebar-text);
            position: fixed;
            top: 0; left: 0; bottom: 0;
            overflow-y: auto;
            z-index: 50;
            transition: transform 0.25s ease;
            display: flex;
            flex-direction: column;
        }
        .sidebar::-webkit-scrollbar { width: 4px; }
        .sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

        .sidebar-logo {
            padding: 20px 20px 16px;
            border-bottom: 1px solid rgba(255,255,255,0.08);
        }
        .sidebar-logo h2 {
            font-size: 1.05em;
            font-weight: 700;
            color: #e2e8f0;
            letter-spacing: 0.5px;
        }
        .sidebar-logo .subtitle {
            font-size: 0.7em;
            color: var(--sidebar-icon);
            margin-top: 2px;
        }

        .sidebar-nav { flex: 1; padding: 8px 0; }
        .sidebar-group-title {
            padding: 16px 20px 6px;
            font-size: 0.7em;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: var(--sidebar-icon);
            opacity: 0.7;
        }
        .sidebar-nav a {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 20px;
            color: var(--sidebar-text);
            text-decoration: none;
            font-size: 0.82em;
            border-left: 3px solid transparent;
            transition: all 0.15s ease;
        }
        .sidebar-nav a:hover {
            background: var(--sidebar-hover);
            color: #e2e8f0;
        }
        .sidebar-nav a.active {
            background: #1e3a5f;
            border-left-color: #3b82f6;
            color: #fff;
            font-weight: 600;
        }
        .sidebar-nav a .nav-icon {
            width: 20px;
            text-align: center;
            font-size: 0.95em;
            flex-shrink: 0;
        }

        .sidebar-footer {
            border-top: 1px solid rgba(255,255,255,0.08);
            padding: 12px 20px;
            font-size: 0.75em;
            color: #475569;
            opacity: 0.6;
        }

        /* ============================================
           Main Area
           ============================================ */
        .main-area {
            margin-left: var(--sidebar-width);
            flex: 1;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
            min-width: 0;
        }
        .topbar {
            height: var(--topbar-height);
            background: #fff;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            padding: 0 16px;
            position: sticky;
            top: 0;
            z-index: 40;
            gap: 10px;
        }
        .topbar .hamburger {
            display: none;
            background: none;
            border: none;
            font-size: 1.3em;
            cursor: pointer;
            color: var(--text-secondary);
            padding: 4px 6px;
            border-radius: var(--radius-sm);
            line-height: 1;
        }
        .topbar .hamburger:hover { background: var(--bg); }
        .topbar .page-title {
            font-size: 0.95em;
            font-weight: 600;
            color: var(--text);
            flex: 1;
        }
        .topbar .topbar-right {
            font-size: 0.8em;
            color: var(--text-secondary);
            white-space: nowrap;
        }
        .main-content {
            flex: 1;
            padding: 20px;
            max-width: 1300px;
            margin: 0 auto;
            width: 100%;
        }

        /* ============================================
           Messages (Flash)
           ============================================ */
        .flash-msg {
            padding: 10px 16px;
            margin-bottom: 16px;
            border-radius: var(--radius-sm);
            font-size: 0.88em;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
        }
        .flash-msg.success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
        .flash-msg.error   { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
        .flash-msg .close-msg {
            background: none; border: none; cursor: pointer; font-size: 1.1em;
            color: inherit; opacity: 0.6; line-height: 1; padding: 0 2px;
        }
        .flash-msg .close-msg:hover { opacity: 1; }

        /* ============================================
           Cards
           ============================================ */
        .card {
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 16px;
            margin-bottom: 12px;
        }
        .card-bordered { border: 1px solid var(--border); }
        .card-flat { box-shadow: none; }
        .card-header {
            margin: -16px -16px 14px;
            padding: 12px 16px;
            border-bottom: 1px solid var(--border);
            font-size: 0.9em;
            font-weight: 700;
            color: var(--primary);
            border-radius: var(--radius) var(--radius) 0 0;
            background: var(--bg);
        }
        .card-body { padding: 0; }
        .card h3 {
            font-size: 0.95em;
            color: var(--primary);
            margin-bottom: 12px;
            padding-bottom: 8px;
            border-bottom: 1px solid var(--border);
            font-weight: 600;
        }

        /* ============================================
           Button System
           ============================================ */
        .btn {
            display: inline-block;
            padding: 7px 16px;
            border: 1px solid transparent;
            border-radius: var(--radius-sm);
            font-size: 0.84em;
            cursor: pointer;
            text-decoration: none;
            transition: background 0.12s ease;
            font-family: inherit;
            font-weight: 600;
            text-align: center;
            line-height: 1.4;
        }
        .btn:focus-visible {
            outline: 2px solid var(--info);
            outline-offset: 1px;
        }
        .btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }
        .btn-primary   { background: var(--primary); color: #f1f5f9; }
        .btn-primary:hover   { background: var(--primary-hover); }
        .btn-success   { background: var(--success); color: #fff; }
        .btn-success:hover   { background: #047857; }
        .btn-warning   { background: var(--warning); color: #fff; }
        .btn-warning:hover   { background: #b45309; }
        .btn-danger    { background: var(--danger); color: #fff; }
        .btn-danger:hover    { background: #b91c1c; }
        .btn-outline {
            background: transparent;
            color: var(--primary);
            border-color: var(--border);
        }
        .btn-outline:hover { background: var(--bg); border-color: var(--primary); }
        .btn-sm  { padding: 4px 10px; font-size: 0.78em; }
        .btn-xs  { padding: 3px 6px; font-size: 0.72em; }

        /* ============================================
           Table System
           ============================================ */
        .table-wrap {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
        table { width: 100%; border-collapse: collapse; font-size: 0.84em; }
        th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
        th {
            background: var(--bg);
            color: var(--text-secondary);
            font-weight: 700;
            font-size: 0.76em;
            text-transform: uppercase;
            letter-spacing: 0.4px;
            white-space: nowrap;
        }
        tr:hover td { background: #f8fafc; }
        .table-striped tbody tr:nth-child(even) td { background: #fafbfc; }
        .table-striped tbody tr:hover td { background: #f1f5f9; }

        /* ============================================
           Form System
           ============================================ */
        .form-group { margin-bottom: 14px; }
        .form-group label {
            display: block;
            margin-bottom: 6px;
            font-size: 0.84em;
            color: var(--text-secondary);
            font-weight: 600;
        }
        .form-group.required label::after {
            content: ' *';
            color: var(--danger);
        }
        input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
        select,
        textarea {
            width: 100%;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 7px 10px;
            font-size: 0.88em;
            font-family: inherit;
            background: #fff;
            transition: border-color 0.12s ease;
            color: var(--text);
        }
        input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
        select:focus,
        textarea:focus {
            outline: none;
            border-color: var(--info);
            box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
        }
        .form-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 12px;
        }

        /* ============================================
           Tag System
           ============================================ */
        .tag {
            display: inline-block;
            padding: 3px 10px;
            border-radius: 12px;
            font-size: 0.75em;
            font-weight: 600;
            line-height: 1.4;
            white-space: nowrap;
        }
        .tag-green  { background: var(--success-light); color: #065f46; }
        .tag-yellow { background: var(--warning-light); color: #92400e; }
        .tag-orange { background: #fff7ed; color: #9a3412; }
        .tag-red    { background: var(--danger-light); color: #991b1b; }
        .tag-gray   { background: #f1f5f9; color: #64748b; }
        .tag-blue   { background: var(--info-light); color: #1e40af; }
        .tag-purple { background: #f5f3ff; color: #5b21b6; }

        /* ============================================
           Stat Card System
           ============================================ */
        .stat-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 16px;
            margin-bottom: 20px;
        }
        .stat-card {
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-top: 3px solid var(--info);
            border-radius: var(--radius);
            padding: 12px 16px;
            transition: border-color 0.12s ease;
        }
        .stat-card:hover { border-color: var(--primary); }
        .stat-card .label {
            font-size: 0.72em;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.6px;
            margin-bottom: 2px;
        }
        .stat-card .value {
            font-size: 1.6em;
            font-weight: 700;
            color: var(--text);
            font-family: var(--font-mono);
        }
        .stat-card .value.danger  { color: var(--danger); }
        .stat-card .value.warning { color: var(--warning); }
        .stat-card .value.success { color: var(--success); }
        .stat-card .value.info    { color: var(--info); }
        .stat-card .trend {
            font-size: 0.72em;
            margin-top: 2px;
            font-weight: 600;
            color: var(--text-muted);
        }
        .stat-card .trend.up   { color: var(--success); }
        .stat-card .trend.down { color: var(--danger); }

        /* ============================================
           Quick Links
           ============================================ */
        .quick-links {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: 8px;
            margin-top: 12px;
        }
        .quick-link {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 14px;
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            text-decoration: none;
            color: var(--text);
            font-weight: 600;
            font-size: 0.84em;
            transition: border-color 0.12s ease, background 0.12s ease;
        }
        .quick-link:hover {
            background: var(--primary);
            color: #f1f5f9;
            border-color: var(--primary);
        }

        /* ============================================
           Bar Chart (legacy inline)
           ============================================ */
        .bar-chart { margin-top: 12px; }
        .bar-row {
            display: flex;
            align-items: center;
            margin-bottom: 6px;
            font-size: 0.84em;
        }
        .bar-label { width: 70px; text-align: right; padding-right: 10px; color: var(--text-secondary); flex-shrink: 0; }
        .bar-track {
            flex: 1;
            background: var(--bg);
            border-radius: 4px;
            height: 22px;
            position: relative;
            overflow: hidden;
        }
        .bar-fill {
            height: 100%;
            border-radius: 4px;
            display: flex;
            align-items: center;
            padding-left: 8px;
            color: #fff;
            font-size: 0.78em;
            font-weight: 600;
            min-width: 40px;
        }
        .bar-fill.income  { background: var(--success); }
        .bar-fill.expense { background: var(--danger); }
        .bar-fill.profit  { background: var(--info); }

        /* ============================================
           Utility Classes
           ============================================ */
        .flex-between {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 10px;
        }
        td.text-right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
        .text-center { text-align: center; }
        .empty {
            text-align: center;
            color: var(--text-muted);
            padding: 40px 20px;
            font-size: 0.9em;
        }
        .ar-row td:first-child { border-left: 4px solid transparent; }

        /* Chart containers */
        .chart-container {
            position: relative;
            width: 100%;
            max-height: 320px;
        }
        .chart-container canvas { width: 100% !important; }

        /* ============================================
           Modal
           ============================================ */
        .modal-bg {
            display: none;
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.5);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }
        .modal-bg.show { display: flex; }
        .modal {
            background: #fff;
            border-radius: var(--radius);
            padding: 24px;
            max-width: 500px;
            width: 90%;
            box-shadow: var(--shadow-md);
        }

        .mobile-tabbar { display: none; }

        /* ============================================
           Responsive — Mobile (≤768px)
           ============================================ */
        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
            }
            .sidebar.open {
                transform: translateX(0);
                box-shadow: 4px 0 16px rgba(0,0,0,0.25);
                z-index: 101;
            }
            .main-area {
                margin-left: 0 !important;
                padding-bottom: 60px;
            }
            .topbar .hamburger {
                display: inline-flex;
                align-items: center;
            }
            .topbar {
                height: 44px;
                padding: 0 12px;
            }
            .topbar .page-title { font-size: 0.88em; }
            .topbar .topbar-right {
                font-size: 0.72em;
                white-space: normal;
                text-align: right;
                line-height: 1.3;
                max-width: 45%;
            }
            .main-content {
                padding: 12px;
            }
            .stat-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 10px;
            }
            .stat-card { padding: 10px 12px; }
            .stat-card .value { font-size: 1.3em; }
            .card {
                padding: 12px;
                margin-bottom: 8px;
            }
            .table-wrap {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }
            table { min-width: 640px; }
            th {
                white-space: nowrap;
            }
            tbody { font-size: 0.78em; }
            th, td { padding: 6px 8px; font-size: 0.76em; }
            td.text-right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
            .btn {
                display: block;
                width: 100%;
            }
            .btn-inline {
                display: inline-block;
                width: auto;
            }
            input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
            select,
            textarea {
                font-size: 16px;
                min-height: 40px;
            }
            .form-row { grid-template-columns: 1fr; }
            .quick-links { grid-template-columns: repeat(2, 1fr); }
            .mobile-tabbar {
                position: fixed;
                left: 0;
                right: 0;
                bottom: 0;
                height: 60px;
                background: #fff;
                border-top: 1px solid var(--border);
                z-index: 100;
                display: flex;
                padding-bottom: env(safe-area-inset-bottom);
            }
            .mobile-tab {
                flex: 1;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                gap: 2px;
                color: var(--text-secondary);
                text-decoration: none;
                font-size: 10px;
                font-weight: 500;
                line-height: 1.15;
                transition: color 0.12s ease, transform 0.12s ease;
            }
            .mobile-tab-icon {
                font-size: 18px;
                line-height: 1;
            }
            .mobile-tab.active {
                color: var(--primary);
                font-weight: 700;
            }
            .mobile-tab:active {
                transform: scale(0.95);
            }
        }
