:root {
      --bg-primary: #0f172a;
      --bg-card: #1e293b;
      --bg-card-hover: #334155;
      --bg-input: #0f172a;
      --text-main: #f8fafc;
      --text-muted: #94a3b8;
      --border-color: #334155;
      --accent-blue: #3b82f6;
      --accent-blue-hover: #2563eb;
      --accent-green: #10b981;
      --accent-purple: #8b5cf6;
    }

    [data-theme="light"] {
      --bg-primary: #f1f5f9;
      --bg-card: #ffffff;
      --bg-card-hover: #f8fafc;
      --bg-input: #f8fafc;
      --text-main: #0f172a;
      --text-muted: #64748b;
      --border-color: #e2e8f0;
      --accent-blue: #2563eb;
      --accent-blue-hover: #1d4ed8;
      --accent-green: #059669;
      --accent-purple: #7c3aed;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }

    body {
      background-color: var(--bg-primary);
      color: var(--text-main);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      font-size: 14px;
      line-height: 1.5;
    }

    /* HEADER */
    header {
      background-color: var(--bg-card);
      border-bottom: 1px solid var(--border-color);
      padding: 14px 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 100;
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .brand-icon {
      width: 40px;
      height: 40px;
      background: linear-gradient(135deg, #3b82f6, #8b5cf6);
      border-radius: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: white;
      font-weight: bold;
      font-size: 20px;
      box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    }

    .brand-text h1 {
      font-size: 17px;
      font-weight: 700;
      color: var(--text-main);
      letter-spacing: -0.3px;
    }

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

    .header-actions {
      display: flex;
      gap: 10px;
      align-items: center;
    }

    .btn {
      padding: 8px 16px;
      border-radius: 6px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      border: 1px solid transparent;
      transition: all 0.2s ease;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .btn-primary {
      background-color: var(--accent-blue);
      color: white;
    }
    .btn-primary:hover {
      background-color: var(--accent-blue-hover);
    }

    .btn-success {
      background-color: var(--accent-green);
      color: white;
    }
    .btn-success:hover {
      filter: brightness(0.9);
    }

    .btn-outline {
      background: transparent;
      border-color: var(--border-color);
      color: var(--text-main);
    }
    .btn-outline:hover {
      background: var(--bg-card-hover);
    }

    .btn-sm {
      padding: 4px 10px;
      font-size: 12px;
    }

    .badge-offline {
      background: rgba(16, 185, 129, 0.15);
      color: var(--accent-green);
      border: 1px solid rgba(16, 185, 129, 0.3);
      padding: 4px 10px;
      border-radius: 20px;
      font-size: 12px;
      font-weight: 600;
    }

    /* MAIN CONTAINER */
    .container {
      flex: 1;
      padding: 20px 24px;
      max-width: 1600px;
      margin: 0 auto;
      width: 100%;
    }

    /* DROPZONE UPLOAD AREA */
    .drop-zone {
      border: 2px dashed var(--border-color);
      border-radius: 16px;
      padding: 60px 40px;
      text-align: center;
      background-color: var(--bg-card);
      transition: all 0.2s ease;
      cursor: pointer;
      margin: 40px auto;
      max-width: 800px;
    }
    .drop-zone:hover, .drop-zone.dragover {
      border-color: var(--accent-blue);
      background-color: var(--bg-card-hover);
    }
    .drop-icon {
      font-size: 48px;
      margin-bottom: 16px;
      display: block;
    }
    .drop-title {
      font-size: 20px;
      font-weight: 700;
      margin-bottom: 8px;
    }
    .drop-desc {
      color: var(--text-muted);
      font-size: 13px;
      margin-bottom: 24px;
    }

    /* KPI METRICS GRID */
    .kpi-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
      gap: 16px;
      margin-bottom: 24px;
    }
    .kpi-card {
      background-color: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 12px;
      padding: 18px 20px;
      position: relative;
      overflow: hidden;
    }
    .kpi-title {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 6px;
    }
    .kpi-value {
      font-size: 22px;
      font-weight: 800;
      color: var(--text-main);
    }
    .kpi-sub {
      font-size: 12px;
      color: var(--accent-blue);
      margin-top: 4px;
    }

    /* NAVIGATION TABS */
    .tabs-nav {
      display: flex;
      gap: 12px;
      border-bottom: 1px solid var(--border-color);
      margin-bottom: 20px;
      overflow-x: auto;
    }
    .tab-btn {
      padding: 12px 20px;
      background: transparent;
      border: none;
      color: var(--text-muted);
      font-size: 14px;
      font-weight: 700;
      cursor: pointer;
      border-bottom: 3px solid transparent;
      transition: all 0.2s ease;
      white-space: nowrap;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .tab-btn:hover {
      color: var(--text-main);
    }
    .tab-btn.active {
      color: var(--accent-blue);
      border-bottom-color: var(--accent-blue);
    }

    .tab-panel {
      display: none;
    }
    .tab-panel.active {
      display: block;
    }

    /* TOOLBAR & CONTROLS */
    .toolbar-box {
      background-color: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 10px;
      padding: 14px 18px;
      margin-bottom: 20px;
      display: flex;
      gap: 16px;
      align-items: center;
      flex-wrap: wrap;
      justify-content: space-between;
    }
    .filter-group {
      display: flex;
      gap: 12px;
      align-items: center;
      flex-wrap: wrap;
    }
    .input-control {
      background-color: var(--bg-primary);
      border: 1px solid var(--border-color);
      color: var(--text-main);
      padding: 8px 12px;
      border-radius: 6px;
      font-size: 13px;
      outline: none;
      transition: border-color 0.2s;
    }
    .input-control:focus {
      border-color: var(--accent-blue);
    }

    /* TABLES */
    .table-container {
      background-color: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 10px;
      overflow: hidden;
      overflow-x: auto;
    }
    .data-table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
    }
    .data-table th {
      background-color: rgba(255, 255, 255, 0.03);
      color: var(--text-muted);
      font-weight: 600;
      font-size: 12px;
      text-transform: uppercase;
      padding: 12px 16px;
      border-bottom: 1px solid var(--border-color);
      white-space: nowrap;
    }
    .data-table td {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border-color);
      font-size: 13px;
    }
    .data-table tbody tr:hover {
      background-color: var(--bg-card-hover);
    }
    .font-mono {
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    }
    .text-right {
      text-align: right;
    }

    .acc-badge {
      display: inline-block;
      padding: 3px 8px;
      border-radius: 4px;
      font-size: 12px;
      font-weight: 700;
      font-family: ui-monospace, SFMono-Regular, monospace;
    }
    .acc-debit {
      background: rgba(59, 130, 246, 0.15);
      color: #60a5fa;
      border: 1px solid rgba(59, 130, 246, 0.3);
    }
    .acc-credit {
      background: rgba(139, 92, 246, 0.15);
      color: #c084fc;
      border: 1px solid rgba(139, 92, 246, 0.3);
    }

    .pct-bar-container {
      width: 100px;
      height: 8px;
      background: var(--bg-primary);
      border-radius: 4px;
      overflow: hidden;
      display: inline-block;
      vertical-align: middle;
      margin-right: 8px;
    }
    .pct-bar-fill {
      height: 100%;
      background: linear-gradient(90deg, #3b82f6, #8b5cf6);
      border-radius: 4px;
    }

    /* MODAL */
    .modal-backdrop {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0,0,0,0.7);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s;
    }
    .modal-backdrop.active {
      opacity: 1;
      pointer-events: auto;
    }
    .modal-box {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 12px;
      width: 90%;
      max-width: 800px;
      max-height: 85vh;
      display: flex;
      flex-direction: column;
      box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    }
    .modal-header {
      padding: 16px 20px;
      border-bottom: 1px solid var(--border-color);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .modal-body {
      padding: 20px;
      overflow-y: auto;
      flex: 1;
    }
    .modal-footer {
      padding: 16px 20px;
      border-top: 1px solid var(--border-color);
      display: flex;
      justify-content: flex-end;
      gap: 10px;
    }

    .mapping-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 14px;
    }
    .mapping-field label {
      display: block;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      margin-bottom: 6px;
    }
    .mapping-field select {
      width: 100%;
      padding: 8px 12px;
      background: var(--bg-primary);
      border: 1px solid var(--border-color);
      color: var(--text-main);
      border-radius: 6px;
    }

    .hidden { display: none !important; }

    /* ===== UI POLISH: chuyên nghiệp & dễ nhìn ===== */
    html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

    /* Custom scrollbar */
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
    ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; }

    /* Căn số thẳng hàng theo cột */
    .font-mono, .text-right, .kpi-value { font-variant-numeric: tabular-nums; }

    /* Bảng */
    .table-container { border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
    .data-table th {
      background-color: var(--bg-card);
      letter-spacing: 0.4px;
      border-bottom: 2px solid var(--border-color);
    }
    .data-table td { vertical-align: middle; }
    .data-table tbody tr:nth-child(even) { background-color: rgba(127,127,127,0.04); }
    .data-table tbody tr:hover { background-color: var(--bg-card-hover); }
    .data-table tbody tr:last-child td { border-bottom: none; }

    /* KPI cards */
    .kpi-card {
      border-radius: 14px;
      border-top: 3px solid transparent;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
      transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    .kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.09); }
    .kpi-card:nth-child(1) { border-top-color: var(--accent-blue); }
    .kpi-card:nth-child(2) { border-top-color: var(--accent-green); }
    .kpi-card:nth-child(3) { border-top-color: var(--accent-purple); }
    .kpi-card:nth-child(4) { border-top-color: #f59e0b; }
    .kpi-value { letter-spacing: -0.5px; }

    /* Nút */
    .btn { border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
    .btn:active { transform: translateY(1px); }
    .btn-primary { box-shadow: 0 2px 8px rgba(59,130,246,0.28); }
    .btn-success { box-shadow: 0 2px 8px rgba(16,185,129,0.22); }
    .btn:focus-visible, .input-control:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

    /* Input & select */
    .input-control { border-radius: 8px; padding: 9px 14px; }
    .input-control:focus { box-shadow: 0 0 0 3px rgba(59,130,246,0.14); }

    /* Tabs */
    .tab-btn { border-radius: 8px 8px 0 0; }
    .tab-btn.active { background: var(--bg-card); }

    /* Toolbar */
    .toolbar-box { border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

    /* Dropzone */
    .drop-zone { border-radius: 20px; }
    .drop-zone:hover, .drop-zone.dragover {
      border-color: var(--accent-blue);
      box-shadow: 0 10px 32px rgba(59,130,246,0.12);
    }

    /* Header */
    header { box-shadow: 0 1px 0 var(--border-color), 0 4px 18px rgba(0,0,0,0.07); }

    /* Modal */
    .modal-box { border-radius: 16px; }

    /* Badge */
    .acc-badge { border-radius: 6px; }
    .badge-offline { border-radius: 999px; }

    /* Cân đối chiều rộng cột */
    .table-fixed { table-layout: fixed; }
    .td-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Phân trang */
    .pagination-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 16px;
      border-top: 1px solid var(--border-color);
      color: var(--text-muted);
      font-size: 12px;
    }
    .pagination-btns {
      display: flex;
      gap: 8px;
    }
    .pagination-bar button:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }
