:root {
  --bg: #f9fafc;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-2: #f3f4f8;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-2: rgba(255, 255, 255, 0.86);
  --accent: #d7263d;
  --accent-2: #b3122d;
  --accent-soft: rgba(215, 38, 61, 0.12);
  --text: #161823;
  --muted: #5d6673;
  --danger: #d7263d;
  --warn: #f08c42;
  --ok: #2ca46f;
  --border: rgba(22, 24, 35, 0.1);
  --border-strong: rgba(22, 24, 35, 0.16);
  --ghost: rgba(22, 24, 35, 0.05);
  --ghost-border: rgba(22, 24, 35, 0.12);
  --input-bg: #ffffff;
  --input-border: rgba(22, 24, 35, 0.16);
  --shadow: 0 14px 50px rgba(15, 18, 32, 0.12);
  --radius: 14px;
}

:root[data-theme="night"] {
  --bg: #0e0b11;
  --bg-2: #140f18;
  --card: #14121b;
  --card-2: #1b1722;
  --panel: rgba(20, 18, 27, 0.94);
  --panel-2: rgba(20, 18, 27, 0.86);
  --accent: #ff4d5a;
  --accent-2: #d7263d;
  --accent-soft: rgba(255, 77, 90, 0.18);
  --text: #f6f7fb;
  --muted: #b3b9c6;
  --danger: #ff7f6a;
  --warn: #f3c969;
  --ok: #6ff7a7;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --ghost: rgba(255, 255, 255, 0.06);
  --ghost-border: rgba(255, 255, 255, 0.12);
  --input-bg: #0f0c14;
  --input-border: rgba(255, 255, 255, 0.12);
  --shadow: 0 14px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at 18% 20%, rgba(215, 38, 61, 0.08), transparent 32%),
    radial-gradient(circle at 82% 18%, rgba(179, 18, 45, 0.08), transparent 36%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 36%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.2s ease;
}

.page {
  width: min(1200px, 94vw);
  margin: 32px auto 64px;
}

.hub {
  min-height: 60vh;
}

.hub-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.hub-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.hub .cta {
  min-width: 160px;
  text-align: center;
}

.hub .ghost-btn {
  min-width: 160px;
  text-align: center;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(215, 38, 61, 0.35);
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-sub {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--ghost);
  color: var(--text);
  border: 1px solid var(--ghost-border);
  font-size: 13px;
}

.pill.online {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: rgba(215, 38, 61, 0.24);
}

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

.pill.ghost {
  background: transparent;
  border-color: var(--ghost-border);
}

.pill.severity-high {
  background: rgba(215, 38, 61, 0.14);
  border-color: rgba(215, 38, 61, 0.45);
  color: var(--accent-2);
}

.pill.severity-med {
  background: rgba(243, 201, 105, 0.14);
  border-color: rgba(243, 201, 105, 0.5);
  color: #b57405;
}

.pill.severity-low {
  background: rgba(111, 247, 167, 0.14);
  border-color: rgba(111, 247, 167, 0.5);
  color: #1f7c4c;
}
.grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 18px;
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.panel.wide {
  padding: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 4px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 18px;
}

.lede {
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
}

.meta {
  display: flex;
  gap: 16px;
}

.lang-switch {
  display: grid;
  gap: 4px;
  align-items: center;
}

.lang-switch label {
  color: var(--muted);
  font-size: 12px;
}

.lang-switch select {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 8px 10px;
}

.meta-item {
  display: grid;
  gap: 4px;
}

.meta .label {
  color: var(--muted);
  font-size: 12px;
}

.meta .value {
  font-weight: 600;
}

.intake {
  display: grid;
  grid-template-columns: 1fr 0.9fr;
  gap: 18px;
  margin-top: 18px;
}

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: inset 0 1px 0 var(--border);
}

.row.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
}

.field select {
  width: 100%;
  padding: 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
}

.cta {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(215, 38, 61, 0.18);
}

.cta.small {
  padding: 9px 14px;
  font-size: 13px;
}

.cta:hover {
  transform: translateY(-1px);
}

.result {
  border-color: var(--accent-soft);
}

.result-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}

.result-text {
  color: var(--muted);
  line-height: 1.4;
}

.features {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.feature {
  padding: 10px 12px;
  background: var(--ghost);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.feature .label {
  color: var(--muted);
  font-size: 12px;
}

.feature .value {
  font-weight: 600;
}

.item.clickable {
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--ghost);
}

.item.clickable:hover {
  border-color: rgba(215, 38, 61, 0.35);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  width: min(520px, 90vw);
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body .meta-line {
  margin: 4px 0;
}

.modal-sbar-block {
  width: 100%;
}

.sbar-blocks {
  display: grid;
  gap: 10px;
}

.sbar-item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(215, 38, 61, 0.22);
  background: var(--accent-soft);
}

.sbar-label {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 700;
  margin-bottom: 4px;
}

.sbar-body {
  color: var(--text);
  line-height: 1.5;
  font-weight: 500;
}

.sbar-key {
  color: var(--accent);
  font-weight: 700;
}

.clarifying-card .meta-line {
  color: var(--muted);
}

.questions-modal {
  margin-top: 8px;
}

.questions {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.questions .question-item.interactive {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.question-text {
  flex: 1;
}

.answer-controls {
  display: flex;
  gap: 6px;
}

.answer-pill.active {
  border-color: rgba(215, 38, 61, 0.35);
  background: var(--accent-soft);
}

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

.clarify-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.questions .title {
  font-weight: 600;
  font-size: 13px;
}

.question-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--ghost);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 13px;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.maps-panel .map-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
}

.map-canvas {
  position: relative;
  min-height: 360px;
  height: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: radial-gradient(circle at 22% 20%, var(--accent-soft), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(0, 0, 0, 0.04), transparent 34%),
    var(--card-2);
  box-shadow: inset 0 1px 0 var(--border);
}

.map-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

#map > div {
  border-radius: var(--radius);
}

.places-scroll {
  max-height: 360px;
  overflow: auto;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  filter: saturate(1.1);
}

.ghost-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--ghost-border);
  background: var(--ghost);
  color: var(--text);
  cursor: pointer;
}

.ghost-btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

.ghost-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

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

.list {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  background: var(--ghost);
  border: 1px solid var(--border);
}

.item .title {
  font-weight: 600;
}

#incoming-list .title {
  color: var(--accent);
}

.item .meta-line {
  color: var(--muted);
  font-size: 13px;
}

.align-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge.er {
  background: rgba(255, 127, 106, 0.12);
  border-color: rgba(255, 127, 106, 0.4);
  color: #ffc2b8;
}

.badge.urgent_care {
  background: rgba(243, 201, 105, 0.12);
  border-color: rgba(243, 201, 105, 0.4);
  color: #ffe5aa;
}

.badge.telehealth {
  background: rgba(111, 247, 167, 0.12);
  border-color: rgba(111, 247, 167, 0.4);
  color: #c1ffd8;
}

.list.compact .item {
  grid-template-columns: 1fr;
  align-items: flex-start;
  gap: 6px;
}

.list.compact .distance {
  color: var(--muted);
  font-size: 12px;
}

.places-scroll .card-head {
  position: sticky;
  top: 0;
  background: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  z-index: 1;
}

.bar {
  margin: 8px 0;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--ghost);
  overflow: hidden;
}

.bar-fill {
  height: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 30%;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.forecast-card {
  padding: 12px;
  border-radius: 10px;
  background: var(--ghost);
  border: 1px solid var(--border);
}

.forecast-card .label {
  color: var(--muted);
  font-size: 12px;
}

.forecast-card .value {
  font-size: 24px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .panel-header {
    flex-direction: column;
  }
  .intake {
    grid-template-columns: 1fr;
  }
  .meta {
    width: 100%;
  }
  .meta-item {
    width: 100%;
  }
  .maps-panel .map-grid {
    grid-template-columns: 1fr;
  }
}
