:root {
  color-scheme: dark;
  --bg: #09111f;
  --bg-soft: rgba(10, 19, 34, 0.75);
  --surface: rgba(10, 19, 34, 0.82);
  --surface-strong: rgba(16, 28, 48, 0.96);
  --surface-alt: rgba(255, 255, 255, 0.08);
  --border: rgba(128, 154, 188, 0.28);
  --text: #f4f7fb;
  --muted: #adc1d5;
  --title: #ffffff;
  --accent: #5be7c4;
  --accent-strong: #1ecfa4;
  --danger: #ff6b63;
  --urgent: #ffb45c;
  --routine: #4fd281;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.26);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-display: "Space Grotesk", "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --font-body: "Noto Sans", "Noto Sans Devanagari", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f7;
  --bg-soft: rgba(255, 255, 255, 0.8);
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: rgba(255, 255, 255, 0.98);
  --surface-alt: rgba(12, 27, 48, 0.04);
  --border: rgba(28, 58, 95, 0.16);
  --text: #142236;
  --muted: #52657d;
  --title: #0c1930;
  --accent: #007f72;
  --accent-strong: #03655b;
  --danger: #c83d38;
  --urgent: #cb7a00;
  --routine: #137b48;
  --shadow: 0 24px 60px rgba(19, 37, 61, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  background:
    radial-gradient(circle at top left, rgba(91, 231, 196, 0.18), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(255, 180, 92, 0.14), transparent 24%),
    linear-gradient(180deg, rgba(9, 17, 31, 1) 0%, rgba(4, 10, 19, 1) 100%);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at top left, rgba(0, 127, 114, 0.12), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(203, 122, 0, 0.08), transparent 22%),
    linear-gradient(180deg, #f9fbfd 0%, #edf2f7 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
}

.background-orb {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(90px);
  opacity: 0.38;
}

.background-orb-a {
  inset: 4rem auto auto 6%;
  width: 18rem;
  height: 18rem;
  background: rgba(91, 231, 196, 0.26);
}

.background-orb-b {
  inset: auto 8% 12% auto;
  width: 14rem;
  height: 14rem;
  background: rgba(255, 107, 99, 0.22);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 1.25rem));
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  display: grid;
  gap: 1.25rem;
  padding: 1.4rem;
}

.eyebrow,
.section-label,
.badge,
.agent-tag,
.urgency-chip,
.urgency-pill {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
}

.hero-copy h1,
.card-heading h2,
.triage-result h3,
.facility-item h3 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--title);
}

.hero-copy h1 {
  font-size: clamp(2.2rem, 7vw, 4.4rem);
  line-height: 0.95;
  margin-top: 0.3rem;
}

.hero-text,
.modal-copy,
.details-content p,
.disclaimer,
.footer-note,
.facility-message,
.history-action {
  color: var(--muted);
}

.hero-actions,
.settings-actions,
.action-row,
.emergency-actions,
.field-grid {
  display: grid;
  gap: 0.75rem;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.badge,
.agent-tag,
.urgency-pill,
.urgency-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 0.5rem 0.75rem;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  padding: 0.92rem 1.1rem;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
  text-decoration: none;
  text-align: center;
}

.button:hover:not(:disabled),
.button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #041019;
  box-shadow: 0 16px 32px rgba(30, 207, 164, 0.24);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

:root[data-theme="light"] .button-secondary {
  background: rgba(12, 25, 48, 0.04);
}

.button-danger {
  background: linear-gradient(135deg, #ff8a72, var(--danger));
  color: #fff;
}

.button-small {
  padding: 0.7rem 0.95rem;
  font-size: 0.9rem;
}

.details-card {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
}

.deployment-notice {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1.15rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(91, 231, 196, 0.28);
  background:
    linear-gradient(135deg, rgba(91, 231, 196, 0.12), rgba(0, 127, 114, 0.08)),
    var(--surface);
}

.deployment-notice.hidden {
  display: none;
}

.deployment-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
}

.deployment-notice h2,
.deployment-notice p {
  margin: 0.3rem 0 0;
}

.details-card summary,
.history-card details summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--title);
}

.details-content {
  padding-top: 0.9rem;
}

.pipeline-list {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.form-card,
.result-card-shell,
.map-card,
.history-card {
  padding: 1.15rem;
}

.card-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.triage-form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field span {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--title);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--text);
  padding: 0.95rem 1rem;
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 9rem;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(91, 231, 196, 0.62);
  box-shadow: 0 0 0 3px rgba(91, 231, 196, 0.16);
}

.status-message,
.disclaimer {
  margin: 0;
  font-size: 0.95rem;
}

.triage-result {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  min-height: 18rem;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
}

.triage-result.empty {
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.placeholder-title {
  color: var(--title);
  font-weight: 700;
}

.triage-result.emergency {
  border-color: rgba(255, 107, 99, 0.42);
  background: linear-gradient(180deg, rgba(255, 107, 99, 0.18), rgba(255, 107, 99, 0.06));
}

.triage-result.urgent {
  border-color: rgba(255, 180, 92, 0.38);
  background: linear-gradient(180deg, rgba(255, 180, 92, 0.18), rgba(255, 180, 92, 0.06));
}

.triage-result.routine {
  border-color: rgba(79, 210, 129, 0.38);
  background: linear-gradient(180deg, rgba(79, 210, 129, 0.18), rgba(79, 210, 129, 0.06));
}

.urgency-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.result-grid {
  display: grid;
  gap: 1rem;
}

.triage-result article + article {
  margin-top: 1rem;
}

.triage-result ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.triage-result h4 {
  margin: 0;
  color: var(--title);
}

.triage-result p {
  margin: 0.4rem 0 0;
}

.fallback-note {
  margin-top: 1rem;
  border-left: 3px solid rgba(255, 255, 255, 0.18);
  padding-left: 0.85rem;
  color: var(--muted);
}

.map-panel {
  width: 100%;
  min-height: 18rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.facility-message {
  margin: 0.9rem 0 0.2rem;
}

.facility-list,
.history-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.9rem;
}

.facility-item,
.history-item {
  display: grid;
  gap: 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 0.95rem;
}

.facility-item p,
.history-item p {
  margin: 0.3rem 0 0;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.urgency-chip.emergency,
.urgency-pill {
  color: var(--title);
}

.urgency-chip.emergency {
  border-color: rgba(255, 107, 99, 0.35);
  background: rgba(255, 107, 99, 0.15);
}

.urgency-chip.urgent {
  border-color: rgba(255, 180, 92, 0.35);
  background: rgba(255, 180, 92, 0.14);
}

.urgency-chip.routine {
  border-color: rgba(79, 210, 129, 0.35);
  background: rgba(79, 210, 129, 0.15);
}

.empty-list {
  margin: 0;
  color: var(--muted);
}

.emergency-banner {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1.15rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 107, 99, 0.3);
  background:
    linear-gradient(135deg, rgba(255, 107, 99, 0.28), rgba(110, 14, 14, 0.2)),
    rgba(71, 8, 8, 0.72);
}

.emergency-banner.hidden {
  display: none;
}

.emergency-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
}

.emergency-banner h2 {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
}

.emergency-banner p {
  margin: 0.45rem 0 0;
}

.footer-note {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.92rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(2, 6, 12, 0.72);
  z-index: 30;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-card {
  width: min(34rem, 100%);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.modal-footnote {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.noscript-banner {
  padding: 0.8rem 1rem;
  background: #ffefe8;
  color: #5b140d;
  text-align: center;
  font-weight: 700;
}

@media (min-width: 720px) {
  .hero-card {
    grid-template-columns: 1.45fr 0.8fr;
    align-items: end;
    padding: 1.6rem;
  }

  .hero-actions {
    align-self: stretch;
    align-content: end;
  }

  .field-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .action-row,
  .settings-actions,
  .emergency-actions,
  .facility-item {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
  }

  .dashboard-grid {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .form-card {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .result-card-shell {
    grid-column: 2;
  }

  .map-card {
    grid-column: 2;
  }

  .history-card {
    grid-column: 1 / span 2;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .emergency-banner {
    grid-template-columns: 1.2fr auto;
    align-items: center;
  }

  .deployment-notice {
    grid-template-columns: 1.2fr auto;
    align-items: center;
  }
}

@media (max-width: 719px) {
  .app-shell {
    width: min(100% - 1rem, 100%);
  }

  .hero-card,
  .details-card,
  .form-card,
  .result-card-shell,
  .map-card,
  .history-card,
  .emergency-banner {
    border-radius: 24px;
  }
}
