:root {
  --primary: #0a1628;
  --secondary: #132244;
  --accent: #d4a843;
  --accent-dark: #b8912e;
  --accent-light: #e8c96a;
  --bg: #f0f4f8;
  --bg-card: #ffffff;
  --bg-card-light: #1a2a4a;
  --bg-secondary: #e8edf4;
  --text: #ffffff;
  --text-dark: #0a1628;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: rgba(255,255,255,0.1);
  --success: #059669;
  --success-bg: rgba(5,150,105,0.12);
  --warning: #d97706;
  --error: #dc2626;
  --info: #2563eb;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 24px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.18);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w: 260px;
}
[data-theme="dark"] {
  --primary: #f1f5f9;
  --secondary: #0f172a;
  --bg: #0a0f1a;
  --bg-card: #111927;
  --bg-card-light: #1a2a4a;
  --bg-secondary: #0f172a;
  --text: #f1f5f9;
  --text-dark: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255,255,255,0.08);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text-dark);
  line-height: 1.6; -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
ul { list-style: none; }
::selection { background: var(--accent); color: var(--primary); }

.admin-container { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, #0a1628 0%, #132244 100%);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; transition: transform 0.3s ease; overflow-y: auto;
}
.sidebar-header {
  padding: 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-badge { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); background: rgba(212,168,67,0.12); padding: 3px 10px; border-radius: 50px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { margin-bottom: 8px; }
.nav-section-title { display: block; padding: 8px 20px 4px; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); opacity: 0.6; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px; margin: 2px 8px;
  color: var(--text-muted); font-size: 0.85rem; font-weight: 500; border-radius: 8px;
  transition: var(--transition); cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.nav-item.active { background: rgba(212,168,67,0.12); color: var(--accent); }
.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; }
.nav-badge {
  margin-left: auto; font-size: 0.65rem; font-weight: 700; padding: 2px 8px;
  border-radius: 50px; background: rgba(255,255,255,0.08);
}
.nav-badge.warning { background: rgba(217,119,6,0.2); color: var(--warning); }
.nav-badge.danger { background: rgba(220,38,38,0.2); color: var(--error); }
.nav-badge.info { background: rgba(37,99,235,0.2); color: var(--info); }
.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 12px;
}
.admin-profile { display: flex; align-items: center; gap: 10px; flex: 1; }
.admin-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  color: var(--primary); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
}
.admin-info { line-height: 1.3; }
.admin-name { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); }
.admin-role { font-size: 0.7rem; color: var(--text-muted); }
.btn-logout { color: var(--text-muted); font-size: 1rem; transition: var(--transition); padding: 8px; }
.btn-logout:hover { color: var(--error); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 99; background: rgba(0,0,0,0.4); }

.main-content {
  flex: 1; margin-left: var(--sidebar-w); min-height: 100vh;
  display: flex; flex-direction: column;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50; gap: 16px;
}
[data-theme="dark"] .topbar { background: var(--bg-card); }
.topbar-left { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.2rem; color: var(--text-dark); cursor: pointer; padding: 4px; }
.page-title h2 { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.page-title span { font-size: 0.75rem; color: var(--text-secondary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-bar {
  position: relative; display: flex; align-items: center;
}
.search-bar i { position: absolute; left: 12px; color: var(--text-muted); font-size: 0.85rem; }
.search-bar input {
  padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.82rem; font-family: var(--font); width: 240px;
  background: var(--bg); color: var(--text-dark); transition: var(--transition);
}
[data-theme="dark"] .search-bar input { background: rgba(255,255,255,0.05); color: var(--text); }
.search-bar input:focus { outline: none; border-color: var(--accent); width: 300px; }
.search-suggestions {
  position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 4px;
  box-shadow: var(--shadow-lg); display: none; z-index: 60; max-height: 300px; overflow-y: auto;
}
.search-suggestions.show { display: block; }
.search-suggestions .suggestion-item { padding: 10px 14px; cursor: pointer; font-size: 0.82rem; border-bottom: 1px solid var(--border); }
.search-suggestions .suggestion-item:hover { background: var(--bg); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; font-family: var(--font); font-size: 0.82rem; font-weight: 600; border-radius: var(--radius-sm); border: none; cursor: pointer; transition: var(--transition); }
.btn-primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%); color: var(--primary); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(212,168,67,0.3); }
.btn-outline { background: transparent; color: var(--accent-dark); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: rgba(212,168,67,0.08); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-sm { padding: 6px 14px; font-size: 0.78rem; }
.btn-block { width: 100%; justify-content: center; }

.page-content { padding: 24px 32px; flex: 1; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
  display: flex; align-items: center; gap: 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px;
  transition: var(--transition);
}
[data-theme="dark"] .stat-card { background: var(--bg-card); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 14px; display: flex;
  align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.blue { background: rgba(37,99,235,0.1); color: #2563eb; }
.stat-icon.green { background: rgba(5,150,105,0.1); color: #059669; }
.stat-icon.gold { background: rgba(212,168,67,0.1); color: var(--accent-dark); }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.stat-info { flex: 1; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); }
.stat-change { font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 50px; }
.stat-change.up { background: rgba(5,150,105,0.1); color: var(--success); }
.stat-change.down { background: rgba(220,38,38,0.1); color: var(--error); }

.dashboard-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-bottom: 24px; }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 20px; transition: var(--transition);
}
[data-theme="dark"] .card { background: var(--bg-card); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--primary); }
.card-action { font-size: 0.78rem; color: var(--accent-dark); cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 4px; }
.card-action:hover { gap: 8px; }
.card-body { padding: 20px 24px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-secondary); padding: 10px 12px;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 10px 12px; font-size: 0.82rem; color: var(--primary); border-bottom: 1px solid var(--border); }
[data-theme="dark"] .data-table td { color: var(--text); }
.data-table tr:hover td { background: rgba(212,168,67,0.03); }
.table-responsive { overflow-x: auto; }

.badge { font-size: 0.65rem; font-weight: 700; padding: 3px 10px; border-radius: 50px; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-success { background: rgba(5,150,105,0.1); color: var(--success); }
.badge-warning { background: rgba(217,119,6,0.1); color: var(--warning); }
.badge-danger { background: rgba(220,38,38,0.1); color: var(--error); }
.badge-info { background: rgba(37,99,235,0.1); color: var(--info); }
.badge-neutral { background: rgba(100,116,139,0.1); color: var(--text-secondary); }

.page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 12px; }
.filter-group { display: flex; gap: 8px; }
.form-select, .form-input {
  padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.82rem; font-family: var(--font); background: var(--bg-card); color: var(--text-dark);
  cursor: pointer; transition: var(--transition);
}
[data-theme="dark"] .form-select, [data-theme="dark"] .form-input { background: rgba(255,255,255,0.06); color: var(--text); border-color: rgba(255,255,255,0.12); }
.form-select:focus, .form-input:focus { outline: none; border-color: var(--accent); }
.toolbar-info { font-size: 0.82rem; color: var(--text-secondary); }

.chart-container { height: 280px; position: relative; }
.chart-tabs { display: flex; gap: 4px; }
.chart-tab {
  padding: 4px 12px; font-size: 0.75rem; font-weight: 600; border: 1px solid var(--border);
  border-radius: 6px; background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: var(--transition); font-family: var(--font);
}
.chart-tab.active { background: var(--accent); color: var(--primary); border-color: var(--accent); }
.chart-tab:hover:not(.active) { background: var(--bg); }

.batch-toolbar {
  display: none; align-items: center; gap: 12px; padding: 12px 20px;
  background: var(--bg-card); border: 1px solid var(--accent); border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.batch-toolbar.show { display: flex; }
.batch-toolbar span { font-size: 0.82rem; color: var(--text-secondary); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9999;
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); padding: 24px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card); border-radius: var(--radius-lg); width: 100%;
  max-width: 500px; position: relative; box-shadow: var(--shadow-xl);
  max-height: 90vh; overflow-y: auto;
}
[data-theme="dark"] .modal { background: #111927; }
.modal.modal-lg { max-width: 640px; }
.modal-header {
  padding: 24px 28px 16px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.1rem; color: var(--text-secondary); cursor: pointer; padding: 4px; transition: var(--transition); }
.modal-close:hover { color: var(--error); transform: rotate(90deg); }
.modal-body { padding: 24px 28px; }
.modal-body .detail-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.modal-body .detail-row:last-child { border: none; }
.modal-body .detail-label { color: var(--text-secondary); }
.modal-body .detail-value { font-weight: 600; color: var(--primary); text-align: right; }
[data-theme="dark"] .modal-body .detail-value { color: var(--text); }
.modal-footer {
  padding: 16px 28px 24px; display: flex; gap: 12px; justify-content: flex-end;
  border-top: 1px solid var(--border);
}

.notif-panel {
  position: fixed; top: 0; right: -360px; width: 340px; height: 100vh;
  background: var(--bg-card); border-left: 1px solid var(--border);
  z-index: 90; transition: right 0.3s ease; display: flex; flex-direction: column;
}
.notif-panel.open { right: 0; }
.notif-header {
  padding: 20px; display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid var(--border);
}
.notif-header h4 { font-size: 0.95rem; font-weight: 700; color: var(--primary); }
.notif-list { flex: 1; overflow-y: auto; padding: 12px; }
.notif-item {
  padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  margin-bottom: 8px; cursor: pointer; transition: var(--transition);
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item .notif-title { font-size: 0.85rem; font-weight: 600; color: var(--primary); }
.notif-item .notif-desc { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.notif-item .notif-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

.notification-btn { position: relative; background: none; border: none; font-size: 1.1rem; color: var(--text-secondary); cursor: pointer; padding: 8px; }
.notif-dot {
  position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--error);
}

.toggle-field { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
.toggle-field span { font-size: 0.85rem; color: var(--primary); }
.toggle-field input[type="checkbox"] { display: none; }
.toggle-slider {
  width: 40px; height: 22px; background: var(--border); border-radius: 11px;
  display: inline-block; position: relative; cursor: pointer; transition: var(--transition);
}
.toggle-slider::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: white; border-radius: 50%; transition: var(--transition);
}
.toggle-field input:checked + .toggle-slider { background: var(--accent); }
.toggle-field input:checked + .toggle-slider::after { left: 20px; }
.settings-body { max-width: 600px; }
.settings-group { margin-bottom: 24px; }
.settings-group h4 { font-size: 0.82rem; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.settings-grid { display: grid; gap: 8px; }

.branches-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.branch-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; transition: var(--transition);
}
.branch-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.branch-card h4 { font-size: 0.95rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.branch-card p { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 4px; }
.branch-card .branch-status { display: inline-block; margin-top: 8px; }

.cms-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.cms-fields { display: flex; flex-direction: column; gap: 12px; }
.cms-field label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.cms-field input, .cms-field textarea { width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 0.82rem; font-family: var(--font); background: var(--bg); color: var(--text-dark); transition: var(--transition); }
[data-theme="dark"] .cms-field input, [data-theme="dark"] .cms-field textarea { background: rgba(255,255,255,0.06); color: var(--text); }
.cms-field input:focus, .cms-field textarea:focus { outline: none; border-color: var(--accent); }

.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 32px;
  text-align: center; cursor: pointer; transition: var(--transition);
  background: var(--bg);
}
[data-theme="dark"] .upload-zone { background: rgba(255,255,255,0.03); }
.upload-zone:hover { border-color: var(--accent); background: rgba(212,168,67,0.04); }
.upload-zone i { font-size: 2rem; color: var(--accent-dark); margin-bottom: 12px; }
.upload-zone p { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 4px; }
.upload-zone small { font-size: 0.75rem; color: var(--text-muted); }
.upload-preview { margin-top: 12px; }
.upload-preview .file-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: rgba(5,150,105,0.08); border-radius: var(--radius-sm);
  font-size: 0.82rem; color: var(--success);
}

.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.staff-card {
  display: flex; align-items: center; gap: 16px; padding: 16px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: var(--transition);
}
.staff-card:hover { box-shadow: var(--shadow-md); }
.staff-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; background: rgba(212,168,67,0.12); color: var(--accent-dark); }

.application-item {
  display: flex; align-items: center; gap: 16px; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px;
  transition: var(--transition); cursor: pointer;
}
[data-theme="dark"] .application-item { border-color: rgba(255,255,255,0.08); }
.application-item:hover { background: var(--bg); }
.application-item .app-icon {
  width: 44px; height: 44px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 1.1rem;
  background: rgba(212,168,67,0.1); color: var(--accent-dark);
}
.application-item .app-info { flex: 1; }
.application-item .app-info h4 { font-size: 0.88rem; font-weight: 600; color: var(--primary); }
.application-item .app-info p { font-size: 0.78rem; color: var(--text-secondary); }
.application-item .app-status { font-size: 0.72rem; }

.empty-state { text-align: center; padding: 40px 20px; }
.empty-state i { font-size: 2.5rem; color: var(--text-muted); margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; color: var(--primary); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; color: var(--text-secondary); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .branches-grid { grid-template-columns: repeat(2, 1fr); }
  .cms-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: none; }
  .sidebar-toggle { display: block; }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .search-bar input { width: 140px; }
  .search-bar input:focus { width: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .branches-grid { grid-template-columns: 1fr; }
  .topbar-right { flex-wrap: wrap; }
  .page-toolbar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 1.2rem; }
}
