/* =========================================================
   KING'S GRILL CONTROL HUB — MASTER DESIGN SYSTEM
   Standardized based on DESIGN.md & ui-ux-redesign-agent
   ========================================================= */

:root {
  /* Surface Scale */
  --surface-0: #090d16; /* Base App Canvas */
  --surface-1: #0f172a; /* Sidebar & Navbars */
  --surface-2: #1e293b; /* Cards, Panels, Modals */
  --surface-3: #334155; /* Hover States, Elevated Elements */
  --surface-subtle: rgba(255, 255, 255, 0.03);

  /* Legacy Aliases */
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-base: #090d16;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-input: #0f172a;

  /* Border Scale */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-focus: #3b82f6;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(37, 99, 235, 0.25);
  --border: rgba(255, 255, 255, 0.08);

  /* Typography Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-main: #f8fafc;
  --text-sub: #64748b;
  --text-dim: #64748b;

  /* Semantic Intent Tokens */
  --brand-primary: #2563eb;
  --brand-primary-hover: #1d4ed8;
  --brand-glow: rgba(37, 99, 235, 0.25);
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;

  --status-success: #10b981;
  --status-success-bg: rgba(16, 185, 129, 0.12);
  --status-success-border: rgba(16, 185, 129, 0.28);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);

  --status-warning: #f59e0b;
  --status-warning-bg: rgba(245, 158, 11, 0.12);
  --status-warning-border: rgba(245, 158, 11, 0.28);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);

  --status-danger: #ef4444;
  --status-danger-bg: rgba(239, 68, 68, 0.12);
  --status-danger-border: rgba(239, 68, 68, 0.28);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);

  --status-info: #0ea5e9;
  --status-info-bg: rgba(14, 165, 233, 0.12);
  --status-info-border: rgba(14, 165, 233, 0.28);
  --info: #0ea5e9;
  --info-bg: rgba(14, 165, 233, 0.12);

  --status-purple: #8b5cf6;
  --status-purple-bg: rgba(139, 92, 246, 0.12);
  --status-purple-border: rgba(139, 92, 246, 0.28);

  /* Radius Scale */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Typography */
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.6);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --surface-0: #f8fafc;
  --surface-1: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --surface-subtle: rgba(0, 0, 0, 0.02);

  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-base: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-glass: rgba(0, 0, 0, 0.02);
  --bg-input: #f8fafc;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.14);
  --border-focus: #2563eb;
  --border-color: rgba(0, 0, 0, 0.08);
  --border: rgba(0, 0, 0, 0.08);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-main: #0f172a;
  --text-sub: #64748b;
  --text-dim: #64748b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 4px 16px -2px rgba(0, 0, 0, 0.06);
}

/* ==================== BASE RESET ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--surface-0);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--surface-0);
}
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-medium);
}

/* ==================== APP LAYOUT ==================== */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ==================== SIDEBAR STYLING ==================== */
.sidebar {
  width: 260px;
  background-color: var(--surface-1);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 4px 6px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 4px 14px var(--brand-glow);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.brand-text h2 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.badge-glow {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(37, 99, 235, 0.3);
  display: inline-block;
  margin-top: 2px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
  width: 100%;
  font-family: inherit;
  user-select: none;
}

.nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px var(--brand-glow);
}

.nav-item i, .nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.badge-active {
  background: var(--status-success-bg);
  color: #34d399;
  border: 1px solid var(--status-success-border);
}

/* VPS Status Footer Card */
.vps-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: auto;
  box-shadow: var(--shadow-sm);
}

.vps-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dot-online {
  width: 8px;
  height: 8px;
  background-color: var(--status-success);
  border-radius: 50%;
  position: relative;
}

.dot-online::after {
  content: '';
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 50%;
  background-color: var(--status-success);
  opacity: 0.6;
  animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

.vps-ip {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.vps-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
  font-size: 11px;
}

.vps-stats small {
  color: var(--text-muted);
  display: block;
}

.vps-stats b {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.text-success { color: var(--status-success) !important; }

/* ==================== MAIN CONTENT AREA ==================== */
.main-content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  max-width: 1600px;
}

/* Header Top Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.page-title p {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
  font-family: inherit;
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px var(--brand-glow);
}
.btn-primary:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

.btn-secondary {
  background: var(--surface-1);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-medium);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: var(--surface-subtle);
  border-color: var(--border-medium);
}

.btn-success {
  background: var(--status-success);
  color: #fff;
}
.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--status-danger-bg);
  border-color: var(--status-danger-border);
  color: #fb7185;
}
.btn-danger:hover {
  background: var(--status-danger);
  border-color: var(--status-danger);
  color: #fff;
}

.btn-icon-only, .btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  position: relative;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon-only:hover, .btn-icon:hover {
  background: var(--surface-3);
  color: #fff;
  border-color: var(--border-medium);
}

.btn-icon-only i, .btn-icon-only svg, .btn-icon i, .btn-icon svg {
  width: 16px;
  height: 16px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* Notification dot */
.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background-color: var(--status-danger);
  border-radius: 50%;
  border: 2px solid var(--surface-1);
}

/* ==================== BENTO STATS CARDS GRID ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-icon.bg-indigo { background: rgba(37, 99, 235, 0.15); color: #60a5fa; border: 1px solid rgba(37, 99, 235, 0.3); }
.stat-icon.bg-emerald { background: var(--status-success-bg); color: #34d399; border: 1px solid var(--status-success-border); }
.stat-icon.bg-purple { background: var(--status-purple-bg); color: #c084fc; border: 1px solid var(--status-purple-border); }
.stat-icon.bg-amber { background: var(--status-warning-bg); color: #fbbf24; border: 1px solid var(--status-warning-border); }
.stat-icon.bg-rose { background: var(--status-danger-bg); color: #fb7185; border: 1px solid var(--status-danger-border); }

.stat-data, .stat-details {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-family);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 2px;
}

/* ==================== TAB VISIBILITY ==================== */
.tab-content {
  display: none;
  animation: fadeIn 0.2s ease-out;
}
.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== DATA TABLES ==================== */
.table-container {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.table-header h3 {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: #0d1527;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
  z-index: 10;
}

.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--surface-subtle);
}

/* Form Controls */
.form-control, input[type="text"], input[type="password"], input[type="date"], select {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

.form-control:focus, input[type="text"]:focus, input[type="password"]:focus, input[type="date"]:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
  background: var(--surface-0);
}

/* ==================== BADGES & TAGS ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.badge-success { background: var(--status-success-bg); color: #34d399; border: 1px solid var(--status-success-border); }
.badge-error, .badge-danger { background: var(--status-danger-bg); color: #fb7185; border: 1px solid var(--status-danger-border); }
.badge-warning { background: var(--status-warning-bg); color: #fbbf24; border: 1px solid var(--status-warning-border); }
.badge-info { background: var(--status-info-bg); color: #38bdf8; border: 1px solid var(--status-info-border); }
.badge-purple { background: var(--status-purple-bg); color: #c084fc; border: 1px solid var(--status-purple-border); }
.badge-neutral { background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

.tag-face { background: var(--status-info-bg); color: #38bdf8; border: 1px solid var(--status-info-border); }
.tag-card { background: var(--status-purple-bg); color: #c084fc; border: 1px solid var(--status-purple-border); }
.tag-in { background: var(--status-success-bg); color: #34d399; border: 1px solid var(--status-success-border); }
.tag-out { background: var(--status-danger-bg); color: #fb7185; border: 1px solid var(--status-danger-border); }

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--surface-3);
  transition: .3s;
  border-radius: 34px;
}
.slider:before {
  position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--brand-primary); }
input:checked + .slider:before { transform: translateX(16px); }

/* ==================== SCHEDULES GRID ==================== */
.schedule-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.schedule-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: var(--transition-fast);
}

.schedule-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.schedule-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.schedule-cron {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-1);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: #60a5fa;
  border: 1px solid var(--border-subtle);
  width: fit-content;
}

/* ==================== ULTRA-COMPACT BENTO CHARTS ==================== */
.charts-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
  align-items: stretch;
}

.chart-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 205px;
  max-height: 205px;
  overflow: hidden;
  box-sizing: border-box;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.chart-card-header h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.chart-canvas-wrap {
  position: relative;
  height: 148px;
  width: 100%;
  flex: 1;
}

.chart-doughnut-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 148px;
  flex: 1;
}

.chart-doughnut-wrap {
  position: relative;
  width: 124px;
  height: 124px;
  flex-shrink: 0;
}

.chart-legend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.45);
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.bg-emerald { background: #10b981; box-shadow: 0 0 6px rgba(16,185,129,0.4); }
.legend-dot.bg-amber { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.legend-dot.bg-rose { background: #f43f5e; box-shadow: 0 0 6px rgba(244,63,94,0.4); }

.legend-label {
  flex: 1;
  font-size: 11px;
}

.legend-val {
  font-family: var(--font-mono, monospace);
  font-size: 11.5px;
  color: var(--text-primary);
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.legend-val small {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
}

@media (max-width: 900px) {
  .charts-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .chart-card {
    height: auto;
    max-height: none;
    min-height: 180px;
  }
}

/* ==================== SETTINGS & CARDS ==================== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}

.settings-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.settings-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-weight: 600;
}

.form-actions, .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.code-block {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #cbd5e1;
  overflow-x: auto;
  line-height: 1.4;
}

/* ==================== CRITICAL: MODAL OVERLAYS FIX ==================== */
.modal-overlay, .modal-backdrop {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: rgba(0, 0, 0, 0.75) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  z-index: 9999 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px;
}

.modal-overlay.active, .modal-overlay.open,
.modal-backdrop.active, .modal-backdrop.open {
  display: flex !important;
}

.modal-container, .modal-box, .modal-card {
  background: var(--surface-2);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: 10000;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-close, .modal-close {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-close:hover, .modal-close:hover {
  color: #fff;
  background: var(--surface-3);
}

/* ==================== PIN LOGIN OVERLAY ==================== */
.pin-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: radial-gradient(circle at center, #111827 0%, #030712 100%) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000 !important;
}

.pin-card {
  background: var(--surface-2);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.pin-logo {
  margin-bottom: 20px;
}

.pin-logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  margin: 0 auto 12px;
  box-shadow: 0 4px 14px var(--brand-glow);
}

.pin-logo h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.pin-logo p {
  font-size: 12px;
  color: var(--text-secondary);
}

.pin-input-row input {
  width: 100%;
  text-align: center;
  font-size: 24px;
  letter-spacing: 10px;
  font-family: var(--font-mono);
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  outline: none;
}

.pin-error {
  color: var(--status-danger);
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 25000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 48px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}

.toast.success { border-left: 4px solid var(--status-success); }
.toast.error { border-left: 4px solid var(--status-danger); }
.toast.info { border-left: 4px solid var(--brand-primary); }

@keyframes toastSlide {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0); }
}

/* Realtime Notification Popup */
.realtime-notif {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 24000;
  background: var(--surface-2);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  animation: toastSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.realtime-notif-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.realtime-notif-icon {
  font-size: 20px;
}

/* ==================== RESPONSIVE MEDIA QUERIES ==================== */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 60;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 35;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: flex;
  }
  .sidebar-overlay.active {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 0; left: -280px; bottom: 0;
    width: 260px;
    transition: left var(--transition-normal);
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .main-content {
    padding: 68px 14px 32px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .top-actions {
    width: 100%;
  }
  .table-container {
    padding: 14px;
    border-radius: var(--radius-md);
  }
}


/* ==================== REFINED COMPACT ATTENDANCE TABLE ==================== */
.table-scroll-container {
  max-height: 540px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.table-scroll-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.table-scroll-container::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.4);
}
.table-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.4);
  border-radius: 4px;
}
.table-scroll-container::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.7);
}

.table-scroll-container table.data-table {
  margin: 0;
  border: none;
}

.table-scroll-container table.data-table thead th {
  position: sticky;
  top: 0;
  background: #090e1a !important;
  backdrop-filter: blur(12px);
  z-index: 10;
  box-shadow: inset 0 -1px 0 var(--border-subtle);
  padding: 10px 14px;
  font-size: 11px;
}

.table-scroll-container table.data-table tbody td {
  padding: 9px 14px;
  font-size: 12.5px;
}

.table-scroll-container table.data-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.65) !important;
}

.pagination-container {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}


/* ==================== EXPORT DROPDOWN MENU ==================== */
.export-dropdown-menu {
  animation: fadeIn 0.15s ease-out;
}

.export-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.export-menu-item:hover {
  background: rgba(59, 130, 246, 0.12);
}
