:root {
  --bg: #0b1220;
  --bg2: #121a2b;
  --card: rgba(18, 28, 48, 0.92);
  --border: rgba(148, 163, 184, 0.18);
  --text: #e8eef8;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --ok: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;
  --font: Inter, system-ui, sans-serif;
  --display: Oswald, Inter, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, #1e3a5f 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
}

/* ---------- PIN gate ---------- */
.pin-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.pin-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.pin-logo { width: 120px; height: auto; margin-bottom: .75rem; border-radius: 8px; }
.pin-card h1 {
  font-family: var(--display);
  font-size: 1.6rem;
  margin: 0 0 .35rem;
  letter-spacing: .04em;
}
.pin-sub { color: var(--muted); margin: 0 0 1.25rem; font-size: .95rem; }
#pin-form { display: flex; gap: .5rem; }
#pin-input {
  flex: 1;
  padding: .75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0a1020;
  color: var(--text);
  font-size: 1.1rem;
  letter-spacing: .2em;
  text-align: center;
}
#pin-form button {
  padding: .75rem 1.1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #041018;
  font-weight: 700;
  cursor: pointer;
}
.pin-error { color: #fca5a5; margin: .75rem 0 0; font-size: .9rem; }

/* ---------- App shell ---------- */
.esd-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 1rem 1rem;
}
.esd-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 .75rem;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-logo { height: 64px; width: auto; border-radius: 6px; }
.brand-kicker {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}
.brand-title {
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: .03em;
}
.header-meta { margin-left: auto; text-align: right; }
.clock { font-family: var(--display); font-size: 1.6rem; letter-spacing: .04em; }
.last-updated { color: var(--muted); font-size: .8rem; }

.fire-danger {
  padding: .45rem .9rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .95rem;
}
.fire-danger-low { background: #15803d; color: #fff; }
.fire-danger-moderate { background: #1d4ed8; color: #fff; }
.fire-danger-high { background: #ca8a04; color: #111; }
.fire-danger-veryhigh { background: #ea580c; color: #fff; }
.fire-danger-extreme { background: #b91c1c; color: #fff; }


.esd-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  overflow: hidden;
}
.card-wide { grid-column: 1 / -1; min-height: 200px; }
.card h2 {
  margin: 0;
  padding: .75rem 1rem;
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  color: #cbd5e1;
}
.card-body {
  flex: 1;
  padding: .85rem 1rem;
  overflow: auto;
  max-height: 42vh;
}
.card-wide .card-body { max-height: 36vh; }

.loading, .empty { color: var(--muted); margin: 0; }
.row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .35rem 0;
  border-bottom: 1px solid rgba(148,163,184,.1);
}
.row:last-child { border-bottom: none; }
.muted { color: var(--muted); font-size: .9rem; }
.section-title {
  color: var(--accent);
  font-weight: 700;
  margin: .65rem 0 .35rem;
}
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-assigned, .badge-dispatched { background: #64748b; color: #fff; }
.badge-enroute { background: #ca8a04; color: #111; }
.badge-on_scene { background: #2563eb; color: #fff; }
.badge-clear { background: #f8fafc; color: #0f172a; }
.badge-in { background: #16a34a; color: #fff; }
.badge-out { background: #dc2626; color: #fff; }

.incident-item { padding: .5rem 0; border-bottom: 1px solid rgba(148,163,184,.12); }
.incident-item:last-child { border-bottom: none; }
.incident-type { font-weight: 700; color: #f8fafc; }
.incident-meta { color: var(--muted); font-size: .88rem; margin-top: .15rem; }

.esd-footer {
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
  padding: .85rem 0 .25rem;
}

@media (max-width: 900px) {
  .esd-grid { grid-template-columns: 1fr; }
  .card-wide { grid-column: auto; }
  .card-body { max-height: none; }
}


/* Message photos */
.msg-photo {
  display: block;
  max-width: 100%;
  max-height: 220px;
  width: auto;
  height: auto;
  margin-top: 0.5rem;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.message-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  cursor: pointer;
}
.message-lightbox img {
  max-width: min(96vw, 900px);
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}
