
    :root {
      --primary: #1a56db;
      --primary-dark: #1240a8;
      --primary-light: #ebf0ff;
      --success: #0d9488;
      --warning: #d97706;
      --danger: #dc2626;
      --surface: #ffffff;
      --bg: #f1f5f9;
      --text: #0f172a;
      --text-muted: #64748b;
      --border: #e2e8f0;
      --sidebar-w: 250px;
      --topbar-h: 60px;
      --radius: 12px;
      --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
      --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    }

    * { box-sizing: border-box; }

    body {
      background: var(--bg);
      font-family: 'Plus Jakarta Sans', sans-serif;
      color: var(--text);
      font-size: 14px;
      margin: 0;
      -webkit-font-smoothing: antialiased;
    }

    /* ===== LAYOUT ===== */
    .app-wrapper {
      display: flex;
      min-height: 100vh;
    }

    /* ===== SIDEBAR ===== */
    .sidebar {
      width: var(--sidebar-w);
      background: var(--text);
      color: #fff;
      display: flex;
      flex-direction: column;
      flex-shrink: 0;
      position: fixed;
      top: 0;
      left: 0;
      bottom: 0;
      z-index: 1040;
      transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
      overflow-y: auto;
      overflow-x: hidden;
    }

    .sidebar-brand {
      padding: 20px 18px 16px;
      border-bottom: 1px solid rgba(255,255,255,0.08);
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .sidebar-brand-icon {
      width: 36px;
      height: 36px;
      background: var(--primary);
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .sidebar-brand-text h1 {
      font-size: 13px;
      font-weight: 700;
      margin: 0;
      line-height: 1.3;
      letter-spacing: 0.3px;
    }

    .sidebar-brand-text p {
      font-size: 10px;
      margin: 0;
      color: rgba(255,255,255,0.45);
      font-weight: 400;
    }

    .sidebar-nav {
      padding: 12px 10px;
      flex: 1;
    }

    .nav-label {
      font-size: 9px;
      font-weight: 600;
      letter-spacing: 1.2px;
      text-transform: uppercase;
      color: rgba(255,255,255,0.35);
      padding: 10px 8px 6px;
      display: block;
    }

    .menu-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 10px;
      border-radius: 8px;
      color: rgba(255,255,255,0.65) !important;
      text-decoration: none !important;
      font-size: 13px;
      font-weight: 500;
      transition: all 0.18s;
      margin-bottom: 2px;
      cursor: pointer;
      border: none;
      background: none;
      width: 100%;
    }

    .menu-item i {
      width: 18px;
      text-align: center;
      font-size: 13px;
      flex-shrink: 0;
      opacity: 0.8;
    }

    .menu-item:hover {
      background: rgba(255,255,255,0.08);
      color: #fff !important;
    }

    .menu-item.active {
      background: var(--primary);
      color: #fff !important;
    }

    .menu-item.active i { opacity: 1; }

    .sidebar-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.45);
      z-index: 1039;
    }

    /* ===== TOPBAR (mobile) ===== */
    .topbar {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: var(--topbar-h);
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      align-items: center;
      padding: 0 16px;
      z-index: 1030;
      gap: 12px;
      box-shadow: var(--shadow);
    }

    .topbar-toggle {
      width: 36px;
      height: 36px;
      border: none;
      background: var(--bg);
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
    }

    .topbar-title {
      font-size: 14px;
      font-weight: 700;
      color: var(--text);
      flex: 1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* ===== MAIN ===== */
    .main-content {
      margin-left: var(--sidebar-w);
      flex: 1;
      min-width: 0;
      padding: 24px;
      display: flex;
      flex-direction: column;
    }

    .content-section { display: none; }
    .content-section.active { display: block; }

    /* ===== PAGE HEADER ===== */
    .page-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
      margin-bottom: 20px;
    }

    .page-title {
      font-size: 20px;
      font-weight: 700;
      margin: 0;
      color: var(--text);
    }

    .page-subtitle {
      font-size: 12px;
      color: var(--text-muted);
      margin: 2px 0 0;
    }

    /* ===== CARDS ===== */
    .card {
      background: var(--surface);
      border-radius: var(--radius);
      border: 1px solid var(--border);
      box-shadow: var(--shadow);
      padding: 20px;
      margin-bottom: 16px;
    }

    .card-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.4px;
      margin-bottom: 4px;
    }

    /* ===== STAT CARDS ===== */
    .stat-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
      margin-bottom: 16px;
    }

    .stat-card {
      background: var(--surface);
      border-radius: var(--radius);
      border: 1px solid var(--border);
      padding: 16px;
      box-shadow: var(--shadow);
    }

    .stat-card-label {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 8px;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .stat-card-label .dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    .dot-green { background: var(--success); }
    .dot-blue { background: var(--primary); }
    .dot-orange { background: var(--warning); }
    .dot-red { background: var(--danger); }

    .stat-card-value {
      font-size: 20px;
      font-weight: 700;
      color: var(--text);
      line-height: 1;
    }

    /* ===== QUICK ACTIONS ===== */
    .quick-actions {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
      margin-bottom: 16px;
    }

    .quick-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 14px 12px;
      cursor: pointer;
      text-align: left;
      transition: all 0.18s;
      display: flex;
      align-items: center;
      gap: 10px;
      text-decoration: none;
      box-shadow: var(--shadow);
    }

    .quick-btn:hover {
      box-shadow: var(--shadow-md);
      transform: translateY(-1px);
      border-color: var(--primary);
    }

    .quick-btn-icon {
      width: 34px;
      height: 34px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      font-size: 14px;
    }

    .qbi-blue { background: var(--primary-light); color: var(--primary); }
    .qbi-green { background: #d1faf4; color: var(--success); }
    .qbi-orange { background: #fef3c7; color: var(--warning); }
    .qbi-red { background: #fee2e2; color: var(--danger); }

    .quick-btn-text {
      font-size: 12px;
      font-weight: 600;
      color: var(--text);
      line-height: 1.3;
    }

    /* ===== TABLE ===== */
    .table-card {
      background: var(--surface);
      border-radius: var(--radius);
      border: 1px solid var(--border);
      box-shadow: var(--shadow);
      overflow: hidden;
    }

    .table-card-header {
      padding: 14px 16px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 8px;
    }

    .table-card-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--text);
      margin: 0;
    }

    .table-responsive {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }

    table.data-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
    }

    table.data-table thead th {
      background: #f8fafc;
      padding: 10px 12px;
      font-weight: 600;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.4px;
      color: var(--text-muted);
      border-bottom: 1px solid var(--border);
      white-space: nowrap;
    }

    table.data-table tbody td {
      padding: 11px 12px;
      border-bottom: 1px solid #f1f5f9;
      vertical-align: middle;
    }

    table.data-table tbody tr:last-child td {
      border-bottom: none;
    }

    table.data-table tbody tr:hover {
      background: #f8fafc;
    }

    /* ===== BUTTONS ===== */
    .btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 8px 14px;
      border-radius: 8px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      border: none;
      transition: all 0.18s;
      text-decoration: none;
      white-space: nowrap;
    }

    .btn-primary {
      background: var(--primary);
      color: #fff;
    }
    .btn-primary:hover { background: var(--primary-dark); color: #fff; }

    .btn-success {
      background: var(--success);
      color: #fff;
    }
    .btn-success:hover { background: #0b7a70; color: #fff; }

    .btn-warning {
      background: #fef3c7;
      color: #92400e;
      border: 1px solid #fde68a;
    }
    .btn-warning:hover { background: #fde68a; color: #78350f; }

    .btn-danger {
      background: #fee2e2;
      color: #991b1b;
      border: 1px solid #fecaca;
    }
    .btn-danger:hover { background: #fecaca; color: #7f1d1d; }

    .btn-outline {
      background: transparent;
      color: var(--text-muted);
      border: 1px solid var(--border);
    }
    .btn-outline:hover { background: var(--bg); color: var(--text); }

    .btn-sm {
      padding: 5px 10px;
      font-size: 12px;
      border-radius: 6px;
    }

    .btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    /* ===== FORMS ===== */
    .form-label {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      margin-bottom: 5px;
      display: block;
      text-transform: uppercase;
      letter-spacing: 0.3px;
    }

    .form-control, .form-select {
      width: 100%;
      padding: 9px 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: 13px;
      font-family: inherit;
      color: var(--text);
      background: var(--surface);
      transition: border-color 0.18s, box-shadow 0.18s;
      outline: none;
    }

    .form-control:focus, .form-select:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
    }

    .form-control[readonly] {
      background: #f8fafc;
      color: var(--text-muted);
    }

    .input-group {
      display: flex;
    }

    .input-group .form-control {
      border-radius: 8px 0 0 8px;
      flex: 1;
      min-width: 0;
    }

    .input-group .btn {
      border-radius: 0 8px 8px 0;
      flex-shrink: 0;
    }

    .form-row {
      display: grid;
      gap: 12px;
      margin-bottom: 12px;
    }

    .form-row-2 { grid-template-columns: 1fr 1fr; }
    .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

    /* ===== ALERTS ===== */
    .alert {
      padding: 10px 14px;
      border-radius: 8px;
      margin-bottom: 12px;
      display: flex;
      align-items: flex-start;
      gap: 8px;
      font-size: 13px;
    }

    .alert-success { background: #d1faf4; color: #065f46; border-left: 3px solid var(--success); }
    .alert-error { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--danger); }
    .alert-warning { background: #fef3c7; color: #92400e; border-left: 3px solid var(--warning); }
    .alert-info { background: var(--primary-light); color: #1e40af; border-left: 3px solid var(--primary); }

    /* ===== BADGE ===== */
    .badge {
      display: inline-flex;
      align-items: center;
      padding: 3px 8px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 600;
      white-space: nowrap;
    }

    .badge-green { background: #d1faf4; color: #065f46; }
    .badge-blue { background: var(--primary-light); color: #1e40af; }
    .badge-orange { background: #fef3c7; color: #92400e; }
    .badge-red { background: #fee2e2; color: #991b1b; }
    .badge-gray { background: #f1f5f9; color: var(--text-muted); }

    /* ===== MODALS ===== */
    .modal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 2000;
      background: rgba(15,23,42,0.5);
      overflow-y: auto;
      padding: 16px;
    }

    .modal-box {
      background: var(--surface);
      border-radius: var(--radius);
      width: 100%;
      max-width: 560px;
      margin: auto;
      box-shadow: 0 20px 60px rgba(0,0,0,0.2);
      display: flex;
      flex-direction: column;
    }

    .modal-box-lg { max-width: 800px; }
    .modal-box-xl { max-width: 1100px; }
    .modal-box-sm { max-width: 400px; }

    .modal-header {
      padding: 16px 18px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .modal-header-title {
      font-size: 15px;
      font-weight: 700;
      color: var(--text);
      margin: 0;
    }

    .modal-close {
      width: 28px;
      height: 28px;
      border: none;
      background: var(--bg);
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-muted);
      flex-shrink: 0;
      font-size: 16px;
      line-height: 1;
      transition: all 0.15s;
    }

    .modal-close:hover { background: #fee2e2; color: var(--danger); }

    .modal-body {
      padding: 18px;
      overflow-y: auto;
      flex: 1;
    }

    .modal-footer {
      padding: 14px 18px;
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
    }

    /* ===== SECTION DIVIDER ===== */
    .section-label {
      font-size: 11px;
      font-weight: 700;
      color: var(--primary);
      text-transform: uppercase;
      letter-spacing: 0.8px;
      margin: 20px 0 12px;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .section-label::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--primary-light);
    }

    /* ===== FILTER BOX ===== */
    .filter-box {
      background: #f8fafc;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 16px;
      margin-bottom: 16px;
    }

    /* ===== ACTIVITY LIST ===== */
    .activity-list { list-style: none; padding: 0; margin: 0; }

    .activity-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 10px 0;
      border-bottom: 1px solid #f1f5f9;
    }

    .activity-item:last-child { border-bottom: none; }

    .activity-icon {
      width: 32px;
      height: 32px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      font-size: 13px;
    }

    .ai-blue { background: var(--primary-light); color: var(--primary); }
    .ai-green { background: #d1faf4; color: var(--success); }
    .ai-orange { background: #fef3c7; color: var(--warning); }

    .activity-info h4 {
      font-size: 13px;
      font-weight: 600;
      margin: 0 0 2px;
      color: var(--text);
    }

    .activity-info p {
      font-size: 12px;
      margin: 0;
      color: var(--text-muted);
    }

    /* ===== CHART ===== */
    .chart-wrapper {
      background: var(--surface);
      border-radius: var(--radius);
      border: 1px solid var(--border);
      padding: 16px;
      margin-bottom: 16px;
      box-shadow: var(--shadow);
    }

    .chart-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 14px;
      flex-wrap: wrap;
      gap: 8px;
    }

    .chart-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--text);
      margin: 0;
    }

    /* ===== INVOICE SUMMARY ===== */
    .summary-box {
      background: var(--primary-light);
      border: 1px solid #bfdbfe;
      border-radius: var(--radius);
      padding: 14px 16px;
      margin-top: 12px;
    }

    .summary-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 4px 0;
      font-size: 13px;
    }

    .summary-row.total {
      border-top: 1px solid #bfdbfe;
      margin-top: 6px;
      padding-top: 10px;
      font-weight: 700;
      font-size: 15px;
      color: var(--primary);
    }

    /* ===== FOOTER ===== */
    .app-footer {
      margin-top: auto;
      padding-top: 24px;
      text-align: center;
      color: var(--text-muted);
      font-size: 11px;
    }

    /* ===== RESPONSIVE ===== */
    @media (max-width: 767px) {
      .sidebar {
        transform: translateX(-100%);
      }

      .sidebar.show {
        transform: translateX(0);
      }

      .sidebar-overlay.show {
        display: block;
      }

      .topbar {
        display: flex;
      }

      .main-content {
        margin-left: 0;
        padding: 76px 14px 20px;
      }

      .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
      }

      .stat-card-value {
        font-size: 16px;
      }

      .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
      }

      .form-row-2 { grid-template-columns: 1fr; }
      .form-row-3 { grid-template-columns: 1fr; }

      .modal {
        padding: 10px;
        align-items: flex-end;
      }

      .modal-box {
        border-radius: 16px 16px 12px 12px;
        max-width: 100%;
        max-height: 90vh;
      }

      .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
      }

      table.data-table { font-size: 12px; }
      table.data-table thead th { padding: 8px 10px; font-size: 10px; }
      table.data-table tbody td { padding: 9px 10px; }

      .page-title { font-size: 17px; }

      .btn { font-size: 13px; }

      .btn-sm { padding: 5px 8px; font-size: 11px; }
    }

    @media (min-width: 1200px) {
      .stat-grid { grid-template-columns: repeat(4, 1fr); }
      .quick-actions { grid-template-columns: repeat(4, 1fr); }
    }

    @media (min-width: 768px) and (max-width: 1199px) {
      .stat-grid { grid-template-columns: repeat(2, 1fr); }
      .quick-actions { grid-template-columns: repeat(4, 1fr); }
    }

    /* Loading state */
    .loading-row td { text-align: center; padding: 40px; color: var(--text-muted); }

    .spinner {
      display: inline-block;
      width: 16px;
      height: 16px;
      border: 2px solid rgba(26,86,219,0.2);
      border-top-color: var(--primary);
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
    }

    @keyframes spin { to { transform: rotate(360deg); } }
