/* ============================
   SchuFi HR – Stylesheet
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Markenfarben – dieselbe Navy/Gold-Identität wie die gedruckten Dokumente
     (siehe public/js/print/engine.js), damit App und PDFs zusammengehören. */
  --navy: #1a2744;
  --navy-light: #24345c;
  --navy-dark: #101a30;
  --navy-pale: #eef1f8;
  --gold: #b8860b;
  --gold-light: #f5e6c0;
  --gray: #4a4a6a;
  --gray-lt: #8890a4;
  --light: #f8f8fc;
  --border: #d8dce8;

  --primary: var(--navy);
  --primary-dark: var(--navy-dark);
  --primary-light: var(--navy-pale);
  --accent: #16a34a;
  --accent-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --gray-50: #f8f9fc;
  --gray-100: #f1f2f7;
  --gray-200: #e3e5ee;
  --gray-300: #cbcedd;
  --gray-400: #9498ac;
  --gray-500: #6b7086;
  --gray-600: #4b5068;
  --gray-700: #363a4d;
  --gray-800: #1f2233;
  --gray-900: #12141f;
  --sidebar-w: 244px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16,22,44,.06), 0 1px 3px rgba(16,22,44,.08);
  --shadow-md: 0 4px 10px -2px rgba(16,22,44,.1), 0 2px 6px -2px rgba(16,22,44,.06);
  --shadow-lg: 0 16px 32px -8px rgba(16,22,44,.22), 0 6px 12px -4px rgba(16,22,44,.1);
  --ease: cubic-bezier(.2,.7,.3,1);
}

body { font-family: 'Inter', system-ui, sans-serif; font-size: 14px; color: var(--gray-800); background: var(--gray-50); line-height: 1.5; }

/* ---- UTILITIES ---- */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.ml-auto { margin-left: auto; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---- LOGIN ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(184,134,11,.18), transparent 45%),
    linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-light) 100%);
  padding: 20px;
}
.login-box {
  background: white;
  border-radius: 18px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.6);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--gray-900); letter-spacing: -.3px; }
.login-logo p { font-size: 12px; color: var(--gray-500); }
.logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: white;
  font-weight: 800;
  font-size: 18px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: -1px;
  box-shadow: 0 3px 8px rgba(26,39,68,.35), inset 0 1px 0 rgba(255,255,255,.15);
  border-bottom: 2px solid var(--gold);
}
.logo-icon.sm { width: 36px; height: 36px; font-size: 13px; border-radius: 9px; }
.login-hint { text-align: center; margin-top: 16px; color: var(--gray-400); font-size: 12px; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit;
  border-radius: var(--radius-sm);
  transition: transform .12s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: white; box-shadow: 0 1px 2px rgba(26,39,68,.25); }
.btn-primary:hover { background: var(--navy-light); box-shadow: 0 4px 10px rgba(26,39,68,.3); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger); color: white; box-shadow: 0 1px 2px rgba(220,38,38,.25); }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 10px rgba(220,38,38,.3); }
.btn-accent { background: var(--accent); color: white; box-shadow: 0 1px 2px rgba(22,163,74,.25); }
.btn-accent:hover { background: #15803d; box-shadow: 0 4px 10px rgba(22,163,74,.3); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }
.btn-icon { padding: 6px 8px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; letter-spacing: .1px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  background: white;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  outline: none;
}
.form-group input:hover, .form-group select:hover, .form-group textarea:hover { border-color: var(--gray-300); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,39,68,.1);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-full { grid-column: 1 / -1; }
.error-msg { background: var(--danger-light); color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; border: 1px solid #fecaca; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px;
  font-size: 11px; font-weight: 700;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .2px;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ---- SIDEBAR ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(185deg, var(--navy-dark) 0%, var(--navy) 60%, var(--navy-light) 100%);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s var(--ease);
  box-shadow: 2px 0 12px rgba(16,22,44,.12);
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-close-btn { display: none; }
.sidebar-title strong { display: block; font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.sidebar-title span { font-size: 11px; color: rgba(255,255,255,.5); }
.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.62);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background-color .15s var(--ease), color .15s var(--ease);
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active {
  background: rgba(184,134,11,.18);
  color: white;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(184,134,11,.35);
}
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; background: var(--gold); border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex; flex-direction: column; gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--gold), #8c6508);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.user-details .user-name { font-size: 12px; font-weight: 600; color: white; }
.user-details .user-role { font-size: 11px; color: rgba(255,255,255,.55); }

/* ---- MAIN ---- */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
.page { display: none; padding: 28px 32px; animation: page-in .2s var(--ease); }
.page.active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--gray-900); letter-spacing: -.3px; }
.page-header p { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- STATS CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  border-top: 3px solid var(--navy);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label { font-size: 11.5px; color: var(--gray-500); font-weight: 700; text-transform: uppercase; letter-spacing: .6px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--gray-900); margin-top: 4px; line-height: 1; letter-spacing: -.5px; }
.stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.stat-card.accent { border-top-color: var(--gold); }
.stat-card.accent .stat-value { color: var(--navy); }

/* ---- CARD ---- */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  overflow: hidden;
  transition: box-shadow .18s var(--ease);
}
.card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  background: linear-gradient(to bottom, var(--gray-50), white);
}
.card-header h3 { font-size: 14.5px; font-weight: 700; color: var(--gray-800); letter-spacing: -.1px; }
.card-body { padding: 20px; }

/* ---- TABLE ---- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; font-size: 13px; }
th {
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1.5px solid var(--gray-100);
  white-space: nowrap;
}
td { border-bottom: 1px solid var(--gray-50); color: var(--gray-700); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--navy-pale); }
.td-actions { display: flex; gap: 4px; white-space: nowrap; }

/* ---- SEARCH / FILTER BAR ---- */
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px;
  background: white;
  border-bottom: 1px solid var(--gray-100);
}
.filter-bar input, .filter-bar select {
  padding: 7px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: white;
  transition: border-color .15s var(--ease);
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--navy); }
.filter-bar input[type="search"] { min-width: 220px; }

/* ---- SCORE STARS ---- */
.stars { display: flex; gap: 3px; }
.star { font-size: 16px; color: var(--gray-200); }
.star.filled { color: var(--gold); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .7; }
.empty-state p { font-size: 14px; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,22,44,.55);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: overlay-in .15s var(--ease);
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal.modal-lg { max-width: 780px; }
.modal.modal-xl { max-width: 960px; }

/* Nav section label */
.nav-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: rgba(255,255,255,.32);
  padding: 18px 16px 4px; margin-top: 4px;
}

/* Alert warning */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; border: 1px solid transparent; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--navy-pale); color: var(--navy); border-color: #c7d0e8; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* Fehlzeiten alarm card */
.alarm-card {
  background: #fff7ed; border: 1.5px solid #fed7aa; border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
}
.alarm-icon { font-size: 22px; flex-shrink: 0; }
.alarm-body { flex: 1; }
.alarm-name { font-weight: 600; font-size: 13.5px; color: #1a1a2e; }
.alarm-meta { font-size: 12px; color: #92400e; margin-top: 2px; }
.alarm-action { }

/* Color swatch */
.color-swatch { width: 20px; height: 20px; border-radius: 5px; display: inline-block; border: 1px solid rgba(0,0,0,.1); vertical-align: middle; margin-right: 6px; }

/* Dept color indicator in table */
.dept-color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-100);
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-900); letter-spacing: -.2px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 18px; padding: 4px;
  border-radius: var(--radius-sm); transition: all .15s var(--ease);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--gray-700); background: var(--gray-100); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ---- DEPT COLORS ---- */
.dept-gastronomie   { background: #fce7f3; color: #9d174d; }
.dept-helfer        { background: #fef3c7; color: #92400e; }
.dept-eventtechnik  { background: #ede9fe; color: #5b21b6; }
.dept-verwaltung    { background: #dbeafe; color: #1e40af; }
.dept-gruen         { background: #dcfce7; color: #166534; }
.dept-care          { background: #fee2e2; color: #991b1b; }

/* ---- DETAIL VIEW ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-item { }
.detail-label { font-size: 11px; color: var(--gray-500); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.detail-value { font-size: 14px; color: var(--gray-800); }
.detail-section { margin-top: 20px; }
.detail-section h4 { font-size: 13px; font-weight: 700; color: var(--gray-700); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1.5px solid var(--gray-100); }

/* ---- SECTION TABS ---- */
.tabs { display: flex; gap: 4px; background: var(--gray-100); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tab {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; background: transparent;
  color: var(--gray-500);
  transition: all .15s var(--ease);
}
.tab.active { background: white; color: var(--navy); box-shadow: var(--shadow); }

/* ---- TOAST ---- */
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- PRINT STYLES ---- */
@media print {
  .sidebar, .main > *:not(.print-active), .modal-overlay { display: none !important; }
  .print-view { display: block !important; }
  body { background: white; font-size: 12px; }
}
.print-view {
  font-family: 'Times New Roman', serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px;
}
.print-view h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.print-view .subtitle { text-align: center; color: var(--gray-500); font-size: 13px; margin-bottom: 28px; }
.print-view .header-logo { text-align: center; font-size: 11px; color: var(--gray-500); border-bottom: 2px solid #000; padding-bottom: 12px; margin-bottom: 24px; }
.print-view table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.print-view th, .print-view td { padding: 8px 12px; border: 1px solid #999; font-size: 12px; }
.print-view th { background: #f0f0f0; font-weight: bold; }
.print-view .sig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 50px; }
.print-view .sig-line { border-top: 1px solid #000; padding-top: 6px; font-size: 11px; text-align: center; }
.print-view .section-title { font-weight: bold; font-size: 14px; margin: 20px 0 8px; border-bottom: 1px solid #ccc; padding-bottom: 4px; }
.print-view .field-row { display: flex; margin-bottom: 8px; }
.print-view .field-label { width: 180px; font-weight: bold; font-size: 12px; flex-shrink: 0; }
.print-view .field-value { flex: 1; font-size: 12px; border-bottom: 1px dotted #ccc; min-height: 20px; padding-bottom: 2px; }
.print-view .text-box { border: 1px solid #ccc; min-height: 60px; padding: 8px; margin-bottom: 12px; font-size: 12px; }
.print-view .score-row { display: flex; gap: 8px; margin-bottom: 8px; }
.print-view .score-box { width: 30px; height: 30px; border: 2px solid #000; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; }
.print-view .score-box.filled { background: #000; color: white; }

/* ---- DEPT BAR CHART ---- */
.dept-chart { display: flex; flex-direction: column; gap: 8px; }
.dept-bar-row { display: flex; align-items: center; gap: 10px; }
.dept-bar-label { width: 120px; font-size: 12px; color: var(--gray-600); }
.dept-bar-track { flex: 1; background: var(--gray-100); border-radius: 4px; height: 10px; overflow: hidden; }
.dept-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--navy), var(--navy-light)); transition: width .6s var(--ease); }
.dept-bar-count { font-size: 12px; color: var(--gray-500); width: 24px; text-align: right; }

/* ---- AVATAR INITIALS ---- */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

/* ---- PILL LIST ---- */
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--gray-100); color: var(--gray-700); padding: 3px 10px; border-radius: 20px; font-size: 12px; }

/* ============================
   MOBILE / TABLET
   ============================ */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 968px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0; height: 56px;
    padding: 0 12px;
    background: linear-gradient(135deg, var(--navy-dark), var(--navy)); color: white;
    z-index: 90;
    box-shadow: var(--shadow-md);
  }
  .sidebar-toggle-btn {
    background: none; border: none; color: white;
    font-size: 22px; line-height: 1; padding: 8px;
    cursor: pointer; border-radius: var(--radius-sm);
  }
  .sidebar-toggle-btn:hover { background: rgba(255,255,255,.1); }
  .mobile-topbar strong { font-size: 14px; font-weight: 700; }

  .sidebar-close-btn {
    display: block; margin-left: auto;
    background: none; border: none; color: rgba(255,255,255,.6);
    font-size: 18px; padding: 6px; cursor: pointer; border-radius: var(--radius-sm);
  }
  .sidebar-close-btn:hover { background: rgba(255,255,255,.1); color: white; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    width: min(280px, 84vw);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(16,22,44,.55);
    z-index: 99;
    opacity: 0; pointer-events: none;
    transition: opacity .2s var(--ease);
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  .main { margin-left: 0; padding-top: 56px; }
  .page { padding: 20px 16px; }

  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page { padding: 16px 12px; }
  .page-header h2 { font-size: 19px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }

  .login-box { padding: 28px 22px; }
  .login-logo h1 { font-size: 20px; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }

  .filter-bar { padding: 10px 12px; }
  .filter-bar input[type="search"] { min-width: 0; flex: 1 1 160px; }

  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }

  .alarm-card { flex-wrap: wrap; }
}
