/* ============================================================
   SafeQR – QR Khẩn Cấp
   Design System v2.0 — clean, calm, easy to act
   ============================================================ */

:root {
  /* ── Core palette ── */
  --red:        #b71c1c;
  --red-deep:   #7f0000;
  --red-dark:   #931a1a;
  --red-mid:    #c62828;
  --red-soft:   #ef5350;
  --red-pale:   #ffebee;
  --red-glow:   rgba(183,28,28,0.10);

  /* Neutrals — warm-tinted */
  --bg:         #f7f5f0;
  --bg-alt:     #f0ede7;
  --card-bg:    #ffffff;
  --surface:    #fafaf7;

  --text:       #1c1c1c;
  --text-soft:  #4a4a4a;
  --text-muted: #8a8a86;
  --text-hint:  #b0b0aa;

  --border:     #e8e4db;
  --border-alt: #f0ece4;

  /* Depth — tinted shadows */
  --shadow-xs:  0 1px 2px rgba(47,30,20,0.04);
  --shadow-sm:  0 2px 6px rgba(47,30,20,0.05), 0 1px 3px rgba(47,30,20,0.04);
  --shadow:     0 4px 14px rgba(47,30,20,0.06), 0 2px 6px rgba(47,30,20,0.04);
  --shadow-lg:  0 8px 28px rgba(47,30,20,0.08), 0 3px 10px rgba(47,30,20,0.05);
  --shadow-xl:  0 14px 44px rgba(47,30,20,0.10), 0 6px 16px rgba(47,30,20,0.06);
  --shadow-red: 0 4px 16px rgba(183,28,28,0.18);

  /* Radii — varied */
  --radius-xl:  20px;
  --radius-lg:  16px;
  --radius:     14px;
  --radius-sm:  10px;
  --radius-xs:  8px;

  /* Layout */
  --max-width: 480px;
  --max-md:    720px;
  --max-lg:    960px;
  --max-xl:    1140px;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --ease: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  margin: 0 auto;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 120px;
  position: relative;
}

/* Subtle grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image:
    radial-gradient(ellipse at 25% 15%, rgba(183,28,28,0.025) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 85%, rgba(183,28,28,0.015) 0%, transparent 55%);
}

body { max-width: var(--max-width); }
@media (min-width: 768px)  { body { max-width: var(--max-md); } }
@media (min-width: 1024px) { body { max-width: var(--max-lg); } }
@media (min-width: 1400px) { body { max-width: var(--max-xl); } }

/* Skip link */
.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 500;
  background: var(--red);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 12px;
  outline: 3px solid rgba(255,255,255,0.5);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   HEADER — Clean sticky with glass finish
   ═══════════════════════════════════════════════════════════════ */
.header {
  background: rgba(183, 28, 28, 0.94);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  color: #fff;
  padding: 10px 18px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow:
    0 4px 24px rgba(127,0,0,0.22),
    0 1px 4px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.08);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-xl);
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo svg {
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.18));
}
.logo-text {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.15;
}
.logo-sub {
  font-size: 0.66rem;
  opacity: 0.78;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 7px;
}
.header-badge {
  background: rgba(255,255,255,0.12);
  padding: 5px 11px;
  border-radius: 22px;
  font-size: 0.66rem;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.14);
  letter-spacing: 0.3px;
}

/* Header nav buttons */
.btn-qr-header,
.btn-handbook-header {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 22px;
  background: rgba(255,255,255,0.94);
  color: var(--red);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font);
  white-space: nowrap;
  transition: all var(--ease);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.btn-handbook-header {
  border: 1.5px dashed rgba(183,28,28,0.20);
  background: #fff;
}
.btn-qr-header:hover,
.btn-handbook-header:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.btn-qr-header:active,
.btn-handbook-header:active {
  transform: scale(0.95);
}
.btn-qr-header:focus-visible,
.btn-handbook-header:focus-visible {
  outline: 3px solid rgba(255,255,255,0.7);
  outline-offset: 3px;
}

.btn-admin-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 11px;
  border-radius: 22px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.88);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font);
  white-space: nowrap;
  transition: all var(--ease);
  border: 1px solid rgba(255,255,255,0.16);
}
.btn-admin-header:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.30);
}
.btn-admin-header:active {
  transform: scale(0.95);
}
.btn-admin-header:focus-visible {
  outline: 3px solid rgba(255,255,255,0.7);
  outline-offset: 3px;
}

@media (max-width: 420px) {
  .btn-qr-header span,
  .btn-admin-header span,
  .btn-handbook-header span { display: none; }
  .btn-qr-header,
  .btn-admin-header,
  .btn-handbook-header { padding: 7px 9px; }
  .header { padding: 8px 12px; }
}

/* ═══════════════════════════════════════════════════════════════
   HERO — Refined gradient, more spacious
   ═══════════════════════════════════════════════════════════════ */
.hero {
  background:
    radial-gradient(ellipse at 35% 25%, rgba(255,255,255,0.10) 0%, transparent 55%),
    radial-gradient(ellipse at 65% 75%, rgba(0,0,0,0.20) 0%, transparent 50%),
    linear-gradient(165deg, #7f0000 0%, #9e1515 30%, #b71c1c 60%, #c62828 100%);
  color: #fff;
  padding: 36px 18px 44px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--bg);
  border-radius: 50% 55% 0 0;
}

@media (min-width: 768px) {
  .hero { padding: 52px 28px 60px; }
}

.hero-content {
  position: relative;
  z-index: 1;
}
.hero-title {
  font-size: clamp(1.55rem, 5.8vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.9px;
  margin-bottom: 10px;
  text-shadow: 0 2px 16px rgba(0,0,0,0.22);
  line-height: 1.18;
  text-wrap: balance;
}
.hero-desc {
  font-size: clamp(0.85rem, 2.8vw, 1.05rem);
  opacity: 0.88;
  margin-bottom: 4px;
  line-height: 1.55;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
  font-weight: 440;
  text-wrap: pretty;
}
.hero-desc strong {
  font-weight: 750;
  opacity: 1;
}

/* ── Location Banner (reverse-geocoded address) ── */
.location-pulse-ring {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.pulse-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.35);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: proximityPulse 2.2s ease-out infinite;
}
.pulse-ring.r1 { width: 80px;  height: 80px;  animation-delay: 0s; }
.pulse-ring.r2 { width: 140px; height: 140px; animation-delay: 0.6s; }
.pulse-ring.r3 { width: 200px; height: 200px; animation-delay: 1.2s; }
@keyframes proximityPulse {
  0%   { opacity: 0.7; transform: translate(-50%, -50%) scale(0.75); }
  100% { opacity: 0;   transform: translate(-50%, -50%) scale(1.35); }
}

.location-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 18px auto 22px;
  padding: 12px 22px;
  border-radius: 28px;
  font-size: 0.82rem;
  font-weight: 500;
  max-width: 520px;
  transition: all 0.35s ease;
  line-height: 1.4;
  text-align: center;
  position: relative;
  z-index: 1;
}
.location-banner strong {
  font-weight: 700;
  color: #fff;
}
.loc-text {
  font-weight: 500;
}
.location-banner.loading {
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.70);
  border: 1px solid rgba(255,255,255,0.10);
}
.location-banner.located {
  background: rgba(255,255,255,0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(255,255,255,0.95);
  border: 1px solid rgba(255,255,255,0.25);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  padding: 14px 24px;
  gap: 10px;
}
.location-banner.located:hover {
  background: rgba(255,255,255,0.24);
  border-color: rgba(255,255,255,0.40);
  transform: translateY(-2px);
  box-shadow: 0 6px 26px rgba(0,0,0,0.18);
}
.location-banner.coords-only {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.58);
  border: 1px solid rgba(255,255,255,0.10);
}
.location-banner.located .loc-label {
  font-size: 0.72rem;
  opacity: 0.78;
  font-weight: 500;
}
.loc-label {
  opacity: 0.70;
  font-weight: 500;
  font-size: 0.73rem;
  white-space: nowrap;
}
.loc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #4caf50;
  box-shadow: 0 0 8px rgba(76,175,80,0.7);
}
.loc-dot.pulse {
  animation: locPulse 1.4s ease-in-out infinite;
  background: rgba(255,255,255,0.55);
}
@keyframes locPulse {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50%      { opacity: 1.0; transform: scale(1.15); }
}
.loc-dot.active {
  background: #4caf50;
  box-shadow: 0 0 10px rgba(76,175,80,0.8);
  width: 11px;
  height: 11px;
}
.loc-dot.denied {
  background: #ff9800;
  box-shadow: 0 0 8px rgba(255,152,0,0.6);
  width: 11px;
  height: 11px;
}
.location-banner.error {
  background: rgba(255,152,0,0.15);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,152,0,0.3);
  cursor: pointer;
}
.location-banner.error:hover {
  background: rgba(255,152,0,0.25);
  border-color: rgba(255,152,0,0.5);
}
@media (max-width: 420px) {
  .location-banner {
    font-size: 0.72rem;
    padding: 10px 16px;
    margin-bottom: 16px;
    border-radius: 24px;
  }
  .location-banner.located {
    padding: 11px 18px;
  }
  .pulse-ring.r1 { width: 60px;  height: 60px; }
  .pulse-ring.r2 { width: 100px; height: 100px; }
  .pulse-ring.r3 { width: 150px; height: 150px; }
}

.hero-hotlines {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.hotline-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255,255,255,0.20);
  border-radius: var(--radius);
  padding: 16px 22px;
  color: #fff;
  font-family: var(--font);
  cursor: pointer;
  min-width: 100px;
  transition: all var(--ease);
}
.hotline-btn:hover {
  background: rgba(255,255,255,0.20);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.hotline-btn:active {
  background: rgba(255,255,255,0.28);
  transform: scale(0.95);
}
.hotline-btn:focus-visible {
  outline: 3px solid rgba(255,255,255,0.6);
  outline-offset: 3px;
}
.hotline-num {
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  font-variant-numeric: tabular-nums;
}
.hotline-label {
  font-size: 0.7rem;
  opacity: 0.80;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════ */
.main-content {
  padding: 28px 16px;
}
@media (min-width: 768px)  { .main-content { padding: 40px 24px; } }
@media (min-width: 1024px) { .main-content { padding: 48px 32px; } }

.section-header {
  text-align: center;
  margin-bottom: 24px;
}
.section-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 5px;
  letter-spacing: -0.3px;
}
.section-header p {
  font-size: 0.82rem;
  color: var(--text-soft);
  font-weight: 440;
}

/* Section divider between global and local contacts */
.section-divider {
  width: 60px;
  height: 4px;
  background: var(--red);
  border-radius: 2px;
  margin: 32px auto 24px;
  opacity: 0.4;
}

/* ═══════════════════════════════════════════════════════════════
   CARD GRID — Dynamic columns (JS-controlled, auto-balanced)
   ═══════════════════════════════════════════════════════════════ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* fallback, JS overrides */
  gap: 12px;
  justify-content: center;
}
@media (min-width: 500px)  { .card-grid { gap: 16px; } }
@media (min-width: 768px)  { .card-grid { gap: 20px; } }

/* Card — compact, clean, top accent bar */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: all var(--ease);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-alt);
  border-top: 3px solid var(--card-color, var(--red));
  min-height: 0;
}

.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.card:active {
  transform: scale(0.975) translateY(-1px);
}

.card-icon {
  font-size: 1.7rem;
  line-height: 1;
}
.card-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.2;
}
.card-desc {
  display: none; /* hide on mobile, show on desktop */
}
.card-phone {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.3px;
  color: var(--card-color, var(--red));
  font-variant-numeric: tabular-nums;
  font-family: var(--font);
  line-height: 1.1;
}
.card-address {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: auto;
  padding-top: 4px;
}

/* Buttons inside cards — stacked, compact */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 10px;
  border-radius: 20px;
  border: none;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--ease);
  width: 100%;
  text-align: center;
  letter-spacing: -0.1px;
  white-space: nowrap;
}
.btn-call {
  background: var(--card-color, var(--red));
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--card-color, var(--red)) 25%, transparent);
}
.btn-call:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--card-color, var(--red)) 30%, transparent);
}
.btn-call:active {
  filter: brightness(0.92);
  transform: scale(0.95);
}
.btn-call:focus-visible {
  outline: 3px solid var(--card-color, var(--red));
  outline-offset: 3px;
}

.btn-maps {
  background: #fff;
  color: var(--card-color, var(--red));
  border: 1.5px solid var(--card-color, var(--red));
}
.btn-maps:hover {
  background: color-mix(in srgb, var(--card-color, var(--red)) 4%, #fff);
  transform: translateY(-1px);
}
.btn-maps:active {
  background: color-mix(in srgb, var(--card-color, var(--red)) 10%, #fff);
  transform: scale(0.95);
}
.btn-maps:focus-visible {
  outline: 3px solid var(--card-color, var(--red));
  outline-offset: 3px;
}

/* ═══════════════════════════════════════════════════════════════
   EXTRA SECTION
   ═══════════════════════════════════════════════════════════════ */
.extra-section {
  padding: 0 16px 28px;
}
.extra-details {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  border: 1px solid var(--border);
}
.extra-summary {
  padding: 15px 20px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: var(--text);
  transition: background var(--ease);
}
.extra-summary:hover {
  background: var(--surface);
}
.extra-summary::-webkit-details-marker { display: none; }
.extra-summary:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: -3px;
  border-radius: var(--radius);
}

.extra-list {
  list-style: none;
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.extra-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.83rem;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-alt);
}
.extra-list li:last-child { border-bottom: none; }
.extra-list .extra-name {
  color: var(--text-soft);
  font-weight: 500;
}
.extra-list .extra-phone {
  font-weight: 700;
  color: var(--red);
  background: none;
  border: none;
  font-size: inherit;
  font-family: var(--font);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: all var(--ease);
}
.extra-list .extra-phone:hover {
  background: var(--red-pale);
  text-decoration: underline;
}
.extra-list .extra-phone:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   SOS FLOATING BUTTON — Refined
   ═══════════════════════════════════════════════════════════════ */
.sos-container {
  position: fixed;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
}
.sos-container.dragging { transition: none; }
.sos-container.on-left  { align-items: flex-start; }
.sos-container.on-right { align-items: flex-end; }

.sos-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.85);
  background: linear-gradient(140deg, #b71c1c 0%, #e53935 100%);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  cursor: grab;
  font-family: var(--font);
  box-shadow:
    0 6px 24px rgba(183,28,28,0.40),
    inset 0 1px 0 rgba(255,255,255,0.12);
  transition: all var(--ease);
  touch-action: none;
}
.sos-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 28px rgba(183,28,28,0.50);
}
.sos-btn:active {
  cursor: grabbing;
  transform: scale(0.90);
}
.sos-btn:focus-visible {
  outline: 4px solid rgba(183,28,28,0.5);
  outline-offset: 4px;
}
.sos-container.dragging .sos-btn {
  transform: scale(1.08);
}

@keyframes sosPulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(183,28,28,0.40); }
  50%      { box-shadow: 0 6px 34px rgba(183,28,28,0.60), 0 0 0 10px rgba(183,28,28,0.08); }
}
.sos-btn { animation: sosPulse 2s ease-in-out infinite; }

.sos-actions {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: var(--card-bg);
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  min-width: 160px;
}
.sos-actions.visible { display: flex; }

.sos-action {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border: none;
  border-radius: 24px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--ease);
  background: #f5f5f2;
  color: var(--text);
}
.sos-action:hover {
  background: #ebebe6;
}
.sos-action:active {
  transform: scale(0.96);
}
.sos-action:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
.sos-action.call {
  background: var(--red);
  color: #fff;
}
.sos-action.call:hover {
  background: var(--red-dark);
}
.sos-action.share {
  background: #1565c0;
  color: #fff;
}
.sos-action.share:hover {
  background: #0d47a1;
}
.sos-action.cancel {
  background: transparent;
  color: var(--text-muted);
}
.sos-action.cancel:hover {
  background: #eee;
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════ */
.footer {
  text-align: center;
  padding: 30px 16px 40px;
  color: var(--text-muted);
  font-size: 0.73rem;
  border-top: 1px solid var(--border);
}
.footer p { margin-bottom: 4px; }
.footer-meta {
  opacity: 0.55;
  font-size: 0.7rem;
}
.footer-links {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--red);
  text-decoration: none;
  font-weight: 700;
  padding: 9px 20px;
  border: 1.5px solid rgba(183,28,28,0.22);
  border-radius: 24px;
  transition: all var(--ease);
  font-size: 0.78rem;
}
.footer-links a:hover {
  background: rgba(183,28,28,0.04);
  border-color: rgba(183,28,28,0.45);
}
.footer-links a:active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.footer-links a:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

/* ═══════════════════════════════════════════════════════════════
   TOAST — Refined
   ═══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(18px);
  background: rgba(30,28,26,0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 11px 24px;
  border-radius: 26px;
  font-size: 0.81rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease);
  z-index: 300;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.08);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  background: rgba(183,28,28,0.94);
  border-color: rgba(255,255,255,0.18);
}

/* ═══════════════════════════════════════════════════════════════
   PHONE MODAL — Desktop fallback
   ═══════════════════════════════════════════════════════════════ */
.phone-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.phone-modal-overlay.visible { display: flex; }

.phone-modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 34px 28px 28px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-alt);
  animation: modalPop 0.3s var(--ease-spring);
}
@keyframes modalPop {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.phone-modal-icon {
  font-size: 3.2rem;
  margin-bottom: 10px;
  line-height: 1;
}
.phone-modal-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.phone-modal-number {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 14px;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}
.phone-modal-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.55;
}
.phone-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.phone-modal-copy {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 12px 26px;
  border-radius: 26px;
  font-size: 0.86rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--ease);
  box-shadow: var(--shadow-red);
}
.phone-modal-copy:hover {
  background: var(--red-dark);
}
.phone-modal-copy:active {
  transform: scale(0.95);
}
.phone-modal-copy:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
.phone-modal-close {
  background: #f0f0eb;
  color: var(--text-soft);
  border: none;
  padding: 12px 26px;
  border-radius: 26px;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--ease);
}
.phone-modal-close:hover {
  background: #e4e4dd;
}
.phone-modal-close:active {
  transform: scale(0.95);
}
.phone-modal-close:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

/* ═══════════════════════════════════════════════════════════════
   EMERGENCY TYPE SELECTOR MODAL
   ═══════════════════════════════════════════════════════════════ */
.emergency-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 450;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.emergency-modal-overlay.visible {
  display: flex;
}

.emergency-modal {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 28px 24px 20px;
  max-width: 440px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-alt);
  animation: modalPop 0.3s var(--ease-spring);
}

.emergency-modal-header {
  text-align: center;
  margin-bottom: 22px;
}
.emergency-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.emergency-modal-header p {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.emergency-types {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 16px;
}

.emergency-type-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: all var(--ease);
  position: relative;
  overflow: hidden;
}
.emergency-type-btn:hover {
  border-color: var(--red);
  background: #fff;
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}
.emergency-type-btn:active {
  transform: scale(0.97);
}
.emergency-type-btn:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

.emergency-type-btn.selected {
  border-color: var(--red);
  background: var(--red-pale);
  box-shadow: 0 0 0 3px var(--red-glow);
  transform: translateX(4px);
}

.emergency-type-btn .et-icon {
  font-size: 1.9rem;
  flex-shrink: 0;
  width: 44px;
  text-align: center;
  line-height: 1;
}

.emergency-type-btn .et-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.emergency-type-btn .et-label {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
}

.emergency-type-btn .et-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.emergency-modal-close-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 26px;
  background: #f0f0eb;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--ease);
}
.emergency-modal-close-btn:hover {
  background: #e4e4dd;
}
.emergency-modal-close-btn:active {
  transform: scale(0.97);
}
.emergency-modal-close-btn:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

/* ── Accuracy Warning Bar ── */
.accuracy-warning {
  display: none;
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(245,158,11,0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.78rem;
  font-weight: 600;
  z-index: 350;
  box-shadow: 0 4px 16px rgba(245,158,11,0.30);
  border: 1px solid rgba(255,255,255,0.20);
  max-width: 90vw;
  text-align: center;
  white-space: normal;
  animation: accuracyWarnIn 0.35s var(--ease-spring);
}
@keyframes accuracyWarnIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.accuracy-warning.show {
  display: block;
}

@media (max-width: 400px) {
  .emergency-modal {
    padding: 22px 16px 16px;
    max-height: 92vh;
  }
  .emergency-type-btn {
    padding: 11px 13px;
    gap: 10px;
  }
  .emergency-type-btn .et-icon {
    font-size: 1.5rem;
    width: 36px;
  }
  .emergency-type-btn .et-label {
    font-size: 0.8rem;
  }
  .accuracy-warning {
    top: 62px;
    font-size: 0.72rem;
    padding: 8px 18px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT AI — Refined panel
   ═══════════════════════════════════════════════════════════════ */
.chat-container {
  position: fixed;
  z-index: 200;
  user-select: none;
  -webkit-user-select: none;
}
.chat-container.dragging { transition: none; }

.chat-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.88);
  background: linear-gradient(140deg, #1565c0 0%, #1e88e5 100%);
  color: #fff;
  font-size: 1.25rem;
  cursor: grab;
  box-shadow:
    0 6px 22px rgba(21,101,192,0.32),
    inset 0 1px 0 rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--ease);
  touch-action: none;
}
.chat-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 26px rgba(21,101,192,0.42);
}
.chat-btn:active {
  cursor: grabbing;
  transform: scale(0.90);
}
.chat-btn:focus-visible {
  outline: 4px solid rgba(21,101,192,0.5);
  outline-offset: 4px;
}
.chat-container.dragging .chat-btn {
  transform: scale(1.08);
}

.chat-panel {
  display: none;
  position: fixed;
  bottom: 94px;
  right: 16px;
  width: calc(100vw - 32px);
  max-width: 400px;
  height: 480px;
  max-height: calc(100vh - 150px);
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-alt);
  animation: chatSlideUp 0.28s var(--ease-spring);
}
.chat-panel.panel-left  { right: auto; left: 16px; }
.chat-panel.panel-right { right: 16px; left: auto; }

@keyframes chatSlideUp {
  from { transform: translateY(34px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.chat-panel.visible { display: flex; }

.chat-header {
  background: linear-gradient(140deg, #0d47a1 0%, #1565c0 100%);
  color: #fff;
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.86rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.chat-header-icon {
  margin-right: 6px;
}
.chat-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 1rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  transition: all var(--ease);
}
.chat-close:hover {
  background: rgba(255,255,255,0.28);
}
.chat-close:focus-visible {
  outline: 3px solid rgba(255,255,255,0.6);
  outline-offset: 2px;
}

.chat-suggestions {
  padding: 12px 14px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-alt);
  background: var(--surface);
}
.chat-chip {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 0.69rem;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--ease);
  font-weight: 500;
  color: var(--text-soft);
}
.chat-chip:hover {
  border-color: #1565c0;
  color: #1565c0;
  background: #f5f8fc;
}
.chat-chip:active {
  background: #1565c0;
  color: #fff;
  border-color: #1565c0;
}
.chat-chip:focus-visible {
  outline: 3px solid #1565c0;
  outline-offset: 2px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fb;
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.ai   { justify-content: flex-start; }
.chat-msg-content {
  max-width: 86%;
  padding: 10px 15px;
  border-radius: 20px;
  font-size: 0.81rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user .chat-msg-content {
  background: linear-gradient(140deg, #1565c0 0%, #1976d2 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 8px rgba(21,101,192,0.22);
}
.chat-msg.ai .chat-msg-content {
  background: #fff;
  color: var(--text);
  border: 1px solid #e8e9ec;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.chat-msg.ai .chat-msg-content strong {
  color: #1565c0;
}
.chat-typing .chat-msg-content {
  background: #fff;
  border: 1px solid #e8e9ec;
  color: var(--text-muted);
  font-style: italic;
}

.chat-input-area {
  display: flex;
  gap: 9px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #e0e2e6;
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 0.83rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
  background: var(--surface);
}
.chat-input:focus {
  border-color: #1565c0;
  box-shadow: 0 0 0 4px rgba(21,101,192,0.06);
  background: #fff;
}
.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(140deg, #1565c0 0%, #1e88e5 100%);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font);
  box-shadow: 0 2px 10px rgba(21,101,192,0.22);
  transition: all var(--ease);
}
.chat-send:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px rgba(21,101,192,0.30);
}
.chat-send:active {
  transform: scale(0.90);
}
.chat-send:focus-visible {
  outline: 3px solid #1565c0;
  outline-offset: 3px;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile fine-tuning
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .card-grid { gap: 6px; }
  .card { padding: 10px 8px; gap: 4px; }
  .card-icon { font-size: 1.4rem; }
  .card-name { font-size: 0.68rem; }
  .card-phone { font-size: 0.9rem; }
  .card-address { font-size: 0.6rem; }
  .btn { padding: 6px 8px; font-size: 0.63rem; border-radius: 16px; }
  .hero-hotlines { gap: 10px; }
  .hotline-btn { min-width: 88px; padding: 14px 16px; }
}

/* Desktop: restore richer card layout */
@media (min-width: 768px) {
  .card { padding: 18px 16px; gap: 8px; border-top-width: 3.5px; }
  .card-icon { font-size: 2.2rem; }
  .card-name { font-size: 0.9rem; }
  .card-desc { display: block; font-size: 0.7rem; }
  .card-phone { font-size: 1.25rem; }
  .card-address { font-size: 0.7rem; white-space: pre-line; overflow: visible; }
  .card-actions { flex-direction: row; gap: 8px; }
  .btn { width: auto; flex: 1; padding: 9px 14px; font-size: 0.74rem; }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */
@media print {
  .header, .hero, .footer, .sos-container, .extra-section,
  .chat-container, .phone-modal-overlay, .emergency-modal-overlay,
  .accuracy-warning { display: none; }
  body { background: #fff; max-width: 100%; padding: 0; }
  body::before { display: none; }
  .card-grid { gap: 8px; }
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
    padding: 14px;
    border-top-width: 2px;
    animation: none;
  }
  .main-content { padding: 12px; }
}
