@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================================
   CIPHER MATRIX — Light Theme Design System (Taste Edition)
   Professional financial UI. Clean, precise, premium.
   ============================================================ */

:root {
  /* ── Color palette (Light) ── */
  --clr-bg:          #f4f4f5; /* Zinc 100 */
  --clr-surface:     #ffffff;
  --clr-surface-2:   #fafafa; /* Zinc 50 */
  --clr-border:      #e4e4e7; /* Zinc 200 */
  --clr-border-soft: #f4f4f5;

  /* Premium Indigo Tone */
  --clr-primary:     #4f46e5;
  --clr-primary-dim: rgba(79, 70, 229, 0.08);
  --clr-primary-hover: #4338ca;
  --clr-accent:      #059669;
  --clr-accent-dim:  rgba(5, 150, 105, 0.08);
  --clr-warning:     #d97706;
  --clr-warning-dim: rgba(217, 119, 6, 0.1);
  --clr-danger:      #e11d48; /* Rose 600 */
  --clr-danger-dim:  rgba(225, 29, 72, 0.08);

  --clr-text:        #0f172a;
  --clr-text-2:      #475569;
  --clr-text-3:      #94a3b8;
  --clr-text-inv:    #ffffff;

  /* Positive/Negative for accounting */
  --clr-debit:       #e11d48;
  --clr-credit:      #059669;

  /* Typography */
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: var(--font-sans);

  /* Spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;

  /* Shadows - Premium Soft */
  --shadow-sm:    0 1px 2px rgba(9, 9, 11, 0.05);
  --shadow-card:  0 4px 12px rgba(9, 9, 11, 0.03), 0 2px 4px rgba(9, 9, 11, 0.02);
  --shadow-modal: 0 24px 48px -12px rgba(9, 9, 11, 0.15), 0 8px 24px -8px rgba(9, 9, 11, 0.1);

  /* Sidebar */
  --sidebar-w: 248px;
  --header-h:  56px;
}

.app-shell.sidebar-hidden {
  --sidebar-w: 64px;
}
.app-shell.sidebar-hidden .sidebar {
  overflow: visible !important;
}
.app-shell.sidebar-hidden .logo-text,
.app-shell.sidebar-hidden .logo-sub,
.app-shell.sidebar-hidden .sidebar-section-label-text,
.app-shell.sidebar-hidden .sidebar-footer-text,
.app-shell.sidebar-hidden .ws-name,
.app-shell.sidebar-hidden .ws-role,
.app-shell.sidebar-hidden .ws-group-link {
  display: none !important;
}
.app-shell.sidebar-hidden .sidebar-logo {
  justify-content: center;
  padding: var(--space-3) 0;
}
.app-shell.sidebar-hidden .sidebar-item {
  justify-content: center;
  padding: 12px 0;
}
.app-shell.sidebar-hidden .sidebar-item svg {
  width: 20px;
  height: 20px;
  margin: 0 !important;
}
.sidebar-section-icon { display: none; }
.app-shell.sidebar-hidden .sidebar-group { position: relative; }
.app-shell.sidebar-hidden .sidebar-section-label {
  display: flex !important;
  justify-content: center !important;
  padding: 12px 0;
  opacity: 1 !important;
}
.app-shell.sidebar-hidden .sidebar-section-icon { display: block; }
.app-shell.sidebar-hidden .sidebar-section-label:hover { background: rgba(0,0,0,0.02); }

.sidebar-group-items.collapsed { display: none; }
.app-shell.sidebar-hidden .sidebar-group-items.collapsed,
.app-shell.sidebar-hidden .sidebar-group-items.expanded {
  display: none !important;
  position: absolute;
  left: 64px;
  top: 50%;
  transform: translateY(-50%);
  width: 240px;
  background: white;
  box-shadow: var(--shadow-modal);
  border-radius: var(--r-md);
  border: 1px solid var(--clr-border);
  padding: 8px;
  z-index: 9999;
}
.app-shell.sidebar-hidden .sidebar-group:hover .sidebar-group-items.collapsed,
.app-shell.sidebar-hidden .sidebar-group:hover .sidebar-group-items.expanded {
  display: block !important;
}
.app-shell.sidebar-hidden .sidebar-group-items .sidebar-item {
  justify-content: flex-start;
  padding: 8px 12px;
}
.app-shell.sidebar-hidden .sidebar-group-items .sidebar-item svg {
  margin: 0 12px 0 0 !important;
}
.app-shell.sidebar-hidden .sidebar-group-items .sidebar-item-label {
  display: block !important;
}
.app-shell.sidebar-hidden .sidebar-flyout-header {
  display: block !important;
}
.app-shell.sidebar-hidden .ws-icon-collapsed {
  display: flex !important;
  justify-content: center;
}
.app-shell.sidebar-hidden .workspace-switcher {
  display: flex;
  justify-content: center;
}
.app-shell.sidebar-hidden .sidebar-footer {
  padding: var(--space-4) 0;
  align-items: center;
}
.app-shell.sidebar-hidden .sidebar-footer .btn {
  padding: 8px 0;
}
.app-shell.sidebar-hidden .sidebar-footer .btn svg {
  margin: 0 !important;
  width: 18px; height: 18px;
}



/* 💠 Sidebar 💠 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.clickable-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.clickable-row:hover {
  background-color: var(--clr-surface-2) !important;
}

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { 
  background-color: lavender; 
  background-clip: padding-box; 
  border: 3px solid transparent; 
  border-radius: 99px; 
}
::-webkit-scrollbar-thumb:hover { 
  border: 1px solid transparent; 
  background-color: #d8bfd8; /* Thistle (darker lavender) */
}

/* ── Layout Shell ──────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────── */
.sidebar {
  grid-row: 1 / 3;
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  padding: var(--space-4) 0;
  overflow-y: auto;
}

.sidebar-logo {
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
  display: flex; align-items: center; gap: var(--space-3);
}

.sidebar-logo .logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--clr-primary), #7c3aed);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.sidebar-logo .logo-text { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; color: var(--clr-text); }
.sidebar-logo .logo-sub  { font-size: 10px; color: var(--clr-text-3); letter-spacing: 0.5px; text-transform: uppercase; }

.sidebar-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--clr-text-3);
  padding: var(--space-3) var(--space-5) var(--space-1);
  margin-top: var(--space-2);
}
.sidebar-section-label.section-t-ng-quan { color: var(--clr-primary); }
.sidebar-section-label.section-nghi-p-v- { color: var(--clr-accent); }
.sidebar-section-label.section-b-o-c-o { color: var(--clr-warning); }
.sidebar-section-label.section-qu-n-l- { color: var(--clr-danger); }
.sidebar-section-label.section-c-i---t---v-n-h-nh { color: var(--clr-text-2); }

.sidebar-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 7px var(--space-5);
  color: var(--clr-text-2);
  cursor: pointer; font-size: 13px; font-weight: 500;
  border-radius: 0; transition: all 0.12s ease;
  text-decoration: none; border: none; background: none; width: 100%;
  text-align: left;
  border-left: 2px solid transparent;
}

.sidebar-item:hover { color: var(--clr-text); background: var(--clr-surface-2); }

.sidebar-item.active {
  color: var(--clr-primary);
  background: var(--clr-primary-dim);
  border-left-color: var(--clr-primary);
  font-weight: 600;
}

.sidebar-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--clr-border);
}

/* Workspace Switcher */
.workspace-switcher {
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  padding: var(--space-3);
  margin: var(--space-4) var(--space-4) 0;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.workspace-switcher:hover { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }

.workspace-switcher .ws-name {
  font-size: 12px; font-weight: 600; color: var(--clr-text);
  display: flex; align-items: center; justify-content: space-between;
}
.workspace-switcher .ws-role {
  font-size: 10px; color: var(--clr-text-3); margin-top: 2px;
}

/* ── Header ────────────────────────────────────── */
.app-header {
  grid-column: 2;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--clr-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6);
  box-shadow: 0 1px 2px rgba(9, 9, 11, 0.02);
  /* Header stays BELOW modals — modals have z-index:9999 */
  position: relative;
  z-index: 10;
}

.header-breadcrumb {
  font-size: 14px; font-weight: 600; color: var(--clr-text);
}

.header-actions { display: flex; align-items: center; gap: var(--space-3); }

.dev-role-switcher {
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid #fdba74;
  border-radius: var(--r-sm);
  background: #fff7ed;
  color: #9a3412;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.dev-role-switcher select {
  min-width: 128px;
  max-width: 170px;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.dev-role-switcher select:disabled { cursor: wait; opacity: 0.65; }

.admin-header .dev-role-switcher {
  border-color: rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.12);
  color: white;
}

.admin-header .dev-role-switcher select option { color: #111827; }

/* ── Main Content ──────────────────────────────── */
.main-content {
  grid-column: 2;
  overflow-y: auto;
  padding: var(--space-6);
  background: var(--clr-bg);
}

/* ── Page Header ───────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-6);
}
.page-title { font-size: 20px; font-weight: 700; color: var(--clr-text); letter-spacing: -0.3px; }
.page-subtitle { font-size: 13px; color: var(--clr-text-2); margin-top: 2px; }

/* ── Cards ─────────────────────────────────────── */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-4);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--clr-text); }

/* KPI Cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }

.kpi-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  position: relative; overflow: hidden;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.kpi-card:hover { border-color: var(--clr-primary); transform: translateY(-2px); box-shadow: var(--shadow-card); }
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--clr-primary), #7c3aed);
}
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; color: var(--clr-text-3); text-transform: uppercase; }
.kpi-value { font-size: 22px; font-weight: 700; margin: var(--space-1) 0; font-family: var(--font-mono); color: var(--clr-text); }
.kpi-change { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.kpi-change.up   { color: var(--clr-credit); }
.kpi-change.down { color: var(--clr-debit); }

/* ── Tables ────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: 0 !important;
  border: 1px solid var(--clr-border);
  box-shadow: var(--shadow-sm);
}

table { min-width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }

.card:has(table),
.card:has(.table-wrapper) {
  border-radius: 0 !important;
}

thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--clr-text-3);
  background: var(--clr-bg);
  border-bottom: 1px solid var(--clr-border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--clr-border); transition: background-color 0.15s ease; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--clr-surface-2); }

tbody td, tfoot td {
  padding: var(--space-3) var(--space-4);
  font-size: 13px; color: var(--clr-text);
}

.td-mono { font-family: var(--font-mono); font-size: 12px; color: var(--clr-text); font-variant-numeric: tabular-nums; }
.td-debit  { color: var(--clr-debit); font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.td-credit { color: var(--clr-credit); font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.td-warning { color: var(--clr-warning); font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.td-muted { color: var(--clr-text-2); }
/* Cột nút action — không xuống dòng, các nút xếp ngang */
.td-actions {
  white-space: nowrap;
  padding: 4px 8px !important;
  text-align: right;
}
.td-actions .btn-icon, .td-actions button { flex-shrink: 0; }
.td-nowrap { white-space: nowrap; }

/* ── Badges / Chips ────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
}
.badge-green  { background: rgba(5,150,105,0.1);  color: #047857; border: 1px solid rgba(5,150,105,0.2); }
.badge-blue   { background: rgba(79, 70, 229, 0.1);  color: var(--clr-primary); border: 1px solid rgba(79, 70, 229, 0.2); }
.badge-red    { background: rgba(225, 29, 72, 0.1);  color: var(--clr-danger); border: 1px solid rgba(225, 29, 72, 0.2); }
.badge-yellow { background: rgba(217,119,6,0.1);  color: var(--clr-warning); border: 1px solid rgba(217,119,6,0.2); }
.badge-gray   { background: var(--clr-bg);        color: var(--clr-text-2); border: 1px solid var(--clr-border); }

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all 0.12s ease;
  font-family: var(--font-sans); white-space: nowrap;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.6; cursor: not-allowed; 
}
.btn svg { width: 15px; height: 15px; }

/* SEARCH BAR */
.search-box {
  display: flex;
  align-items: center;
  background: var(--clr-bg-alt);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  padding: 0 12px;
  gap: 8px;
  transition: all 0.2s ease;
  color: var(--clr-text-3);
}
.search-box:focus-within {
  border-color: var(--clr-primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  color: var(--clr-primary);
}
.search-input {
  border: none;
  background: transparent;
  outline: none;
  padding: 10px 0;
  width: 100%;
  font-size: 13.5px;
  color: var(--clr-text-1);
}
.search-input::placeholder {
  color: var(--clr-text-3);
}

.btn-primary {
  background: var(--clr-primary); color: white; border-color: var(--clr-primary);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover { background: var(--clr-primary-hover); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25); transform: translateY(-1px); }

.btn-ghost {
  background: transparent; color: var(--clr-text-2); border-color: transparent;
}
.btn-ghost:hover { color: var(--clr-text); background: var(--clr-surface-2); border-color: var(--clr-border); transform: translateY(-1px); }

.btn-danger {
  background: var(--clr-surface); color: var(--clr-danger); border-color: var(--clr-border);
}
.btn-danger:hover { background: var(--clr-danger-dim); border-color: var(--clr-danger); transform: translateY(-1px); }

.btn-success {
  background: rgba(5,150,105,0.1); color: var(--clr-accent); border-color: rgba(5,150,105,0.2);
}
.btn-success:hover { background: var(--clr-accent); color: white; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  width: 30px; height: 30px; padding: 0;
  display: inline-flex;
  align-items: center; justify-content: center;
  background: transparent; color: var(--clr-text-3); border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.12s;
}
.btn-icon:hover { color: var(--clr-text); background: var(--clr-bg); }

/* ── Form elements ─────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); }
.form-label { font-size: 12px; font-weight: 600; color: var(--clr-text-2); }

.form-input, .form-select, .form-textarea {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  color: var(--clr-text);
  font-size: 13px; font-family: var(--font-sans);
  padding: 7px var(--space-3);
  width: 100%; outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.form-input::placeholder { color: var(--clr-text-3); }
.form-select { cursor: pointer; }

/* ── Form Table (line-item grids in modals) ────── */
.form-table { border-collapse: collapse; }
.form-table th {
  padding: 6px 8px;
  text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--clr-text-3);
  background: var(--clr-bg);
  border-bottom: 1px solid var(--clr-border);
  white-space: nowrap;
}
.form-table td {
  padding: 3px 4px;
  border-bottom: 1px solid var(--clr-border-soft);
  vertical-align: middle;
}
.form-table tr:last-child td { border-bottom: none; }
/* Inputs bên trong form-table: không có border box riêng, mỏng hơn */
.form-table .form-input,
.form-table .form-select,
.form-table select {
  font-size: 12px;
  padding: 5px 8px;
  border-color: transparent;
  background: transparent;
}
.form-table .form-input.form-input-bordered {
  border-color: var(--clr-border);
  background: var(--clr-surface);
}
.form-table .form-input:hover,
.form-table .form-select:hover,
.form-table select:hover { background: var(--clr-surface-2); border-color: var(--clr-border); }
.form-table .form-input:focus { background: var(--clr-surface); border-color: var(--clr-primary); box-shadow: 0 0 0 2px var(--clr-primary-dim); }

/* ── Auto-grow input (giãn theo nội dung) ────────
   Dùng: <div class="input-grow" data-value={value}><input .../></div>
   Input sẽ chiều rộng theo nội dung, tối thiểu min-width.
   ─────────────────────────────────────────────── */
.input-grow {
  display: inline-grid;
  min-width: 40px;
  max-width: 100%;
}
.input-grow::after {
  content: attr(data-value) '\00a0';  /* \00a0 = non-breaking space padding */
  visibility: hidden;
  white-space: pre;
  font: inherit;
  font-size: 12px;
  padding: 5px 8px;
  grid-area: 1 / 1;
  
}
.input-grow > input {
  grid-area: 1 / 1;
  width: 100%;
  min-width: 0;
  padding: 5px 8px;
  font-size: 12px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  outline: none;
  color: var(--clr-text);
  font-family: var(--font-sans);
  transition: border-color 0.12s, background 0.12s;
}
.input-grow > input:hover  { background: var(--clr-bg); border-color: var(--clr-border); }
.input-grow > input:focus  { background: var(--clr-surface); border-color: var(--clr-primary); box-shadow: 0 0 0 2px var(--clr-primary-dim); }
.input-grow > input::placeholder { color: var(--clr-text-3); }
/* Biến thể số (mono, căn phải) */
.input-grow.is-number > input,
.input-grow.is-number::after { font-family: var(--font-mono); text-align: right; }


/* ── Modal ─────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.35); backdrop-filter: blur(4px);
  z-index: 9999;                     /* Always on top of EVERYTHING */
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-6);
  animation: backdropIn 0.15s ease;
}

@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  width: 96vw; max-width: 1600px;
  max-height: 96vh; overflow-y: auto;
  animation: modalIn 0.18s ease;
}

@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--clr-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body   { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--clr-border);
  display: flex; justify-content: flex-end; gap: var(--space-3);
  background: var(--clr-bg); border-radius: 0 0 var(--r-xl) var(--r-xl);
  flex-shrink: 0;
}

/* Modal Sizes */
.modal-lg {
  width: 95vw !important;
  max-width: 1320px !important;
  height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
}
.modal-lg .modal-body {
  flex: 1 !important;
  overflow-y: auto !important;
}

.modal-full {
  width: 98vw !important;
  max-width: 1600px !important;
  height: 96vh !important;
  display: flex !important;
  flex-direction: column !important;
}
.modal-full .modal-body {
  flex: 1 !important;
  overflow-y: auto !important;
}

/* Drawer styles */
.drawer {
  background: var(--clr-surface);
  box-shadow: -4px 0 24px rgba(15,23,42,0.15);
  height: 100vh;
  position: absolute;
  right: 0;
  top: 0;
  display: flex;
  flex-direction: column;
}
.slide-in-right {
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.modal-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  width: 96vw; max-width: 1600px;
  max-height: 96vh; overflow-y: auto;
  animation: modalIn 0.18s ease;
  position: relative;
}

.modal-title    { font-size: 15px; font-weight: 700; color: var(--clr-text); }
.modal-subtitle { font-size: 12px; color: var(--clr-text-3); margin-top: 2px; }


/* ── Divider ───────────────────────────────────── */
.divider {
  height: 1px; background: var(--clr-border); margin: var(--space-4) 0;
}

/* ── Alert boxes ───────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-sm);
  font-size: 13px;
  border: 1px solid;
}
.alert-error   { background: rgba(220,38,38,0.06);  border-color: rgba(220,38,38,0.2);  color: var(--clr-danger); }
.alert-success { background: rgba(5,150,105,0.06);  border-color: rgba(5,150,105,0.2);  color: var(--clr-accent); }
.alert-info    { background: rgba(37,99,235,0.06);  border-color: rgba(37,99,235,0.2);  color: var(--clr-primary); }

/* ── Login Page ─────────────────────────────────── */
/* Table Column Resizer */
.table-wrapper th, .form-table th {
  position: relative;
}
.th-resizer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 9px; /* Khu vực bắt chuột rộng hơn chút cho dễ kéo */
  transform: translateX(50%); /* Đặt chính giữa ranh giới 2 cột */
  cursor: col-resize;
  user-select: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Vạch kẻ nhỏ ở giữa */
.th-resizer::after {
  content: '';
  display: block;
  width: 1px;
  height: 50%; /* Vạch mờ cao 50% th */
  background-color: var(--clr-border);
  transition: all 0.2s;
}
/* Khi hover hoặc đang kéo: vạch kẻ sẽ cao lên 100%, đậm lên và đổi màu primary */
.th-resizer:hover::after, .th-resizer.is-resizing::after {
  height: 100%;
  width: 2px;
  background-color: var(--clr-primary);
}

.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 50%, #ecfdf5 100%);
}
.login-box {
  width: 100%; max-width: 420px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-modal);
}
.login-logo {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-8);
  justify-content: center;
}
.login-logo .lm {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--clr-primary), #7c3aed);
  border-radius: var(--r-md); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: white;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.login-title { text-align: center; margin-bottom: var(--space-6); }
.login-title h2 { font-size: 22px; font-weight: 700; color: var(--clr-text); }
.login-title p  { color: var(--clr-text-2); font-size: 13px; margin-top: 4px; }

/* ── Tabs ───────────────────────────────────────── */
.tab-list {
  display: flex;
  border-bottom: 1px solid var(--clr-border);
  margin-bottom: var(--space-5);
  gap: 0;
}
.tab-item {
  padding: 10px var(--space-5);
  font-size: 13px; font-weight: 500;
  color: var(--clr-text-2);
  cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.12s;
  font-family: var(--font-sans);
}
.tab-item:hover { color: var(--clr-text); }
.tab-item.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); font-weight: 600; }

/* ── Admin Layout ────────────────────────────────── */
.admin-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
}

.admin-header {
  grid-column: 1 / 3;
  background: linear-gradient(90deg, var(--clr-primary), #7c3aed);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6);
  color: white;
}

.admin-sidebar {
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  overflow-y: auto;
  padding: var(--space-4) 0;
}

.admin-main {
  background: var(--clr-bg);
  overflow-y: auto;
  padding: var(--space-6);
}

/* ── Utilities ─────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.text-sm   { font-size: 12px; }
.text-muted { color: var(--clr-text-2); }
.font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }

/* ── Animations ─────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.fade-in { animation: fadeIn 0.2s ease forwards; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid var(--clr-border); border-top-color: var(--clr-primary);
  animation: spin 0.65s cubic-bezier(0.5, 0, 0.5, 1) infinite; display: inline-block;
}
.spinner-white {
  border-color: rgba(255,255,255,0.3); border-top-color: #fff;
}

/* ── Premium Skeleton / Shimmer ─────────────────── */
@keyframes skeletonShimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skeleton-base {
  border-radius: var(--r-sm);
  background: linear-gradient(
    90deg,
    var(--clr-border) 25%,
    var(--clr-surface-2) 50%,
    var(--clr-border) 75%
  );
  background-size: 600px 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}

/* Table skeleton */
.skeleton-row td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--clr-border-soft);
}
.skeleton-cell {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--clr-border) 25%,
    #f8f8fa 50%,
    var(--clr-border) 75%
  );
  background-size: 600px 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
  min-width: 32px;
}

/* Block skeleton utilities */
.skeleton-line {
  height: 13px;
  border-radius: 5px;
  margin-bottom: 8px;
}
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line-sm  { height: 11px; }
.skeleton-line-lg  { height: 18px; }
.skeleton-line-xl  { height: 24px; border-radius: 7px; }

/* Card skeleton */
.skeleton-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  padding: 20px;
}

/* Inline spinner for tables — centered in cell */
.table-loading-row td {
  padding: 40px 12px;
  text-align: center;
}
.table-skeleton-pulse {
  display: inline-block;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  animation: spin 0.65s cubic-bezier(0.5,0,0.5,1) infinite;
}

/* ── Empty state ───────────────────────────────── */
.empty-state {
  text-align: center; padding: var(--space-12) var(--space-6);
  color: var(--clr-text-3);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: var(--space-4); opacity: 0.25; }
.empty-state p   { font-size: 14px; }

/* ── Chart area ─────────────────────────────────── */
.chart-wrapper { height: 240px; margin-top: var(--space-4); }

/* ── Search bar ──────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  padding: 0 var(--space-3);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search-bar:focus-within {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--clr-primary-dim);
}
.search-bar input {
  border: none; background: none; outline: none;
  padding: 7px 0; font-size: 13px; color: var(--clr-text);
  font-family: var(--font-sans); width: 100%;
}
.search-bar input::placeholder { color: var(--clr-text-3); }

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon input,
.input-with-icon .form-input {
  width: 100%;
}

/* Inline validation error borders and hints */
.form-input.is-invalid, 
.input-grow.is-invalid input,
input.form-input.is-invalid {
  border-color: var(--clr-danger) !important;
  box-shadow: 0 0 0 1px var(--clr-danger-dim) !important;
}

.error-hint {
  color: var(--clr-danger);
  font-size: 11px;
  margin-top: 4px;
  display: block;
  font-weight: 500;
}

/* ── CmdK Palette ──────────────────────────────── */
.cmdk-group [cmdk-group-heading] {
  padding: 12px 12px 4px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--clr-text-3);
  letter-spacing: 0.5px;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--clr-text);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.1s ease;
}
.cmdk-item[data-selected="true"] {
  background: var(--clr-primary);
  color: var(--clr-text-inv);
}
.cmdk-kbd {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--clr-border);
  border: 1px solid #ccc;
  font-family: var(--font-mono);
  font-size: 10px;
}
