:root {
  --bg: #07080c;
  --bg-elev: #10131a;
  --card: #151922;
  --card-2: #1b2030;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f5f7fb;
  --muted: #9aa3b5;
  --red: #ff3b3b;
  --red-2: #ff6b5a;
  --red-dim: #3a1012;
  --amber: #ffb020;
  --green: #2ee59d;
  --blue: #5aa7ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  --radius: 22px;
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display: "Barlow", "IBM Plex Sans", sans-serif;
  --cond: "Barlow Condensed", "Barlow", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }
a { color: var(--blue); }

.bg-glow, .bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.bg-glow {
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(255, 59, 59, 0.22), transparent 60%),
    radial-gradient(600px 280px at 100% 20%, rgba(90, 167, 255, 0.06), transparent 50%);
}
.bg-grid {
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 20%, #000 20%, transparent 75%);
}

.nav, main, .footer { position: relative; z-index: 1; }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 8, 12, 0.78);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 42px; height: 42px; flex: 0 0 auto; filter: drop-shadow(0 6px 12px rgba(195, 19, 19, 0.45)); }
.logo.sm { width: 32px; height: 32px; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.01em;
  font-size: 1.05rem;
}
.brand-copy span { color: var(--muted); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mode-badge {
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #1b1f2a;
  color: var(--amber);
}
.mode-badge.live {
  color: #fff;
  background: var(--red);
  border-color: transparent;
  box-shadow: 0 0 0 4px rgba(255, 59, 59, 0.18);
}

main { width: min(1080px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 64px; }

.notice {
  background: linear-gradient(180deg, #1a140e, #141018);
  border: 1px solid rgba(255, 176, 32, 0.28);
  color: #f3e2c1;
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 0.92rem;
  margin-bottom: 22px;
}
.notice strong { color: var(--amber); display: block; margin-bottom: 4px; font-family: var(--display); }

.hero {
  text-align: center;
  background: linear-gradient(180deg, rgba(27, 17, 20, 0.9), rgba(16, 19, 26, 0.92));
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 22px 18px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}
.pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: #0d1017;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
}
.pill.ok { color: var(--green); border-color: rgba(46, 229, 157, 0.35); }
.pill.warn { color: var(--amber); border-color: rgba(255, 176, 32, 0.35); }
.pill.bad { color: var(--red-2); border-color: rgba(255, 59, 59, 0.35); }

.ring-wrap { display: grid; place-items: center; margin: 8px 0 14px; }
.ring {
  --ring-color: #3a4154;
  width: min(78vw, 280px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 59, 59, 0.12), transparent 42%),
    #0c0f16;
  box-shadow: inset 0 0 0 10px #0a0c12, 0 0 0 3px var(--ring-color), var(--shadow);
}
.ring[data-state="armed"] { --ring-color: var(--green); }
.ring[data-state="triggered"] { --ring-color: var(--red); }
.ring-pulse {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--ring-color);
  opacity: 0;
}
.ring[data-state="armed"] .ring-pulse,
.ring[data-state="triggered"] .ring-pulse {
  animation: pulse 2s ease-out infinite;
}
.ring-pulse.delay { animation-delay: 1s !important; }
@keyframes pulse {
  0% { transform: scale(0.92); opacity: 0.55; }
  100% { transform: scale(1.14); opacity: 0; }
}

.arm-btn {
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 50% 30%, #2a3144, #151822 68%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 16px 30px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.15s ease, background 0.2s ease;
}
.arm-btn:hover { transform: scale(1.02); }
.arm-btn:active { transform: scale(0.98); }
.arm-btn[aria-pressed="true"] {
  background: radial-gradient(circle at 50% 30%, #1c3a30, #10221c 68%);
}
.ring[data-state="triggered"] .arm-btn {
  background: radial-gradient(circle at 50% 30%, #5a1717, #2a0c0c 68%);
}
.arm-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.arm-label {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.15rem, 4.4vw, 1.7rem);
  line-height: 1.05;
  max-width: 11ch;
}

.hero-status { color: var(--muted); margin: 0 0 16px; font-size: 0.95rem; }

.panic-btn {
  width: min(100%, 420px);
  border: 0;
  border-radius: 16px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #ff4d4d, #d41515);
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(212, 21, 21, 0.35);
}
.panic-btn:active { transform: translateY(1px); }

.hearing {
  margin: 18px auto 0;
  width: min(100%, 640px);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  background: #0b0e14;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  min-height: 48px;
}
.hearing-label {
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  padding-top: 2px;
}
.hearing-text { color: var(--text); font-size: 0.92rem; word-break: break-word; }

.meter { width: min(100%, 640px); margin: 14px auto 0; text-align: left; }
.meter-top {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.meter-track {
  height: 10px;
  border-radius: 999px;
  background: #0b0e14;
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2ee59d, #ffb020 70%, #ff3b3b);
  transition: width 0.08s linear;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.card {
  background: linear-gradient(180deg, rgba(27, 32, 48, 0.92), rgba(16, 19, 26, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-head h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
}
.card-head p { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #0b0e14;
  border: 1px solid var(--line);
  padding: 5px;
  border-radius: 14px;
  margin-bottom: 14px;
}
.seg {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 11px 8px;
  font-weight: 700;
}
.seg.on { background: #232a3b; color: var(--text); }
.seg.on[data-live="true"], #liveModeBtn.on {
  background: var(--red);
  color: #fff;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field.tight { margin-top: -4px; }
.field span { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.field em { font-style: normal; color: var(--text); }
input[type="text"], input[type="tel"], input[type="url"], textarea, select {
  background: #0b0e14;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: rgba(90, 167, 255, 0.7); }
textarea { resize: vertical; min-height: 72px; }
input[type="range"] { width: 100%; accent-color: var(--red); }

.toggles { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 16px; }
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}
.toggle input { width: 18px; height: 18px; accent-color: var(--green); }

.ghost-btn, .solid-btn, .link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-decoration: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #1a2030;
  color: var(--text);
}
.solid-btn {
  background: linear-gradient(180deg, #3a82ff, #1f5fe0);
  border: 0;
}
.ghost-btn.is-disabled, .link-btn.is-disabled {
  pointer-events: none;
  opacity: 0.45;
}
.hint { color: var(--muted); font-size: 0.8rem; margin: 8px 0 0; }
.hint.tight { margin-top: 12px; text-align: center; }

.loc-grid { display: grid; gap: 12px; margin: 0 0 14px; }
.loc-grid dt { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.loc-grid dd { margin: 4px 0 0; font-weight: 600; word-break: break-word; }
.row-actions { display: grid; gap: 8px; }

.form { margin: 0; }
.choice {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 14px;
}
.choice legend { padding: 0 6px; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.choice label { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: #101626;
  border: 1px solid var(--line);
  color: #d7deea;
}

.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.log li {
  background: #0b0e14;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
}
.log .empty { color: var(--muted); border-style: dashed; }
.log time { display: block; color: var(--muted); font-size: 0.75rem; margin-bottom: 2px; }

.footer {
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto 36px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 22px;
  font-size: 0.86rem;
}
.footer-brand { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.footer-brand strong { display: block; color: var(--text); font-family: var(--display); margin-bottom: 4px; }
.footer-brand p, .footer-meta { margin: 0; }
.footer-meta { opacity: 0.8; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(4, 5, 8, 0.82);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 18px 14px;
  overflow: auto;
}
.overlay[hidden] { display: none !important; }
.overlay-card {
  width: min(680px, 100%);
  background: #141824;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.countdown-card { padding-top: 28px; }
.overlay-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--amber);
  margin: 0 0 8px;
}
.count-num {
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(6rem, 24vw, 9rem);
  line-height: 0.85;
  color: #fff;
}
.count-label { font-size: 1.1rem; margin: 8px 0 4px; }
.count-phrase { color: var(--muted); margin: 0 0 22px; }
.cancel-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 18px 16px;
  background: #fff;
  color: #111;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.overlay.emergency { background: rgba(40, 4, 6, 0.88); align-items: start; }
.emergency-card { text-align: left; background: #1a0d10; border-color: rgba(255, 59, 59, 0.4); }
.emergency-card.dim {
  filter: brightness(0.62);
  background: #0c0708;
}
.test-banner {
  background: var(--amber);
  color: #1a1200;
  font-weight: 800;
  text-align: center;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 0 0 12px;
  letter-spacing: 0.02em;
}
.live-kicker { color: #ff9b9b; }
.emergency-title {
  font-family: var(--cond);
  font-size: clamp(2.2rem, 10vw, 3.4rem);
  line-height: 0.9;
  text-transform: uppercase;
  margin: 0 0 8px;
  color: #fff;
  letter-spacing: 0.02em;
}
.heard { color: #ffc9c9; margin: 0 0 16px; font-weight: 600; }
.readout {
  background: #0d0708;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}
.readout h3 {
  margin: 12px 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c9b0b0;
}
.readout h3:first-child { margin-top: 0; }
.readout .big {
  font-family: var(--display);
  font-size: clamp(1.25rem, 5vw, 1.85rem);
  font-weight: 800;
  line-height: 1.15;
  margin: 0;
  color: #fff;
}
.mono { font-variant-numeric: tabular-nums; word-break: break-all; }
.preview-block {
  background: #12090b;
  border: 1px dashed rgba(255,255,255,0.16);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}
.preview-label {
  margin: 10px 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 800;
}
.preview-label:first-child { margin-top: 0; }
.sms-preview, #spokenScript, #dialerPreview { margin: 0; white-space: pre-wrap; word-break: break-word; }
#webhookPreview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  color: #d7deea;
}
.emergency-actions { display: grid; gap: 8px; }
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  border-radius: 14px;
  padding: 14px 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: #2a1518;
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1rem;
}
.action-btn.primary {
  background: linear-gradient(180deg, #ff4d4d, #d41515);
  border: 0;
  font-size: 1.15rem;
  min-height: 56px;
}
.action-btn.danger { background: #3a3f4d; }
.action-btn.is-disabled { pointer-events: none; opacity: 0.45; }

@media (min-width: 820px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
  .row-actions { grid-template-columns: 1fr 1fr; }
  main { padding-top: 28px; }
}
