/* Palette matches the RouteNest Android app (common/Theme.kt). */
:root {
  color-scheme: light;
  --bg: #eaf9fc;
  --panel: #ffffff;
  --panel-2: #f3f6f9;
  --text: #161513;
  --muted: #5f6670;
  --line: #dde5ec;
  --primary: #073477;
  --primary-container: #e8f4fc;
  --header-start: #073477;
  --header-end: #008b9e;
  --gold: #c4a35a;
  --good-bg: #073477;
  --warn-bg: #f6edd9;
  --warn-text: #7a4f0e;
  --ok-text: #0b5d2a;
  --bad: #8c2f24;
  --bad-bg: #f9e3df;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.shell {
  --gutter: max(16px, calc((100% - 980px) / 2));
  padding: 0 0 32px;
}
.shell > :not(.hero) { margin-left: var(--gutter); margin-right: var(--gutter); }

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 22px;
  padding: 28px var(--gutter);
  background: linear-gradient(90deg, var(--header-start), var(--header-end));
  color: #ffffff;
}

.eyebrow {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.card .eyebrow { color: var(--muted); }

h1, h2 { margin: 0; line-height: 1.1; }
h1 { font-size: clamp(1.8rem, 5vw, 3rem); max-width: 820px; }
h2 { font-size: clamp(1.5rem, 4vw, 2.2rem); }
.lead { color: rgba(255, 255, 255, 0.85); max-width: 660px; font-size: 1.02rem; line-height: 1.6; margin-bottom: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.shell > .login-card { max-width: 560px; }
label { display: block; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.code-row { display: flex; gap: 10px; }
input {
  flex: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  padding: 13px 16px;
  outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(7, 52, 119, 0.15); }
button, .ghost {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  min-height: 48px;
  padding: 0 20px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button { background: var(--primary); color: #ffffff; }
button:focus-visible, .ghost:focus-visible { outline: 3px solid var(--header-end); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: 0.66; }
.ghost { background: var(--panel); color: var(--primary); border: 1px solid var(--line); }
.hero .ghost { background: rgba(255, 255, 255, 0.14); color: #ffffff; border-color: rgba(255, 255, 255, 0.5); }
.hint, .muted { color: var(--muted); }
.hint { line-height: 1.5; margin-bottom: 0; }

.status-row, .actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.badge {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
}
.badge.live { color: #ffffff; background: var(--good-bg); }
.badge.stale { color: var(--warn-text); background: var(--warn-bg); }
.badge.idle { color: var(--muted); background: var(--panel-2); }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 12px;
}
.metrics div {
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.metrics span { color: var(--muted); display: block; font-size: 0.82rem; margin-bottom: 6px; }
.metrics strong { font-size: 1.05rem; }
.route-text { color: var(--muted); min-height: 1.4em; }

.map-box {
  position: relative;
  width: 100%;
  height: min(62vh, 560px);
  min-height: 330px;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
}
iframe { width: 100%; height: 100%; border: 0; }
.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}
.actions { margin-top: 14px; }
.actions > :last-child { margin-left: auto; }

/* ---- Full-screen map */
.map-fab {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}
.map-fab:hover { transform: scale(1.06); }
.map-fab:active { transform: scale(0.94); }
.map-fab svg, .map-overlay svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.map-overlay svg .fill { fill: currentColor; stroke: none; }

html.map-locked, html.map-locked body { overflow: hidden; overscroll-behavior: none; }

.map-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000000;
  transform-origin: 0 0;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  --safe-left: max(12px, env(safe-area-inset-left));
  --safe-right: max(12px, env(safe-area-inset-right));
}
.map-overlay:fullscreen { width: 100vw; height: 100vh; }
.map-overlay::backdrop { background: #000000; }
.map-overlay iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

.fs-chrome {
  position: absolute;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.55s cubic-bezier(0.34, 1.45, 0.5, 1);
}
.fs-tools { transform: translateY(-24px) scale(0.94); }
.fs-sheet { transform: translateY(36px) scale(0.96); }
.map-overlay.open .fs-chrome { opacity: 1; transform: none; transition-delay: 0.12s; }
.map-overlay.closing .fs-chrome { transition-duration: 0.14s; transition-delay: 0s; }

.fs-tools, .fs-sheet {
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
  color: var(--text);
}
.fs-circle {
  flex: none;
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--muted);
}
.fs-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.fs-title { min-width: 0; display: flex; flex-direction: column; }
.fs-title strong, .fs-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-title strong { font-size: 1.08rem; }
.fs-title span { color: var(--muted); font-size: 0.8rem; }
.fs-title span:empty { display: none; }

.fs-tools {
  top: var(--safe-top);
  right: var(--safe-right);
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 14px;
  overflow: hidden;
}
.fs-tools button {
  width: 46px;
  height: 46px;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary);
}
.fs-tools button.active { background: var(--primary-container); }
.fs-tools button:active, .fs-circle:active { opacity: 0.6; }
.fs-divider { width: 28px; height: 1px; background: var(--line); }

.fs-sheet {
  left: var(--safe-left);
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  max-width: 560px;
  margin: 0 auto;
  border-radius: 22px;
  padding: 16px 18px;
}
.fs-sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fs-sheet-row strong { font-size: 1.2rem; color: var(--primary); }
.fs-route { color: var(--muted); font-size: 0.88rem; margin: 6px 0 10px; }
.fs-route:empty { display: none; }
.fs-link { color: var(--primary); font-weight: 700; font-size: 0.9rem; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  .fs-chrome, .map-fab { transition: opacity 0.15s ease; transform: none !important; }
}
.message { font-weight: 600; border-radius: var(--radius); }
.message:empty { display: none; }
.message[data-kind="error"] { color: var(--bad); background: var(--bad-bg); padding: 11px 13px; }
.message[data-kind="ok"] { color: var(--ok-text); background: var(--primary-container); padding: 11px 13px; }
.hidden { display: none !important; }

@media (max-width: 720px) {
  .hero { padding-top: 20px; padding-bottom: 20px; }
  .hero, .status-row, .actions, .code-row { flex-direction: column; align-items: stretch; }
  .metrics { grid-template-columns: 1fr; }
  button, .ghost { width: 100%; }
  .map-overlay .fs-circle { width: 36px; }
  .map-overlay .fs-tools button { width: 46px; }
  .map-box .map-fab { width: 40px; }
  .actions > :last-child { margin-left: 0; }
  .card { padding: 18px; }
}
