/* ==========================================================================
   臺中消防即時災情推播系統 - Cyber Emergency Dark Theme
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(239, 68, 68, 0.25);

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.35);
  --accent-orange: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.3);
  --accent-green: #10b981;
  --accent-cyan: #06b6d4;

  --font-main: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Chakra Petch', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px -5px var(--accent-red-glow);
}

/* Base Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 17px;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Background Cyber Atmosphere */
.cyber-bg-glow {
  position: fixed;
  top: -15vw;
  left: 20vw;
  width: 60vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.12) 0%, rgba(59, 130, 246, 0.05) 50%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  filter: blur(80px);
}

.cyber-grid {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

/* Main Container */
.app-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
  position: relative;
  z-index: 1;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
  background: rgba(17, 24, 39, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-badge {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.app-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.pulse-ring {
  position: absolute;
  inset: -4px;
  border: 2px solid var(--accent-red);
  border-radius: 16px;
  opacity: 0.6;
  animation: pulse-border 2.5s infinite;
}

@keyframes pulse-border {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.08); opacity: 0.2; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.title-group {
  display: flex;
  flex-direction: column;
}

.title-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.15rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
  animation: blink 1.2s infinite ease-in-out;
}

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.7); }
}

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

.main-title {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 30%, #fca5a5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.title-desktop {
  display: inline;
}

.title-mobile {
  display: none;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-install {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-push {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  position: relative;
}

.btn-push:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-push.subscribed {
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.push-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-dim);
}

.btn-push.subscribed .push-status-dot {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.btn-accent {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
}

.btn-accent:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
}

/* Alert Banner */
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(17, 24, 39, 0.8));
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  backdrop-filter: blur(8px);
}

.alert-content {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.alert-icon {
  font-size: 1.4rem;
  color: var(--accent-red);
}

.alert-text {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
}

.alert-text strong {
  font-size: 0.92rem;
  color: #fff;
}

.alert-text span {
  color: var(--text-muted);
}

/* Stats KPI & Filter Cards (2-in-1 互動統計按鈕) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(30, 41, 59, 0.9);
}

.stat-card:active {
  transform: scale(0.97);
}

.stat-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  flex-shrink: 0;
  transition: all 0.2s;
}

.stat-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.stat-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}

.stat-label {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.stat-filter-badge {
  display: none;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.2px;
}

.stat-card.active .stat-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.15;
}

/* Card Themes & Active States */

/* 1. 雙軌重症 (Amber/Yellow) */
.stat-dual {
  border-color: rgba(245, 158, 11, 0.25);
}
.stat-dual .stat-icon-wrap {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
}
.stat-dual.active {
  border-color: #fbbf24;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(20, 24, 38, 0.95));
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3), inset 0 0 12px rgba(245, 158, 11, 0.1);
}
.stat-dual.active .stat-filter-badge {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.5);
}
.stat-dual.active .stat-label {
  color: #fde68a;
  font-weight: 700;
}

/* 2. 全部救護 (Blue) */
.stat-rescue {
  border-color: rgba(59, 130, 246, 0.2);
}
.stat-rescue .stat-icon-wrap {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.1);
}
.stat-rescue.active {
  border-color: #3b82f6;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(20, 24, 38, 0.95));
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3), inset 0 0 12px rgba(59, 130, 246, 0.1);
}
.stat-rescue.active .stat-filter-badge {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.5);
}
.stat-rescue.active .stat-label {
  color: #bfdbfe;
  font-weight: 700;
}

/* 3. 急病案件 (Teal / Emerald) */
.stat-ill {
  border-color: rgba(16, 185, 129, 0.25);
}
.stat-ill .stat-icon-wrap {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
}
.stat-ill.active {
  border-color: #10b981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(20, 24, 38, 0.95));
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3), inset 0 0 12px rgba(16, 185, 129, 0.1);
}
.stat-ill.active .stat-label {
  color: #a7f3d0;
  font-weight: 700;
}

.text-teal { color: #34d399; text-shadow: 0 0 12px rgba(16, 185, 129, 0.4); }

/* 4. 車禍案件 (Orange) */
.stat-crash {
  border-color: rgba(249, 115, 22, 0.2);
}
.stat-crash .stat-icon-wrap {
  color: #fb923c;
  background: rgba(249, 115, 22, 0.1);
}
.stat-crash.active {
  border-color: #f97316;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(20, 24, 38, 0.95));
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.3), inset 0 0 12px rgba(249, 115, 22, 0.1);
}
.stat-crash.active .stat-filter-badge {
  background: rgba(249, 115, 22, 0.25);
  color: #fdba74;
  border: 1px solid rgba(249, 115, 22, 0.5);
}
.stat-crash.active .stat-label {
  color: #fed7aa;
  font-weight: 700;
}

.text-red { color: #f87171; text-shadow: 0 0 12px rgba(239, 68, 68, 0.4); }
.text-blue { color: #60a5fa; text-shadow: 0 0 12px rgba(59, 130, 246, 0.4); }
.text-amber { color: #fbbf24; text-shadow: 0 0 14px rgba(245, 158, 11, 0.5); }
.text-green { color: #34d399; text-shadow: 0 0 12px rgba(16, 185, 129, 0.4); }
.text-orange { color: #fb923c; text-shadow: 0 0 12px rgba(249, 115, 22, 0.4); }

.active-beacon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-orange);
  box-shadow: 0 0 10px var(--accent-orange);
  animation: blink 1.5s infinite;
}

.beacon-amber {
  background: #fbbf24 !important;
  box-shadow: 0 0 12px #fbbf24 !important;
}

/* Toolbar & Filter */
.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.search-box input {
  width: 100%;
  height: 44px;
  padding: 0 2.5rem 0 2.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.clear-btn {
  position: absolute;
  right: 0.85rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}

.filter-controls {
  display: flex;
  gap: 0.6rem;
}

.select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.select-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  pointer-events: none;
}

.select-wrap select {
  height: 44px;
  padding: 0 1.75rem 0 2.3rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.88rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 0.85rem;
  color: var(--text-dim);
  pointer-events: none;
}

.select-wrap select:focus {
  outline: none;
  border-color: var(--accent-red);
}

/* Category Chips */
.chips-container {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
  scrollbar-width: none;
}

.chips-container::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.chip.active {
  background: #fff;
  color: #0f172a;
  border-color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
}

.chip.chip-fire.active {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.chip.chip-crash.active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border-color: transparent;
}

.chip.chip-ill.active, .chip.chip-trauma.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border-color: transparent;
}

/* Feed Header */
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.25rem 0.65rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.feed-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.feed-count {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
}

.feed-controls-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.feed-countdown {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-refresh-feed {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  height: 32px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh-feed:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-refresh-feed:active {
  transform: scale(0.95);
}

.countdown-circle {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-weight: 600;
}

/* Incidents Feed */
.incidents-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Incident Card */
.incident-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.incident-card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.18);
}

.chip.chip-dual.active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.incident-card.card-dual {
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-left: 6px solid #f59e0b;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(17, 24, 39, 0.9) 100%);
  box-shadow: 0 8px 30px -5px rgba(245, 158, 11, 0.3);
}

.badge-dual {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.45);
  letter-spacing: 0.3px;
  animation: pulse-border 2s infinite;
}

.unit-dual-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 3px 8px;
  border-radius: 6px;
  margin-top: 0.25rem;
}

.highlight-amber-box {
  padding: 1rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
}

.setting-info-tip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #93c5fd;
  line-height: 1.4;
}

.setting-scope-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #fde68a;
}

.incident-card.card-fire {
  border-left: 4px solid var(--accent-red);
  box-shadow: 0 4px 20px -5px rgba(239, 68, 68, 0.2);
}

.incident-card.card-accident {
  border-left: 4px solid var(--accent-orange);
}

.incident-card.card-rescue {
  border-left: 4px solid var(--accent-blue);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.card-tags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge-district {
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 3px 9px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 6px;
}

.badge-cat {
  font-size: 0.88rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
}

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

.badge-cat.cat-accident {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.badge-cat.cat-rescue {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.badge-status {
  font-size: 0.84rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.status-active {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  animation: pulse-border 2s infinite;
}

.status-arrived {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.card-time {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
}

.card-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.card-location-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-location {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.2px;
}

.card-unit {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card-unit i {
  color: var(--accent-red);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.btn-nav-primary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.35));
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: var(--radius-sm);
  color: #93c5fd;
  font-weight: 700;
  font-size: 1.02rem;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.15);
}

.btn-nav-primary:hover, .btn-nav-primary:active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.4), rgba(37, 99, 235, 0.6));
  border-color: #60a5fa;
  color: #fff;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.35);
}

.setting-explanation-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.explanation-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.explanation-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 0;
}

.explanation-list li strong {
  color: #e2e8f0;
}

/* Skeleton Loading */
.skeleton-card {
  height: 90px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-title h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.highlight-box {
  padding: 1rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
}

.setting-info {
  display: flex;
  flex-direction: column;
}

.setting-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

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

.push-status-callout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.setting-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.districts-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.district-check-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}

.district-check-label input {
  accent-color: var(--accent-red);
}

.district-check-label:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
}

input:checked + .slider {
  background-color: var(--accent-green);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* High Rescue Team Selector */
.team-selector-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
}

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

.team-selector-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fbbf24;
}

.btn-toggle-all {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 3px 8px;
  font-size: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-all:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.team-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.team-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, background 0.2s;
}

.team-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(245, 158, 11, 0.3);
}

.team-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.team-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.team-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.team-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.team-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.badge-boguan {
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-huludun {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-heli {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Compact switch for team items */
.switch-sm {
  width: 44px;
  height: 24px;
}

.switch-sm .slider:before {
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
}

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

.highlight-teal-box {
  padding: 0.85rem 1rem;
  background: rgba(20, 184, 166, 0.08);
  border: 1px solid rgba(20, 184, 166, 0.25);
  border-radius: var(--radius-md);
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

/* Map Modal */
.modal-map-card {
  max-width: 720px;
}

.map-container {
  height: 420px;
  width: 100%;
}

.map-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.map-addr-text {
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 500;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1.4rem;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    padding: 0.75rem 0.6rem 3rem;
  }

  .main-title {
    font-size: 1.1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .stat-card {
    padding: 0.85rem 1rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .toolbar {
    flex-direction: column;
  }

  .filter-controls {
    width: 100%;
  }

  .select-wrap {
    flex: 1;
  }

  .select-wrap select {
    width: 100%;
  }

  .hide-mobile {
    display: none;
  }

  .districts-checkbox-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .map-container {
    height: 300px;
  }
}

/* Dedicated Mobile Optimization (iPhone & Android Phones <= 600px) */
@media (max-width: 600px) {
  .app-container {
    padding: 0.5rem 0.6rem 3rem;
  }

  /* Header Optimization */
  .app-header {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
    border-radius: var(--radius-md);
  }

  .header-left {
    gap: 0.6rem;
    min-width: 0;
    flex: 1;
  }

  .logo-badge {
    width: 36px;
    height: 36px;
  }

  .pulse-ring {
    inset: -3px;
    border-radius: 12px;
  }

  .title-group {
    min-width: 0;
  }

  .title-top {
    gap: 0.4rem;
    margin-bottom: 0.1rem;
  }

  .live-pill {
    font-size: 0.68rem;
    padding: 1px 6px;
    white-space: nowrap;
  }

  .timer-tag {
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .title-desktop {
    display: none;
  }

  .title-mobile {
    display: inline;
    white-space: nowrap;
  }

  .main-title {
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .btn-icon-action {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
  }

  .btn-refresh-action {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .push-status-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
  }

  /* Notification Banner Optimization */
  .alert-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem 0.95rem;
    margin-bottom: 0.9rem;
    border-radius: var(--radius-md);
  }

  .alert-content {
    align-items: flex-start;
    gap: 0.65rem;
  }

  .alert-icon {
    font-size: 1.25rem;
    margin-top: 2px;
    flex-shrink: 0;
  }

  .alert-text strong {
    font-size: 0.92rem;
    margin-bottom: 0.15rem;
    line-height: 1.3;
  }

  .alert-text span {
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-muted);
  }

  .btn-banner-action {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
    border-radius: var(--radius-sm);
  }

  /* Stats KPI & Filter Grid Mobile Layout */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
    margin-bottom: 0.85rem;
  }

  .stat-card {
    padding: 0.75rem 0.85rem;
    gap: 0.55rem;
    border-radius: var(--radius-sm);
  }

  .stat-icon-wrap {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    border-radius: 9px;
  }

  .stat-label-row {
    gap: 0.25rem;
    margin-bottom: 0.1rem;
  }

  .stat-label {
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0;
  }

  .stat-filter-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 6px;
  }

  .stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1.1;
  }

  .active-beacon {
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
  }

  /* Feed Header */
  .feed-header {
    padding: 0 0.15rem 0.55rem;
    margin-bottom: 0.75rem;
  }

  .feed-title {
    font-size: 1.05rem;
    font-weight: 700;
  }

  .feed-count {
    font-size: 0.84rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 8px;
  }

  .feed-countdown {
    font-size: 0.84rem;
  }

  /* Incidents Feed & Card Mobile Ergonomics */
  .incidents-container {
    gap: 0.75rem;
  }

  .incident-card {
    padding: 0.95rem 1rem;
    border-radius: var(--radius-md);
  }

  .card-top {
    margin-bottom: 0.55rem;
    gap: 0.4rem;
  }

  .card-tags {
    gap: 0.35rem;
  }

  .badge-district {
    font-size: 0.82rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
  }

  .badge-cat {
    font-size: 0.82rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
  }

  .badge-status {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
  }

  .badge-dual {
    padding: 3px 8px;
    font-size: 0.84rem;
    font-weight: 800;
  }

  .card-time {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-dim);
  }

  /* Card Main Stacked Layout */
  .card-main {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .card-location-group {
    gap: 0.35rem;
  }

  .card-location {
    font-size: 1.28rem;
    font-weight: 800;
    line-height: 1.32;
    word-break: break-word;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }

  .card-unit {
    font-size: 0.94rem;
    font-weight: 600;
    line-height: 1.35;
    flex-wrap: wrap;
    color: #cbd5e1;
  }

  .unit-dual-badge {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 3px 7px;
    margin-top: 0.15rem;
  }

  .feed-controls-right {
    gap: 0.45rem;
  }

  .btn-refresh-feed span {
    display: none;
  }

  .btn-refresh-feed {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
    padding: 0;
    justify-content: center;
    border-radius: 8px;
  }

  /* Card Bottom Action Bar */
  .card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.25rem;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .card-actions .btn-nav-primary {
    flex: 1;
    height: 44px;
    font-size: 1.02rem;
    font-weight: 800;
    justify-content: center;
    padding: 0 0.9rem;
    letter-spacing: 0.3px;
  }

  .card-actions .btn-speak {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
    flex-shrink: 0;
    justify-content: center;
    padding: 0;
  }

  /* Modals Mobile Fit */
  .modal-backdrop {
    padding: 0.75rem;
  }

  .modal-card {
    border-radius: var(--radius-md);
    max-height: 88vh;
  }

  .modal-header {
    padding: 1rem 1.15rem;
  }

  .modal-title h3 {
    font-size: 1.1rem;
    font-weight: 700;
  }

  .modal-body {
    padding: 1rem 1.15rem;
    gap: 1rem;
  }

  .setting-row {
    gap: 0.75rem;
  }

  .setting-title {
    font-size: 0.98rem;
    font-weight: 700;
  }

  .setting-desc {
    font-size: 0.84rem;
    line-height: 1.4;
  }

  .modal-footer {
    padding: 1rem 1.15rem;
  }
}

/* Extra small screens <= 360px */
@media (max-width: 360px) {
  .main-title {
    font-size: 1.05rem;
  }
  .stat-label {
    font-size: 0.78rem;
  }
  .stat-value {
    font-size: 1.4rem;
  }
  .card-location {
    font-size: 1.18rem;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
