:root {
  color-scheme: light;
  --panel: rgba(255, 253, 248, 0.94);
  --panel-border: rgba(106, 89, 58, 0.12);
  --text: #221d17;
  --muted: #675c50;
  --primary: #284f44;
  --primary-strong: #1d3931;
  --accent: #e96b3a;
  --accent-soft: rgba(233, 107, 58, 0.14);
  --shadow: 0 18px 44px rgba(67, 56, 37, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --surface: rgba(255, 255, 255, 0.84);
  --dropdown-bg: rgb(255, 253, 248);
  --dropdown-border: rgba(106, 89, 58, 0.14);
  --dropdown-shadow: 0 18px 36px rgba(64, 53, 35, 0.15);
  --hero-accent: rgba(40, 79, 68, 0.08);
  --toast-bg: rgba(24, 61, 50, 0.96);
  --soft-surface: rgba(34, 29, 23, 0.06);
  --summary-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(249, 244, 235, 0.96));
  --map-shell: rgba(246, 241, 231, 0.9);
  --map-base: #f0e8d8;
  --map-fallback-bg: linear-gradient(180deg, #f6f1e6 0%, #efe5d4 100%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --panel: rgba(21, 26, 31, 0.9);
  --panel-border: rgba(179, 196, 190, 0.12);
  --text: #eef1ec;
  --muted: #aeb8b0;
  --primary: #85c0ab;
  --primary-strong: #5b8f7c;
  --accent: #ff9959;
  --accent-soft: rgba(255, 153, 89, 0.18);
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.32);
  --surface: rgba(16, 20, 24, 0.9);
  --dropdown-bg: rgb(10, 14, 18);
  --dropdown-border: rgba(133, 192, 171, 0.24);
  --dropdown-shadow: 0 24px 44px rgba(0, 0, 0, 0.44);
  --hero-accent: rgba(133, 192, 171, 0.12);
  --toast-bg: rgba(18, 24, 29, 0.96);
  --soft-surface: rgba(255, 255, 255, 0.08);
  --summary-bg: linear-gradient(180deg, rgba(27, 34, 40, 0.92), rgba(16, 21, 26, 0.98));
  --map-shell: rgba(16, 21, 26, 0.92);
  --map-base: #151d23;
  --map-fallback-bg: linear-gradient(180deg, #1a2228 0%, #12181d 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Roboto Condensed", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(196, 222, 177, 0.62), transparent 28%),
    radial-gradient(circle at top right, rgba(239, 209, 157, 0.54), transparent 30%),
    linear-gradient(180deg, #f7f3eb 0%, #f0ebe0 100%);
  transition: background 0.25s ease, color 0.25s ease;
}

body.modal-open {
  overflow: hidden;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(36, 69, 60, 0.55), transparent 28%),
    radial-gradient(circle at top right, rgba(115, 75, 49, 0.35), transparent 30%),
    linear-gradient(180deg, #11171b 0%, #0b1115 100%);
}

button,
input,
select {
  font: inherit;
}

code {
  font-family: inherit;
  font-weight: 700;
}

.page-shell {
  width: min(100% - 20px, 100%);
  margin: 0 auto;
  padding: 16px 0 92px;
}

.hero,
.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.hero {
  margin-bottom: 14px;
}

.hero-copy,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: 24px;
  padding: 18px;
}

.hero-topbar {
  display: contents;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 16px;
  right: 10px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  z-index: 60;
  box-shadow: 0 14px 28px rgba(20, 18, 16, 0.18);
}

.icon-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--hero-accent);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 14px 0 10px;
  font-size: clamp(1.85rem, 8vw, 2.8rem);
  line-height: 0.96;
}

.clinic-note {
  margin-bottom: -5px;
  max-width: 900px;
  color: #999 !important;
  font-size: 0.9rem;
  line-height: 1.4;
  font-weight: 400;
}

.hero p,
.section-heading p,
.route-summary p,
.suggestion-meta,
.map-fallback span,
.scanner-head p,
.scanner-status {
  color: var(--muted);
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

.section-heading p {
  margin: 0;
}

.route-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-grid {
  display: grid;
  gap: 16px;
}

.search-field {
  position: relative;
}

.search-field label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
}

.combo {
  position: relative;
}

.combo input {
  width: 100%;
  height: 56px;
  padding: 0 48px 0 16px;
  border: 1px solid rgba(34, 29, 23, 0.1);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.combo input:focus {
  outline: none;
  border-color: rgba(40, 79, 68, 0.4);
  box-shadow: 0 0 0 4px rgba(40, 79, 68, 0.1);
}

.clear-btn {
  position: absolute;
  top: 50%;
  right: 12px;
  translate: 0 -50%;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--soft-surface);
  color: var(--muted);
  cursor: pointer;
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border-radius: 20px;
  border: 1px solid var(--dropdown-border);
  background: var(--dropdown-bg);
  backdrop-filter: none;
  box-shadow: var(--dropdown-shadow);
  z-index: 10;
}

.dropdown.open {
  display: block;
}

.suggestion {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: left;
  padding: 13px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

.suggestion:hover,
.suggestion:focus-visible {
  background: var(--hero-accent);
  transform: translateY(-1px);
  outline: none;
}

.suggestion-title {
  font-weight: 700;
}

.actions,
.qr-actions,
.scanner-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.camera-select {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid rgba(34, 29, 23, 0.12);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.primary-btn,
.ghost-btn,
.scan-qr-btn {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
}

.ghost-btn {
  background: var(--soft-surface);
  color: var(--text);
}

:root[data-theme="dark"] .ghost-btn,
:root[data-theme="dark"] .clear-btn,
:root[data-theme="dark"] .icon-btn {
  background: var(--soft-surface);
}

.route-summary {
  margin-top: 18px;
  padding: 16px;
  border-radius: 22px;
  background: var(--summary-bg);
  border: 1px solid rgba(34, 29, 23, 0.08);
}

.route-summary.empty {
  border-style: dashed;
}

.route-summary h3,
.route-summary h4,
.route-summary ul {
  margin: 0;
}

.route-summary .route-head {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.route-summary .route-badge {
  justify-self: start;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.route-summary .route-points {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.route-summary .route-point {
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--hero-accent);
}

.route-summary .route-point strong {
  display: block;
  margin-bottom: 4px;
}

.route-summary .route-steps {
  display: grid;
  gap: 10px;
  padding-left: 18px;
  margin-top: 10px;
}

.route-summary .route-steps li {
  color: var(--muted);
}

.desktop-only {
  display: none;
}

.map-panel {
  display: grid;
  gap: 18px;
}

.map-wrapper {
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(34, 29, 23, 0.08);
  background: var(--map-shell);
  cursor: zoom-in;
}

.map-image-shell {
  position: relative;
  aspect-ratio: 1388 / 690;
  background: var(--map-base);
}

.map-wrapper:focus-visible {
  outline: 3px solid rgba(40, 79, 68, 0.34);
  outline-offset: 4px;
}

.map-base-image,
#campus-map,
.map-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-base-image {
  display: none;
  object-fit: cover;
  z-index: 1;
}

#campus-map {
  pointer-events: none;
  z-index: 2;
}

.map-fallback {
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(196, 222, 177, 0.45), transparent 25%),
    radial-gradient(circle at 80% 10%, rgba(239, 209, 157, 0.4), transparent 26%),
    var(--map-fallback-bg);
  z-index: 3;
}

.map-fallback[hidden] {
  display: none;
}

.qr-panel {
  padding: 18px;
  border-radius: 24px;
  background: var(--summary-bg);
  border: 1px solid rgba(34, 29, 23, 0.08);
}

.qr-state {
  padding: 14px;
  border-radius: 18px;
  background: var(--hero-accent);
  margin-bottom: 14px;
}

.qr-state p {
  margin: 0;
}

.qr-preview-wrap {
  display: grid;
  place-items: center;
  min-height: 220px;
  margin-bottom: 14px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid rgba(34, 29, 23, 0.08);
}

.qr-preview {
  width: min(100%, 240px);
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 16px;
}

.route-line {
  fill: none;
  stroke: #e96b3a;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
  marker-end: url(#route-arrow);
}

.route-halo {
  fill: none;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 22;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-marker circle {
  stroke: rgba(255, 255, 255, 0.96);
  stroke-width: 6;
}

.map-marker text {
  font-size: 16px;
  font-weight: 800;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: middle;
}

.map-marker.start circle {
  fill: #2c6b5d;
}

.map-marker.end circle {
  fill: #e96b3a;
}

.scan-qr-btn {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: 420px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  box-shadow: 0 16px 34px rgba(29, 57, 49, 0.28);
  z-index: 30;
}

.scan-file-input-native {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  clip: rect(0 0 0 0);
  clip-path: inset(100%);
}

.scanner-dialog {
  width: min(100% - 20px, 520px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
}

.scanner-dialog::backdrop {
  background: rgba(20, 18, 16, 0.56);
  backdrop-filter: blur(6px);
}

.scanner-sheet {
  background: var(--panel);
  border: 1px solid rgba(34, 29, 23, 0.08);
  border-radius: 28px;
  padding: 18px;
  box-shadow: 0 24px 56px rgba(20, 18, 16, 0.24);
}

.scanner-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.scanner-head h2,
.scanner-head p {
  margin: 0;
}

.scanner-close {
  position: static;
  translate: none;
  flex-shrink: 0;
}

.scanner-stage {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: #0d1714;
  aspect-ratio: 1 / 1;
}

.scanner-reader,
.scanner-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-reader {
  position: absolute;
  inset: 0;
}

.scanner-reader video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-reader__hint {
  position: absolute;
  inset: auto 16px 16px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(9, 18, 15, 0.72);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  text-align: center;
  z-index: 2;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scanner-frame {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(62vw, 220px);
  height: min(62vw, 220px);
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 28px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.18);
}

.scanner-status {
  margin: 14px 0 0;
  min-height: 44px;
}

.scan-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(12px);
  width: min(calc(100% - 24px), 420px);
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--toast-bg);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 18px 40px rgba(16, 31, 27, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 45;
}

.settings-dialog {
  width: min(100% - 20px, 520px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
}

.map-zoom-dialog {
  width: min(100% - 18px, 1180px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
}

.map-zoom-dialog::backdrop {
  background: rgba(6, 10, 14, 0.72);
  backdrop-filter: blur(8px);
}

.map-zoom-sheet {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.map-zoom-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.map-zoom-head h2,
.map-zoom-head p {
  margin: 0;
}

.map-zoom-head p {
  margin-top: 6px;
  color: var(--muted);
}

.map-zoom-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.map-zoom-toolbar .settings-action {
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.95rem;
}

.map-zoom-stage {
  overflow: auto;
  max-height: min(70vh, 860px);
  border-radius: 22px;
  background: var(--map-base);
  border: 1px solid var(--panel-border);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: block;
}

.map-zoom-canvas {
  position: relative;
  width: 1388px;
  height: 690px;
  min-width: 1388px;
  min-height: 690px;
  transition: width 0.18s ease, height 0.18s ease;
}

.map-zoom-canvas .map-image-shell {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

.map-zoom-canvas .map-base-image {
  display: block;
}

.settings-dialog::backdrop {
  background: rgba(20, 18, 16, 0.56);
  backdrop-filter: blur(6px);
}

.settings-sheet {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.settings-head,
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-head {
  margin-bottom: 18px;
}

.settings-head h2,
.settings-row strong {
  margin: 0;
}

.settings-head p,
.settings-row p,
.settings-status {
  margin: 6px 0 0;
  color: var(--muted);
}

.settings-group {
  display: grid;
  gap: 14px;
}

.settings-row {
  padding: 14px;
  border-radius: 18px;
  background: rgba(34, 29, 23, 0.05);
}

:root[data-theme="dark"] .settings-row {
  background: rgba(255, 255, 255, 0.06);
}

.settings-action {
  min-width: 140px;
}

.settings-status {
  min-height: 22px;
  margin-top: 14px;
}

.scan-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 700px) {
  .icon-btn {
    top: 22px;
    right: 16px;
  }

  .page-shell {
    width: min(100% - 32px, 960px);
    padding-top: 22px;
  }

  .actions,
  .qr-actions {
    grid-template-columns: 1fr 1fr;
  }

  .route-summary .route-head {
    grid-template-columns: 1fr auto;
    align-items: start;
  }
}

@media (min-width: 1100px) {
  .icon-btn {
    top: 28px;
    right: 22px;
  }

  .page-shell {
    width: min(1380px, calc(100% - 44px));
    padding: 28px 0 40px;
  }

  .hero-copy,
  .panel {
    border-radius: 30px;
    padding: 24px;
  }

  .dashboard {
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    gap: 22px;
    align-items: stretch;
  }

  .controls-panel,
  .map-panel {
    min-height: 100%;
  }

  .map-panel {
    grid-template-rows: auto minmax(420px, 1fr) auto;
  }

  .map-wrapper {
    height: 100%;
    min-height: 520px;
    border-radius: 30px;
  }

  .desktop-only {
    display: block;
  }

  .scan-qr-btn {
    display: none;
  }

  .scan-toast {
    bottom: 28px;
  }
}
