:root {
  --bg: #080b0f;
  --bg-soft: #0d1218;
  --panel: #121820;
  --panel-raised: #18212b;
  --display: #0d1712;
  --border: #29333e;
  --border-strong: #3b4754;
  --text: #f4f7f9;
  --muted: #9ba9b6;
  --signal: #a8ff3e;
  --signal-dark: #75c51d;
  --alarm: #ff4d45;
  --alarm-dark: #c92f32;
  --warning: #ffb224;
  --success: #4bd28b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 50% -15%, rgba(168, 255, 62, 0.09), transparent 34%),
    var(--bg);
  background-size: 100% 4px, auto, auto;
}

body:has(dialog[open]) {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 11, 15, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 850;
  letter-spacing: -0.3px;
  text-decoration: none;
  text-transform: uppercase;
}

.brand__mark {
  padding: 5px 7px 4px;
  border-radius: 3px;
  background: var(--signal);
  color: #10160a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.8px;
}

.brand__name {
  font-size: 14px;
  letter-spacing: 1.5px;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  text-transform: uppercase;
}

.connection i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.connection[data-state="online"] {
  color: var(--signal);
}

.connection[data-state="offline"] {
  color: var(--alarm);
}

.shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px) 16px calc(30px + var(--safe-bottom));
}

.auth-card {
  width: min(540px, 100%);
  margin: 4vh auto 0;
  padding: clamp(24px, 6vw, 44px);
  border: 1px solid var(--border-strong);
  border-top: 4px solid var(--signal);
  border-radius: 4px;
  background: rgba(18, 24, 32, 0.97);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.eyebrow {
  color: var(--signal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.35px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(30px, 7vw, 49px);
  line-height: 1.02;
  letter-spacing: -1.6px;
}

h2 {
  margin-bottom: 0;
  letter-spacing: -0.5px;
}

.lead {
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.stack {
  display: grid;
  gap: 13px;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
}

.auth-switch__button {
  min-height: 42px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}

.auth-switch__button.is-active {
  background: var(--panel-raised);
  color: var(--text);
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 17px;
}

.field input:focus {
  border-color: var(--signal-dark);
  box-shadow: 0 0 0 3px rgba(168, 255, 62, 0.13);
}

.field input:disabled {
  opacity: 0.65;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button--primary,
.button--signal {
  border-color: var(--signal);
  background: var(--signal);
  color: #101609;
}

.button--primary:hover,
.button--signal:hover {
  border-color: #b9ff68;
  background: #b9ff68;
}

.button--quiet {
  min-height: 36px;
  background: transparent;
}

.message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--warning);
  font-size: 13px;
}

.privacy-note,
.install-hint {
  margin-top: 24px;
  padding: 14px;
  border-left: 3px solid var(--signal);
  background: rgba(168, 255, 62, 0.06);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.pager-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 5vw, 34px);
  border: 1px solid var(--border-strong);
  border-top: 5px solid var(--signal);
  border-radius: 5px;
  background:
    linear-gradient(125deg, rgba(168, 255, 62, 0.08), transparent 48%),
    var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.pager-hero::after {
  position: absolute;
  right: -45px;
  bottom: -75px;
  width: 190px;
  height: 190px;
  border: 1px solid rgba(168, 255, 62, 0.12);
  border-radius: 50%;
  content: "";
}

.pager-hero__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--signal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.live-indicator {
  width: 9px;
  height: 9px;
  border: 2px solid rgba(168, 255, 62, 0.3);
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 12px rgba(168, 255, 62, 0.8);
}

.welcome,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.welcome {
  position: relative;
  z-index: 1;
}

.welcome h1 {
  margin: 4px 0 7px;
  font-size: clamp(28px, 6vw, 44px);
}

.welcome p {
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
}

.pager-metrics {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) minmax(90px, 0.7fr) 1.6fr;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--display);
}

.pager-metric {
  display: grid;
  gap: 3px;
  min-height: 68px;
  align-content: center;
  padding: 11px 16px;
  border-right: 1px solid rgba(168, 255, 62, 0.13);
}

.pager-metric:last-child {
  border-right: 0;
}

.pager-metric span {
  color: #6f9674;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.pager-metric strong {
  color: var(--signal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 22px;
  letter-spacing: 0.5px;
}

.pager-metric--wide strong {
  font-size: 14px;
}

.status-row {
  margin: 18px 0 28px;
}

.status-pill {
  color: var(--muted);
  font-size: 12px;
}

.status-pill--ok {
  color: var(--success);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin-top: 3px;
  font-size: 24px;
}

.section-heading__hint {
  color: var(--muted);
  font-size: 11px;
}

.incident-list {
  display: grid;
  gap: 11px;
}

.incident-card {
  position: relative;
  display: grid;
  gap: 11px;
  width: 100%;
  overflow: hidden;
  padding: 16px 17px 15px 20px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--alarm);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.incident-card:hover {
  border-color: var(--border-strong);
  background: var(--panel-raised);
  transform: translateY(-1px);
}

.incident-card[data-state="cancelled"],
.incident-card[data-state="completed"],
.incident-card[data-state="released"] {
  border-left-color: #65717c;
  opacity: 0.72;
}

.incident-card__top,
.incident-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.incident-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.priority,
.state-badge,
.unit-badge {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.55px;
  text-transform: uppercase;
}

.priority {
  background: var(--alarm);
  color: #fff;
}

.state-badge {
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.incident-card__time {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  white-space: nowrap;
}

.incident-card__title {
  display: block;
  font-size: clamp(18px, 4vw, 23px);
  font-weight: 850;
  line-height: 1.15;
  letter-spacing: -0.45px;
}

.incident-card__body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.incident-card__number {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.6px;
}

.incident-card__address {
  display: flex;
  gap: 8px;
  align-items: start;
  color: #c6d0d9;
  font-size: 14px;
  line-height: 1.45;
}

.incident-card__address::before {
  color: var(--signal);
  content: "⌖";
  font-size: 17px;
  line-height: 1.1;
}

.unit-badge {
  border: 1px solid rgba(168, 255, 62, 0.24);
  background: rgba(168, 255, 62, 0.07);
  color: var(--signal);
}

.incident-card__open {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 56px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: 5px;
  background: rgba(18, 24, 32, 0.5);
  color: var(--muted);
  text-align: center;
}

.empty-state::before {
  color: var(--signal);
  content: "●";
  font-size: 20px;
  text-shadow: 0 0 14px rgba(168, 255, 62, 0.8);
}

.empty-state strong {
  color: var(--text);
}

.incident-dialog {
  width: min(720px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.65);
}

.incident-dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.dialog__head {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-top: 4px solid var(--alarm);
  border-bottom: 1px solid var(--border);
  background: rgba(18, 24, 32, 0.96);
  backdrop-filter: blur(16px);
}

.dialog__head h2 {
  margin: 9px 0 0;
  font-size: clamp(20px, 5vw, 28px);
  line-height: 1.12;
}

#profileDialog .dialog__head {
  border-top-color: var(--signal);
}

.dialog__kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.incident-map {
  padding: 18px 18px 0;
}

.incident-map__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.incident-map__head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.incident-map__head strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-map__viewport {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg-soft);
}

.incident-map iframe {
  display: block;
  width: 100%;
  height: 280px;
  border: 0;
  filter: saturate(0.75) contrast(1.08);
}

.map-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 7px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.map-placeholder strong {
  color: var(--text);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(130px, 0.32fr) 1fr;
  padding: 12px 18px 24px;
}

.detail-grid dt,
.detail-grid dd {
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.detail-grid dt {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.detail-grid dd {
  color: #e5ebef;
  line-height: 1.45;
}

.profile-form {
  padding: 20px 18px 24px;
}

.profile-summary {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--display);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-line;
}

@media (max-width: 620px) {
  .topbar {
    gap: 7px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .brand__name,
  .connection {
    display: none;
  }

  .brand {
    margin-right: auto;
  }

  .topbar .button {
    min-height: 35px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .shell {
    padding: 14px 10px calc(24px + var(--safe-bottom));
  }

  .auth-card {
    margin-top: 0;
    padding: 24px 18px;
  }

  .pager-hero {
    padding: 20px 16px;
  }

  .welcome {
    align-items: stretch;
    flex-direction: column;
  }

  .welcome .button {
    width: 100%;
  }

  .pager-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .pager-metric:nth-child(2) {
    border-right: 0;
  }

  .pager-metric--wide {
    grid-column: 1 / -1;
    border-top: 1px solid rgba(168, 255, 62, 0.13);
  }

  .status-row {
    align-items: start;
  }

  .status-row .button {
    flex: 0 0 auto;
  }

  .section-heading__hint {
    display: none;
  }

  .incident-card {
    padding: 15px 14px 14px 16px;
  }

  .incident-dialog {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .dialog__head {
    padding: max(14px, env(safe-area-inset-top)) 14px 14px;
  }

  .dialog__head .button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .incident-map {
    padding: 14px 12px 0;
  }

  .incident-map__head {
    align-items: stretch;
    flex-direction: column;
  }

  .incident-map__head strong {
    white-space: normal;
  }

  .incident-map__viewport,
  .incident-map iframe {
    min-height: 245px;
    height: 245px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    padding: 10px 14px calc(28px + var(--safe-bottom));
  }

  .detail-grid dt {
    padding-bottom: 3px;
    border-bottom: 0;
  }

  .detail-grid dd {
    padding-top: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
