:root {
  --bg-primary: #0a0f1e;
  --bg-secondary: #111827;
  --bg-card: #1a2236;
  --bg-hover: #1e2d45;
  --border: #2a3a55;
  --border-light: #334466;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --accent-glow: rgba(14, 165, 233, 0.15);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #8b5cf6;
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

html {
  font-size: 14px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.sidebar-logo .logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-logo .logo-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
  font-size: 0.875rem;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item .nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

.sidebar-logout:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ---- SIDEBAR BRAND (header area) ---- */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ---- SIDEBAR USER (footer area) ---- */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ---- MAIN WRAPPER — pushes content past the fixed sidebar ---- */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}

/* ---- MAIN ---- */
.main-content {
  flex: 1;
  padding: 24px 28px;
  overflow-x: hidden;
  min-width: 0;
  width: 100%;
  max-width: 1500px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.topbar {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  text-decoration: none;
  transition: all var(--transition);
}

.topbar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.topbar-btn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--kpi-color, var(--accent));
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--kpi-color-bg, var(--accent-glow));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 14px;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-trend {
  font-size: 0.75rem;
  margin-top: 8px;
}

.kpi-trend.up {
  color: var(--success);
}

.kpi-trend.down {
  color: var(--danger);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.875rem;
}

tbody tr:hover td {
  background: var(--bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

td .text-muted {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="email"],
input[type="password"],
select,
textarea {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  appearance: none;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.form-error {
  font-size: 0.72rem;
  color: var(--danger);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  filter: brightness(1.1);
}

.btn-warning {
  background: var(--warning);
  color: #000;
}

.btn-warning:hover {
  filter: brightness(1.1);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

.btn-icon {
  padding: 8px;
  width: 34px;
  height: 34px;
}

/* ============================================================
   ALERTS & BADGES
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.alert-info {
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.3);
  color: #7dd3fc;
}

/* ============================================================
   WORKFLOW STEPS
   ============================================================ */
.workflow-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 28px;
  overflow-x: auto;
}

.step-item {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.step-item.done:not(:last-child)::after {
  background: var(--success);
}

.step-item.active:not(:last-child)::after {
  background: var(--border);
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
  transition: all var(--transition);
}

.step-item.done .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.step-item.active .step-circle {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.step-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  line-height: 1.3;
  max-width: 100px;
}

.step-item.active .step-label {
  color: var(--accent);
  font-weight: 600;
}

.step-item.done .step-label {
  color: var(--success);
}

/* ============================================================
   MISC
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.text-muted {
  color: var(--text-muted);
}

.text-accent {
  color: var(--accent);
}

.text-sm {
  font-size: 0.8rem;
}

.text-xs {
  font-size: 0.72rem;
}

.fw-bold {
  font-weight: 700;
}

.fw-600 {
  font-weight: 600;
}

.mt-4 {
  margin-top: 16px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Mớn nước grid */
.mn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 420px;
}

.mn-input-wrap {
  position: relative;
}

.mn-label {
  position: absolute;
  top: -9px;
  left: 10px;
  background: var(--bg-card);
  padding: 0 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.tl-item {
  position: relative;
  margin-bottom: 20px;
}

.tl-dot {
  position: absolute;
  left: -28px;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-card);
  z-index: 1;
}

.tl-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.tl-content {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top left, rgba(14, 165, 233, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(124, 58, 237, 0.1) 0%, transparent 60%),
    var(--bg-primary);
}

.login-card {
  width: 420px;
  max-width: 95vw;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  color: #fff;
}

.login-logo-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ============================================================
   SIDEBAR BRAND (header.php uses .sidebar-brand, .brand-*)
   ============================================================ */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ============================================================
   SIDEBAR USER PANEL
   ============================================================ */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}


/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {

  .sidebar,
  .topbar,
  .btn,
  .no-print {
    display: none !important;
  }

  .main-wrapper {
    margin-left: 0 !important;
  }

  .main-content {
    padding: 0 !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12px;
  }

  .card {
    border: 1px solid #ccc;
    box-shadow: none;
    background: #fff;
  }

  thead th {
    background: #f5f5f5;
    color: #333;
  }

  tbody td {
    color: #000;
    border-color: #ddd;
  }

  .text-muted {
    color: #666 !important;
  }

  .text-accent,
  .text-success,
  .text-danger,
  .text-warning {
    color: #000 !important;
  }

  table {
    page-break-inside: auto;
  }

  tr {
    page-break-inside: avoid;
  }
}

/* ============================================================
   COLLAPSIBLE SIDEBAR
   ============================================================ */
.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar.collapsed+.main-wrapper {
  margin-left: 0;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* ============================================================
   STAT MINI ROW
   ============================================================ */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
}

.stat-val {
  font-size: .9rem;
  font-weight: 700;
}

/* ============================================================
   RESPONSIVE MOBILE — Breakpoint 768px
   ============================================================ */

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
  display: block;
}

/* Bottom mobile nav bar */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 98;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}

.mobile-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 12px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  border-radius: 8px;
  transition: color var(--transition);
  min-width: 52px;
}

.mobile-nav-item .mn-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.mobile-nav-item.active {
  color: var(--accent);
}

.mobile-nav-item.active .mn-icon {
  filter: drop-shadow(0 0 6px var(--accent));
}

@media (max-width: 768px) {

  /* ----- SIDEBAR: hidden off-screen by default ----- */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    width: min(280px, 85vw);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Remove desktop collapsed state on mobile */
  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  /* ----- MAIN WRAPPER: no left margin on mobile ----- */
  .main-wrapper {
    margin-left: 0 !important;
  }

  /* ----- TOPBAR ----- */
  .topbar {
    padding: 0 14px;
    height: 56px;
  }

  .topbar-title {
    font-size: 0.92rem;
  }

  /* ----- MAIN CONTENT padding ----- */
  .main-content {
    padding: 16px 14px;
    padding-bottom: 80px;
    /* room for bottom nav */
  }

  /* ----- BOTTOM NAV visible ----- */
  .mobile-nav {
    display: block;
  }

  /* ----- KPI GRIDS: 2 columns on tablet ----- */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* ----- CARD GRID: 1 column ----- */
  .card-grid {
    grid-template-columns: 1fr;
  }

  /* ----- TABLES: horizontal scroll ----- */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }

  .table-wrap table {
    min-width: 560px;
  }

  /* ----- FORMS: full width ----- */
  .form-row {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
    gap: 8px;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* ----- PAGE HEADER ----- */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .page-header .btn {
    align-self: stretch;
    justify-content: center;
  }

  /* ----- MODAL ----- */
  .modal-box {
    width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* ----- STATS CARDS: full width ----- */
  .stat-cards {
    grid-template-columns: 1fr;
  }

  /* ----- FILTERS: wrap ----- */
  .filter-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filter-bar select,
  .filter-bar input {
    min-width: 140px;
    flex: 1;
  }

  /* ----- DASHBOARD GRID: stack ----- */
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 13px;
  }

  /* Single column KPI on phone */
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi-card {
    padding: 14px 16px;
  }

  .kpi-value {
    font-size: 1.6rem;
  }

  /* Cards padding tighter */
  .card {
    padding: 14px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* Buttons full-width rows */
  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
  }

  /* Table font smaller */
  .table-wrap table {
    font-size: 0.78rem;
  }

  .table-wrap th,
  .table-wrap td {
    padding: 8px 10px;
  }

  /* Hide less-critical columns on phone via utility class */
  .col-hide-sm {
    display: none;
  }

  /* Topbar: hide date text */
  .topbar-date {
    display: none;
  }

  /* Page header title smaller */
  .page-header h1,
  .page-header .page-title {
    font-size: 1rem;
  }

  /* Modal full-screen on phone */
  .modal-box {
    width: 100%;
    min-height: 100%;
    border-radius: 0;
    margin: 0;
    max-height: 100vh;
  }

  .modal {
    align-items: flex-end;
  }
}

/* Hamburger button: show on mobile, hide on desktop */
#sidebarToggle {
  display: flex;
}

@media (min-width: 769px) {
  #sidebarToggle {
    display: none;
  }
}

/* ========= UI FIX v2: High contrast sidebar ========= */
:root {
  --text-secondary: #e2e8f0 !important;
  --text-muted: #b0bec5 !important;
}

/* Section titles (DANH MỤC, ĐIỀU PHỐI, etc) */
.nav-section-title {
  color: #90a4ae !important;
  font-weight: 700 !important;
}

/* Menu items - bright white */
.nav-item {
  color: #e8eaed !important;
  font-weight: 500 !important;
}
.nav-item:hover {
  color: #ffffff !important;
  background: var(--bg-hover) !important;
}
.nav-item.active {
  color: var(--accent) !important;
  font-weight: 600 !important;
}

/* User name in sidebar footer */
.sidebar-user .user-name,
.user-name {
  color: #ffffff !important;
}
.sidebar-user .user-role,
.user-role {
  color: #b0bec5 !important;
}

/* Profile & Logout buttons - WHITE icons */
.sidebar-action-btn {
  color: #ffffff !important;
  background: rgba(255,255,255,0.1) !important;
  border: 1px solid rgba(255,255,255,0.25) !important;
}
.sidebar-action-btn:hover {
  background: rgba(14,165,233,0.25) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
.sidebar-action-btn.logout-btn:hover {
  background: rgba(239,68,68,0.25) !important;
  border-color: var(--danger) !important;
  color: #ff6b6b !important;
}

/* Also fix btn-ghost btn-icon used as fallback */
.sidebar-user .btn-ghost.btn-icon {
  color: #ffffff !important;
  background: rgba(255,255,255,0.1) !important;
  border: 1px solid rgba(255,255,255,0.25) !important;
}
.sidebar-user .btn-ghost.btn-icon:hover {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

/* Form labels */
label {
  color: #e2e8f0 !important;
}

/* Table headers */
thead th {
  color: #b0bec5 !important;
}

/* KPI labels */
.kpi-label {
  color: #b0bec5 !important;
}

/* Card subtitle */
.card-subtitle {
  color: #b0bec5 !important;
}

/* Brand sub text */
.brand-sub {
  color: #90a4ae !important;
}
