@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --navy: #0f1f3d;
  --navy2: #162845;
  --navy3: #1e3460;
  --blue: #2563eb;
  --blue2: #3b82f6;
  --blue-light: #dbeafe;
  --accent: #f59e0b;
  --accent2: #fbbf24;
  --green: #10b981;
  --green-light: #d1fae5;
  --red: #ef4444;
  --red-light: #fee2e2;
  --yellow: #f59e0b;
  --yellow-light: #fef3c7;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --white: #ffffff;
  --sidebar-w: 260px;
  --sidebar-collapsed: 64px;
  --header-h: 60px;
  --font: 'Be Vietnam Pro', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ===== AUTH SCREEN ===== */
#auth-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #0f1f3d 0%, #1e3460 50%, #162845 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
  overflow: hidden;
}
#auth-screen::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 80%, rgba(37,99,235,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(245,158,11,0.08) 0%, transparent 60%);
  pointer-events: none;
}
.auth-card {
  background: white; border-radius: 20px;
  width: 100%; max-width: 440px; margin: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  overflow: hidden; position: relative; z-index: 1;
}
.auth-header {
  background: linear-gradient(135deg, #0f1f3d, #1e3460);
  padding: 32px 32px 24px; text-align: center;
}
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #f59e0b);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: white;
  margin: 0 auto 12px; letter-spacing: -1px;
}
.auth-brand { color: white; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.auth-tagline { color: rgba(255,255,255,0.5); font-size: 12px; margin-top: 4px; }
.auth-tabs {
  display: flex; border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.auth-tab {
  flex: 1; padding: 14px; text-align: center;
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--gray-400); border-bottom: 2px solid transparent;
  transition: all .2s; background: transparent; border-left: none; border-right: none; border-top: none;
  font-family: var(--font);
}
.auth-tab.active { color: var(--blue); border-bottom-color: var(--blue); background: white; }
.auth-body { padding: 28px 32px 24px; }
.auth-form-group { margin-bottom: 14px; }
.auth-label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.auth-field-error { font-size: 11px; color: #dc2626; margin-top: 4px; display: none; }
.auth-input.field-error { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,0.12) !important; }
.auth-input.field-ok { border-color: #10b981 !important; }
.auth-input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--gray-200); border-radius: 10px;
  font-family: var(--font); font-size: 14px; color: var(--gray-800);
  outline: none; transition: all .15s; background: white;
}
.auth-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.auth-input.error { border-color: var(--red); }
.auth-input-wrap { position: relative; }
.auth-input-icon {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); cursor: pointer; font-size: 15px; user-select: none;
}
.auth-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white; border: none; border-radius: 10px;
  font-family: var(--font); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all .2s; margin-top: 6px;
  letter-spacing: 0.2px;
}
.auth-btn:hover { background: linear-gradient(135deg, #1d4ed8, #1e40af); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(37,99,235,0.3); }
.auth-btn:active { transform: translateY(0); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--gray-300); font-size: 11px; margin: 16px 0;
}
.auth-divider::before, .auth-divider::after { content:''; flex:1; height:1px; background:var(--gray-200); }
.auth-error {
  background: var(--red-light); border: 1px solid #fecaca;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
  font-size: 12px; color: #dc2626; display: none;
}
.auth-success {
  background: var(--green-light); border: 1px solid #a7f3d0;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
  font-size: 12px; color: #059669; display: none;
}
.auth-footer-note {
  text-align: center; font-size: 11px; color: var(--gray-400); margin-top: 16px;
  padding-top: 16px; border-top: 1px solid var(--gray-100);
}
.auth-role-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 99px; font-size: 11px; font-weight: 600;
}
.auth-loading { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth screen covers everything via z-index:9999 */

#sidebar {
  position: fixed; left:0; top:0; bottom:0;
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex; flex-direction: column;
  transition: width .25s ease;
  z-index: 100;
  overflow: hidden;
}
#sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  padding: 0 16px;
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; color: white; font-weight: 700;
}
.logo-text {
  color: white; font-weight: 700; font-size: 16px; letter-spacing: -0.3px;
  white-space: nowrap; opacity: 1; transition: opacity .2s;
}
#sidebar.collapsed .logo-text { opacity: 0; pointer-events: none; }

.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 8px 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-group { margin-bottom: 2px; }
.nav-group-label {
  padding: 10px 20px 4px;
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  color: rgba(255,255,255,0.3); text-transform: uppercase;
  white-space: nowrap; overflow: hidden;
  transition: opacity .2s;
}
#sidebar.collapsed .nav-group-label { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .15s;
  border-radius: 0;
  color: rgba(255,255,255,0.65);
  position: relative;
  white-space: nowrap;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.nav-item.active {
  background: rgba(37,99,235,0.25);
  color: white;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--blue2); border-radius: 0 3px 3px 0;
}
.nav-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
  background: rgba(255,255,255,0.06);
}
.nav-item.active .nav-icon { background: rgba(37,99,235,0.35); }
.nav-label {
  font-size: 13.5px; font-weight: 500;
  transition: opacity .2s;
}
#sidebar.collapsed .nav-label { opacity: 0; pointer-events: none; }

.nav-badge {
  margin-left: auto; background: var(--red);
  color: white; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 99px; min-width: 18px;
  text-align: center; transition: opacity .2s;
}
#sidebar.collapsed .nav-badge { opacity: 0; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 12px;
  flex-shrink: 0;
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.user-card:hover { background: rgba(255,255,255,0.06); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.user-info { min-width: 0; transition: opacity .2s; }
#sidebar.collapsed .user-info { opacity: 0; }
.user-name { color: white; font-weight: 600; font-size: 13px; }
.user-role { color: rgba(255,255,255,0.4); font-size: 11px; }

/* ===== HEADER ===== */
#header {
  position: fixed; top: 0; right: 0;
  left: var(--sidebar-w);
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  z-index: 99;
  transition: left .25s ease;
  box-shadow: var(--shadow);
}
body.sidebar-collapsed #header { left: var(--sidebar-collapsed); }

.toggle-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--gray-200); background: white;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 16px;
  color: var(--gray-500); transition: all .15s;
  flex-shrink: 0;
}
.toggle-btn:hover { background: var(--gray-100); color: var(--gray-700); }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  color: var(--gray-500); font-size: 13px;
}
.breadcrumb-current {
  color: var(--gray-800); font-weight: 600; font-size: 14px;
}
.breadcrumb-sep { color: var(--gray-300); }

.header-actions {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: all .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--blue); color: white;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary {
  background: var(--gray-100); color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-accent {
  background: var(--accent); color: white;
}
.btn-accent:hover { background: #d97706; }
.btn-danger {
  background: var(--red-light); color: var(--red);
  border: 1px solid #fecaca;
}
.btn-success {
  background: var(--green-light); color: #059669;
  border: 1px solid #a7f3d0;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

.notification-btn {
  position: relative;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--gray-200); background: white;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 16px; color: var(--gray-600);
}
.notif-dot {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; background: var(--red);
  border-radius: 99px; border: 2px solid white;
  font-size: 9px; font-weight: 700; color: white;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* ===== MAIN CONTENT ===== */
#main {
  margin-left: var(--sidebar-w);
  padding-top: var(--header-h);
  min-height: 100vh;
  transition: margin-left .25s ease;
}
body.sidebar-collapsed #main { margin-left: var(--sidebar-collapsed); }

.page { display: none; padding: 24px; }
.page.active { display: block; }

/* ===== DASHBOARD ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white; border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--gray-500); margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--gray-800); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.stat-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
}
.stat-trend { font-size: 11px; font-weight: 500; margin-top: 6px; }
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

.charts-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: white; border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-weight: 600; font-size: 14px; color: var(--gray-800); }
.card-body { padding: 20px; }

/* Bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 160px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar {
  width: 60%; border-radius: 4px 4px 0 0;
  background: var(--blue);
  transition: height .3s ease;
  min-height: 4px;
}
.bar.accent { background: var(--accent); }
.bar-label { font-size: 10px; color: var(--gray-400); }

/* HSD alerts */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid;
}
.alert-item.red { background: var(--red-light); border-color: #fecaca; }
.alert-item.yellow { background: var(--yellow-light); border-color: #fde68a; }
.alert-item.green { background: var(--green-light); border-color: #a7f3d0; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alert-item.red .alert-dot { background: var(--red); }
.alert-item.yellow .alert-dot { background: var(--yellow); }
.alert-item.green .alert-dot { background: var(--green); }
.alert-name { font-weight: 500; font-size: 12px; flex: 1; }
.alert-days { font-size: 11px; font-weight: 600; }
.alert-item.red .alert-days { color: var(--red); }
.alert-item.yellow .alert-days { color: #d97706; }
.alert-item.green .alert-days { color: #059669; }

/* ===== TABLE ===== */
.table-container {
  background: white; border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-toolbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.search-box {
  position: relative; flex: 1; min-width: 200px;
}
.search-box input {
  width: 100%; padding: 7px 12px 7px 32px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; color: var(--gray-700);
  background: var(--gray-50); outline: none; transition: border .15s;
}
.search-box input:focus { border-color: var(--blue2); background: white; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 13px;
}
.filter-select {
  padding: 7px 28px 7px 10px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); font-family: var(--font);
  font-size: 13px; color: var(--gray-600); background: white;
  outline: none; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--gray-500);
  background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
td {
  padding: 11px 14px; font-size: 13px; color: var(--gray-700);
  vertical-align: middle;
}
.code-cell {
  font-family: var(--mono); font-size: 12px;
  color: var(--blue); background: var(--blue-light);
  padding: 2px 7px; border-radius: 4px; display: inline-block;
}

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-green { background: var(--green-light); color: #059669; }
.badge-red { background: var(--red-light); color: #dc2626; }
.badge-yellow { background: var(--yellow-light); color: #d97706; }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-navy { background: #dbeafe; color: var(--navy); }
.badge::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor;
}

/* Action buttons */
.action-btns { display: flex; gap: 4px; }
.action-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--gray-200); background: white;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 13px;
  color: var(--gray-500); transition: all .15s;
}
.action-btn:hover { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.action-btn.danger:hover { background: var(--red-light); color: var(--red); border-color: #fecaca; }

.pagination {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.page-info { font-size: 12px; color: var(--gray-500); }
.page-btns { display: flex; gap: 4px; }
.page-btn {
  width: 30px; height: 30px; border-radius: 6px;
  border: 1px solid var(--gray-200); background: white;
  cursor: pointer; font-size: 12px; color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.page-btn:hover, .page-btn.active {
  background: var(--blue); color: white; border-color: var(--blue);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 200; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 14px;
  width: 90%; max-width: 600px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-title { font-weight: 700; font-size: 16px; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--gray-200); background: white;
  cursor: pointer; font-size: 16px; color: var(--gray-500);
  display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 8px;
  position: sticky; bottom: 0; background: white;
}

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
label { font-size: 12px; font-weight: 500; color: var(--gray-600); }
.form-input, .form-select, .form-textarea {
  padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); font-family: var(--font);
  font-size: 13px; color: var(--gray-700); outline: none;
  transition: border .15s; background: white;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue2); box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* Section heading */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.section-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* Tabs */
.tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  color: var(--gray-500); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .15s; white-space: nowrap;
}
.tab:hover { color: var(--blue); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Approve banner */
.approve-banner {
  background: var(--yellow-light); border: 1px solid #fde68a;
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.approve-banner .icon { font-size: 18px; }
.approve-text { flex: 1; font-size: 13px; color: #92400e; }
.approve-text strong { display: block; font-weight: 600; }

/* Import Gmail section */
.import-card {
  background: linear-gradient(135deg, var(--navy), var(--navy3));
  border-radius: var(--radius); padding: 24px;
  color: white; margin-bottom: 20px;
  display: flex; align-items: center; gap: 20px;
}
.import-icon { font-size: 40px; }
.import-info { flex: 1; }
.import-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.import-sub { font-size: 12px; opacity: 0.65; }

/* NCC dependency chart */
.ncc-bar-list { display: flex; flex-direction: column; gap: 10px; }
.ncc-bar-item {}
.ncc-bar-label {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 4px;
}
.ncc-bar-track {
  height: 8px; background: var(--gray-100);
  border-radius: 99px; overflow: hidden;
}
.ncc-bar-fill {
  height: 100%; border-radius: 99px;
  background: var(--blue);
  transition: width .5s ease;
}
.ncc-bar-fill.warn { background: var(--accent); }
.ncc-bar-fill.danger { background: var(--red); }

/* Status flow */
.status-flow {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; margin: 12px 0;
}
.status-step {
  display: flex; align-items: center; gap: 6px;
}
.status-bubble {
  padding: 4px 12px; border-radius: 99px;
  font-size: 11px; font-weight: 500;
  background: var(--gray-100); color: var(--gray-500);
  white-space: nowrap;
}
.status-bubble.done {
  background: var(--green-light); color: #059669;
}
.status-bubble.current {
  background: var(--blue-light); color: var(--blue);
  border: 1px solid #93c5fd;
}
.status-arrow { color: var(--gray-300); font-size: 12px; }

/* Responsive */
#bottom-nav { display: none; }

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  html, body { overflow-x: hidden; }
  #sidebar {
    width: 82vw; max-width: 300px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 2px 0 24px rgba(0,0,0,.35);
    z-index: 200;
  }
  #sidebar.collapsed { width: 82vw; max-width: 300px; }
  #sidebar.collapsed .nav-label,
  #sidebar.collapsed .logo-text,
  #sidebar.collapsed .nav-group-label,
  #sidebar.collapsed .user-info { opacity: 1 !important; pointer-events: auto; }
  body.mobile-nav-open #sidebar { transform: translateX(0); }
  #header { left: 0 !important; padding: 0 12px; }
  #main, body.sidebar-collapsed #main { margin-left: 0 !important; }
  body.sidebar-collapsed #header { left: 0 !important; }
  #mobile-nav-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 150;
  }
  body.mobile-nav-open #mobile-nav-overlay { display: block; }
  .modal { max-width: 94vw !important; width: 94vw; }
  #notif-panel { width: 92vw !important; right: -4px !important; max-width: 92vw; }
  .header-actions .btn-accent { font-size: 12px; padding: 6px 10px; }
  .toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; }
  /* Header gọn gàng 1 hàng */
  :root { --header-h: 56px; }
  #header { gap: 8px; }
  .breadcrumb { min-width: 0; flex: 1 1 auto; overflow: hidden; }
  .breadcrumb span:not(.breadcrumb-current), .breadcrumb-sep { display: none; }
  .breadcrumb-current { display: block; flex: 1 1 auto; min-width: 0; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; font-weight: 700; }
  .header-actions { gap: 6px; flex-shrink: 0; }
  .header-actions .btn-label { display: none; }
  .header-actions .btn-accent { padding: 8px 10px; }
  /* Bảng cuộn ngang trong card thay vì bị cắt */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; font-size: 12px; }
  th, td { padding: 8px 10px; }
  .section-header { flex-wrap: wrap; gap: 8px; }

  /* ===== Giao diện mobile kiểu app ===== */
  body { background: #eef1f6; }
  #main { padding-bottom: 80px; }
  .page { padding: 14px !important; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat-card { border-radius: 16px; padding: 14px; box-shadow: 0 1px 4px rgba(15,31,61,.06); }
  .card { border-radius: 16px !important; box-shadow: 0 1px 5px rgba(15,31,61,.06); border: 1px solid #e8edf3; margin-bottom: 12px; }
  .section-title { font-size: 17px; }
  .btn { padding: 10px 16px; border-radius: 12px; font-size: 14px; min-height: 42px; }
  .btn.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 12px; }
  .form-input, .form-select, .form-textarea { font-size: 15px; padding: 11px 12px; border-radius: 10px; }
  .modal { border-radius: 16px !important; }
  .nav-item { padding: 12px 14px; }

  /* Thanh điều hướng dưới đáy — kiểu app */
  #bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0;
    height: 62px; background: #fff;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -2px 14px rgba(15,31,61,.07);
    z-index: 120; padding-bottom: env(safe-area-inset-bottom, 0);
  }
  #bottom-nav .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; border: none; background: none; cursor: pointer;
    color: var(--gray-400); font-size: 10px; font-weight: 700;
    font-family: var(--font); padding: 8px 0; transition: color .15s;
  }
  #bottom-nav .bn-item .bn-ic { font-size: 20px; line-height: 1; }
  #bottom-nav .bn-item.active { color: var(--blue); }
  #bottom-nav .bn-item.active .bn-ic { transform: translateY(-1px); }
}

/* Toast */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--gray-800); color: white;
  padding: 12px 16px; border-radius: 10px;
  font-size: 13px; display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lg); min-width: 240px;
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.success { background: #064e3b; }
.toast.warning { background: #78350f; }
.toast.error { background: #7f1d1d; }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--gray-400);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--gray-500); margin-bottom: 4px; }
.empty-sub { font-size: 13px; }

/* ===== PHIẾU MODAL ===== */
.modal-phieu { max-width: 860px; width: 95%; }
.phieu-editor-layout {
  display: grid; grid-template-columns: 280px 1fr;
  gap: 0; min-height: 500px;
}
.phieu-editor-panel {
  background: var(--gray-50); border-right: 1px solid var(--gray-200);
  padding: 16px; overflow-y: auto;
}
.phieu-editor-panel h4 {
  font-size: 11px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 14px 0 8px; padding-bottom: 4px;
  border-bottom: 1px solid var(--gray-200);
}
.phieu-editor-panel h4:first-child { margin-top: 0; }
.editor-field { margin-bottom: 8px; }
.editor-field label { font-size: 11px; font-weight: 500; color: var(--gray-600); display: block; margin-bottom: 3px; }
.editor-field input, .editor-field select, .editor-field textarea {
  width: 100%; padding: 6px 8px;
  border: 1px solid var(--gray-200); border-radius: 5px;
  font-family: var(--font); font-size: 12px; color: var(--gray-700);
  background: white; outline: none;
}
.editor-field input:focus, .editor-field select:focus, .editor-field textarea:focus {
  border-color: var(--blue2);
}
.editor-field textarea { resize: vertical; min-height: 56px; }

.phieu-preview-panel { padding: 20px; overflow-y: auto; background: #f0f4f8; }
.phieu-preview-panel .phieu-doc {
  background: white; padding: 24px 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  min-height: 100%;
  font-size: 11.5px;
}

/* Phiếu document styles */
.pdoc-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 2px solid var(--navy);
}
.pdoc-co-name { font-size: 12px; font-weight: 700; color: var(--navy); }
.pdoc-co-sub { font-size: 10px; color: var(--gray-500); line-height: 1.6; margin-top: 2px; }
.pdoc-title-block { text-align: center; flex: 1; padding: 0 12px; }
.pdoc-badge {
  display: inline-block; padding: 2px 10px; border-radius: 3px;
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: white; margin-bottom: 4px;
}
.pdoc-title { font-size: 15px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.pdoc-ma { font-size: 10px; color: var(--gray-500); font-family: monospace; margin-top: 3px; }
.pdoc-qr {
  width: 56px; height: 56px; border: 1px solid var(--gray-200);
  border-radius: 4px; display: flex; align-items: center;
  justify-content: center; font-size: 22px; background: var(--gray-100);
  flex-shrink: 0;
}

.pdoc-info {
  border: 1px solid var(--gray-200); border-radius: 5px;
  overflow: hidden; margin-bottom: 12px;
}
.pdoc-info-row {
  display: flex; border-bottom: 1px solid var(--gray-100); min-height: 26px;
}
.pdoc-info-row:last-child { border-bottom: none; }
.pdoc-info-col { display: flex; flex: 1; border-right: 1px solid var(--gray-100); }
.pdoc-info-col:last-child { border-right: none; }
.pdoc-lbl {
  background: #f8fafc; padding: 5px 8px;
  font-size: 10px; font-weight: 600; color: var(--gray-500);
  min-width: 88px; border-right: 1px solid var(--gray-100);
  display: flex; align-items: center;
}
.pdoc-val {
  padding: 5px 8px; font-size: 11px; color: var(--gray-700);
  display: flex; align-items: center; flex: 1; font-weight: 500;
}
.pdoc-val.hl { font-weight: 700; color: var(--navy); }
.pdoc-val.green { color: #059669; font-weight: 700; }

.pdoc-addr {
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 5px; padding: 8px 10px; margin-bottom: 10px;
}
.pdoc-addr-lbl { font-size: 9px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.pdoc-addr-val { font-size: 11px; color: #1e40af; font-weight: 500; }

.pdoc-section-title {
  font-size: 10px; font-weight: 700; color: var(--navy);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-top: 1px solid var(--gray-200); padding-top: 8px;
  margin: 8px 0 6px;
}

table.pdoc-table { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-bottom: 10px; }
.pdoc-table thead tr { background: var(--navy); color: white; }
.pdoc-table th { padding: 6px 7px; text-align: left; font-size: 9.5px; font-weight: 600; }
.pdoc-table th.c, .pdoc-table td.c { text-align: center; }
.pdoc-table th.r, .pdoc-table td.r { text-align: right; }
.pdoc-table tbody tr { border-bottom: 1px solid var(--gray-100); }
.pdoc-table tbody tr:nth-child(even) { background: #fafbfc; }
.pdoc-table tfoot tr { background: #f0f4f8; }
.pdoc-table td { padding: 5px 7px; color: var(--gray-600); }
.pdoc-table tfoot td { font-weight: 700; color: var(--navy); font-size: 11px; padding: 6px 7px; }
.pdoc-code { font-family: monospace; font-size: 10px; color: var(--blue); }
.pdoc-adj { color: #d97706; font-weight: 700; }

.pdoc-bottom { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.pdoc-note {
  flex: 1; background: #fafbfc; border: 1px solid var(--gray-200);
  border-radius: 5px; padding: 8px 10px;
}
.pdoc-note-lbl { font-size: 9px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.pdoc-note-val { font-size: 11px; color: var(--gray-600); line-height: 1.5; }
.pdoc-note2 { background: #eef2ff; border-color: #c7d2fe; }
.pdoc-note2 .pdoc-note-lbl { color: #4338ca; }
.pdoc-note2 .pdoc-note-val { color: #3730a3; }

.pdoc-tong { border: 1px solid var(--gray-200); border-radius: 5px; overflow: hidden; min-width: 220px; }
.pdoc-tong-row { display: flex; border-bottom: 1px solid var(--gray-100); }
.pdoc-tong-row:last-child { border-bottom: none; }
.pdoc-tong-lbl { background: #f8fafc; padding: 5px 10px; font-size: 10px; font-weight: 600; color: var(--gray-500); flex: 1; border-right: 1px solid var(--gray-100); display: flex; align-items: center; }
.pdoc-tong-val { padding: 5px 10px; font-size: 11px; font-weight: 600; color: var(--gray-700); min-width: 100px; text-align: right; display: flex; align-items: center; justify-content: flex-end; }
.pdoc-tong-val.grand { font-size: 13px; font-weight: 700; color: var(--navy); }
.pdoc-tong-row.highlight { background: #f0f9ff; }

.pdoc-sign {
  display: grid; border: 1px solid var(--gray-200); border-radius: 5px; overflow: hidden; margin-bottom: 10px;
}
.pdoc-sign-col { padding: 8px 6px; text-align: center; border-right: 1px solid var(--gray-100); }
.pdoc-sign-col:last-child { border-right: none; }
.pdoc-sign-title { font-size: 10px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.pdoc-sign-sub { font-size: 9px; color: var(--gray-400); margin-bottom: 32px; }
.pdoc-sign-line { border-top: 1px solid var(--gray-200); padding-top: 4px; font-size: 9px; color: var(--gray-400); font-style: italic; }

.pdoc-footer { display: flex; justify-content: space-between; font-size: 9px; color: var(--gray-400); padding-top: 8px; border-top: 1px solid var(--gray-100); }

.pdoc-warn {
  background: #fef9c3; border: 1px solid #fde68a; border-radius: 5px;
  padding: 8px 10px; margin-top: 8px; margin-bottom: 10px;
}
.pdoc-warn-title { font-size: 9px; font-weight: 700; color: #92400e; margin-bottom: 3px; }
.pdoc-warn-text { font-size: 10px; color: #78350f; line-height: 1.5; }

@media print {
  .modal-overlay, #sidebar, #header { display: none !important; }
  .phieu-print-area {
    position: fixed; inset: 0; background: white;
    z-index: 9999; overflow: auto; padding: 20px;
  }
}

/* ===================== Bổ sung GĐ4 (frontend module) ===================== */
.hidden { display: none !important; }
.muted { color: var(--gray-400); font-size: 12px; }
.txt-r { text-align: right; }
.txt-c { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.loading { color: var(--gray-400); font-size: 13px; padding: 16px; }
.err-box { color: #dc2626; font-size: 13px; padding: 12px; background: var(--red-light); border-radius: 8px; }
.warn-box { color: #92400e; font-size: 12px; padding: 10px 12px; background: var(--yellow-light); border: 1px solid #fde68a; border-radius: 8px; }
.ok-box { color: #065f46; font-size: 12px; padding: 10px 12px; background: var(--green-light); border: 1px solid #a7f3d0; border-radius: 8px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--gray-100); color: var(--gray-600); font-size: 11px; margin: 1px 2px; }
.chip-btp { background: #ede9fe; color: #6d28d9; font-weight: 600; }
.bulk-bar { display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: var(--blue-light); border-bottom: 1px solid var(--gray-200); font-size: 13px; flex-wrap: wrap; }
table td.chk, table th.chk { width: 34px; text-align: center; }
tr.expand-row td { background: #f8fafc; padding: 8px 16px 12px 48px; }
tr.clickable { cursor: pointer; }
.sub-table { width: 100%; border: 1px solid var(--gray-200); border-radius: 8px; overflow: hidden; background: white; }
.sub-table th { background: var(--gray-50); font-size: 11px; }
.sub-table td, .sub-table th { padding: 6px 10px; }
.lines-table input, .lines-table select { width: 100%; padding: 6px 8px; border: 1px solid var(--gray-200); border-radius: 6px; font-family: var(--font); font-size: 13px; }
.lines-table td { padding: 4px 6px; vertical-align: top; }
.lines-table .ton-hint { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.modal.modal-lg { max-width: 980px; width: 96%; }
.modal.modal-md { max-width: 640px; width: 96%; }
.modal-body { max-height: calc(100vh - 180px); overflow-y: auto; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--gray-500); }
.tabs.small .tab { padding: 8px 12px; font-size: 13px; }
.stat-card.clickable { cursor: pointer; }
.imp-steps { display: flex; flex-direction: column; gap: 12px; }
.check-list { display: flex; flex-wrap: wrap; gap: 6px 14px; max-height: 160px; overflow-y: auto; padding: 8px; border: 1px solid var(--gray-200); border-radius: 8px; }
.check-list label { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--gray-700); font-weight: 400; }
.table-scroll { overflow-x: auto; }
.num-neg { color: var(--red); font-weight: 600; }
.num-pos { color: #059669; font-weight: 600; }
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span-2 { grid-column: span 1; }
  .kv { grid-template-columns: 110px 1fr; }
  tr.expand-row td { padding-left: 12px; }
}
/* Sơ đồ các bước (hướng dẫn ngắn bằng hình) */
.steps-row { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; }
.step-box { flex: 1 1 140px; display: flex; gap: 8px; align-items: flex-start; padding: 10px; border: 1px solid #e5e7eb; border-radius: 10px; background: var(--white); font-size: 13px; }
.step-num { flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.step-arrow { align-self: center; color: #9ca3af; font-size: 18px; }
@media (max-width: 640px) { .step-arrow { display: none; } .step-box { flex-basis: 100%; } }
/* Trang Hỗ trợ / Báo lỗi */
.ht-luoi { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 14px; align-items: start; }
.ht-ds { max-height: 75vh; overflow: auto; }
.ht-muc { padding: 10px 14px; border-bottom: 1px solid #eef0f3; cursor: pointer; }
.ht-muc:hover { background: #f8fafc; }
.ht-muc.active { background: var(--blue-light); }
.ht-tin-ds { max-height: 55vh; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ht-tin { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.ht-tin.nv { align-self: flex-end; background: var(--blue-light); }
.ht-tin.claude { align-self: flex-start; background: #f1f5f9; border: 1px solid #e2e8f0; }
.ht-tin code { background: #e2e8f0; padding: 0 4px; border-radius: 4px; }
.ht-ai { font-size: 11px; color: #64748b; margin-bottom: 2px; }
.ht-soan { padding: 12px; border-top: 1px solid #eef0f3; }
@media (max-width: 760px) { .ht-luoi { grid-template-columns: 1fr; } .ht-ds { max-height: 40vh; } .ht-tin { max-width: 95%; } }
