/* ==========================================================================
   SafeExit AI - Design System & Modern CSS Stylesheet
   ========================================================================== */

/* 1. CSS Custom Variables & Root Tokens */
:root {
  --bg-dark: #090d16;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 53, 0.85);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);
  
  --accent-purple: #a855f7;
  --accent-cyan: #06b6d4;
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.3);
  
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);

  --font-family: 'Outfit', 'Plus Jakarta Sans', -apple-system, sans-serif;
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Global Resets & Base Setup */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(168, 85, 247, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.05) 0%, transparent 60%);
  background-attachment: fixed;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Screen reader utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Loading Placeholder */
.loading-placeholder {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* 3. Header Styling */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  padding: 1rem 1.5rem;
}

.header-container {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  color: #fff;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-text h1 span {
  background: linear-gradient(135deg, #a855f7 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.825rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-standby {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}
.status-standby .status-dot { background: var(--text-dim); }

.status-active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--success);
}
.status-active .status-dot {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
  animation: pulseDot 1.5s infinite;
}

.status-alarm {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
  animation: headShake 0.5s ease-in-out;
}
.status-alarm .status-dot {
  background: var(--danger);
  box-shadow: 0 0 12px var(--danger);
  animation: pulseDot 0.6s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.2); }
}

/* 4. Layout Grid */
.main-container {
  max-width: 1320px;
  margin: 1.5rem auto;
  padding: 0 1.5rem 3rem 1.5rem;
}

.grid-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
}

@media (max-width: 992px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

/* 5. Card Component Styles */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-normal);
}

.card:hover {
  border-color: var(--border-glow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.card-header h2 i {
  color: var(--primary);
}

/* Badges */
.badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-wallet {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

.icon-phone {
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
}

.icon-book {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
}

.badge-tech {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* 6. Webcam & AI Scanner Frame */
.webcam-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #04060a;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

#webcam, #canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Scanner Frame Overlay */
.scanner-frame {
  position: absolute;
  inset: 20px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.webcam-wrapper.active .scanner-frame {
  opacity: 1;
}

.corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--primary);
  border-style: solid;
}

.corner-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-top-left-radius: 4px; }
.corner-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-top-right-radius: 4px; }
.corner-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-bottom-left-radius: 4px; }
.corner-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-bottom-right-radius: 4px; }

.scanner-line {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%);
  box-shadow: 0 0 12px var(--primary);
  opacity: 0;
}

.webcam-wrapper.active .scanner-line {
  opacity: 1;
  animation: scanAnim 2.5s ease-in-out infinite alternate;
}

@keyframes scanAnim {
  0% { top: 0%; }
  100% { top: 98%; }
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: rgba(11, 16, 26, 0.95);
  z-index: 2;
  transition: opacity 0.3s ease;
}

.webcam-wrapper.active .camera-placeholder {
  opacity: 0;
  pointer-events: none;
}

.placeholder-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.camera-placeholder h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.camera-placeholder p {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 300px;
}

.camera-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* 7. Prediction Bars & Confidence Display */
.detection-results {
  margin-top: 1.5rem;
  background: rgba(10, 14, 23, 0.5);
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.detection-results h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.prediction-bars {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.prediction-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.bar-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  font-weight: 600;
}

.item-name i {
  margin-right: 0.4rem;
  color: var(--primary);
}

.item-percentage {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.15s ease-out;
}

.fill-book {
  background: linear-gradient(90deg, #8b5cf6 0%, #d8b4fe 100%);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.fill-wallet {
  background: linear-gradient(90deg, #6366f1 0%, #a855f7 100%);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.fill-phone {
  background: linear-gradient(90deg, #06b6d4 0%, #3b82f6 100%);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

.fill-key {
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.fill-laptop {
  background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* 8. Checklist Column & Items */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.items-checklist {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(10, 15, 26, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  transition: var(--transition-normal);
}

.checklist-item.detected {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.1);
}

.checklist-item.missing-alert {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
  animation: headShake 0.6s ease-in-out;
}

.item-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.item-details {
  flex-grow: 1;
}

.item-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.item-title-row h3 {
  font-size: 1rem;
  font-weight: 700;
}

.status-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  transition: var(--transition-fast);
}

.pill-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.pill-success {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.pill-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.item-meta {
  font-size: 0.725rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.btn-reset-item {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.btn-reset-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

/* Select Input */
.select-input {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.select-input:focus {
  border-color: var(--primary);
}

/* 9. Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.1);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-accent {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 15px var(--success-glow);
}
.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px var(--success-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 15px var(--danger-glow);
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px var(--danger-glow);
}

.btn-outline-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-outline-secondary {
  background: transparent;
  border-color: var(--border-light);
  color: var(--text-muted);
}
.btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 0.9rem 1.5rem;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--primary);
}

.btn-icon-only {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-text:hover {
  color: var(--danger);
}

/* 10. Alarm Controls Grid */
.alarm-controls-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.switch-group {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

/* Custom Range Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Custom Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 999px;
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider-toggle {
  background-color: var(--primary);
}

input:checked + .slider-toggle:before {
  transform: translateX(20px);
}

.alarm-action-buttons {
  display: flex;
  gap: 0.75rem;
}
.alarm-action-buttons .btn {
  flex: 1;
}

/* 11. Activity Log Section */
.log-card {
  max-height: 280px;
  display: flex;
  flex-direction: column;
}

.log-container {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.35rem;
  max-height: 180px;
}

.log-container::-webkit-scrollbar {
  width: 5px;
}
.log-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
.log-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.log-entry {
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(10, 14, 23, 0.6);
  border-left: 3px solid var(--border-light);
  line-height: 1.4;
}

.log-time {
  font-weight: 700;
  color: var(--text-dim);
  margin-right: 0.35rem;
}

.log-info { border-left-color: var(--primary); }
.log-success { border-left-color: var(--success); background: rgba(16, 185, 129, 0.08); }
.log-warning { border-left-color: var(--warning); background: rgba(245, 158, 11, 0.08); }
.log-danger { border-left-color: var(--danger); background: rgba(239, 68, 68, 0.12); color: #fca5a5; }

/* 12. Fullscreen Alarm Strobe Overlay */
.alarm-strobe-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(220, 38, 38, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: strobeFlash 0.5s infinite alternate;
}

.alarm-strobe-overlay.hidden {
  display: none !important;
}

@keyframes strobeFlash {
  0% { background-color: rgba(239, 68, 68, 0.96); }
  100% { background-color: rgba(153, 27, 27, 0.96); }
}

.strobe-content {
  text-align: center;
  color: #ffffff;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.strobe-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 0.6s infinite alternate;
}

.strobe-content h2 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

.strobe-content p {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  opacity: 0.95;
}

@keyframes bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-15px); }
}

/* 13. Settings Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.btn-close:hover { color: #fff; }

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.text-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
}
.text-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.slider-with-val {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.label-inline {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
}

/* 14. Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-light);
}

/* Keyframes shake for alarm warning */
@keyframes headShake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-1deg); }
  40% { transform: translateX(5px) rotate(1deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
  100% { transform: translateX(0); }
}
