:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-elev: #181b22;
  --bg-elev-2: #21252e;
  --fg: #e8eaed;
  --muted: #8a8f98;
  --line: #2a2f3a;
  --accent: #ff3b3b;
  --ok: #3ddc84;
  --warn: #ffb020;
  --bad: #ff5252;
  --blue: #4ea3ff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
}

#map { position: fixed; inset: 0; }

/* status strip */
#status-strip {
  position: fixed; top: 0; left: 0; right: 0;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: linear-gradient(to bottom, rgba(15, 17, 21, 0.92), rgba(15, 17, 21, 0.55) 80%, transparent);
  display: flex; justify-content: space-between; align-items: center;
  z-index: 5; pointer-events: none;
}
#status-strip > div { pointer-events: auto; }
#status-strip strong { color: var(--accent); font-size: 1.05rem; letter-spacing: -0.01em; margin-right: 8px; }
#status-airport { color: var(--muted); font-size: 0.85rem; }
#floor-btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg);
  padding: 7px 12px; border-radius: 999px; font: inherit; font-size: 0.85rem; cursor: pointer;
}
#floor-btn:active { background: var(--bg-elev-2); }

/* route strip */
#route-strip {
  position: fixed; top: calc(var(--safe-top) + 56px); left: 12px; right: 12px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px; z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.route-strip-text { flex: 1; min-width: 0; }
#route-strip-headline { display: block; font-weight: 600; }
#route-strip-detail { color: var(--muted); font-size: 0.85rem; }
#route-clear {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 1.4rem; line-height: 1; width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
}
#route-clear:active { background: var(--bg-elev-2); color: var(--fg); }

/* floor switcher */
#floor-switcher {
  position: fixed; top: 50%; right: 10px; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px;
  padding: 4px; z-index: 5;
}
.floor-pill {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.75rem; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  text-align: left; min-width: 92px; white-space: nowrap;
}
.floor-pill:hover { color: var(--fg); }
.floor-pill.active { background: var(--accent); color: white; }

/* bottom sheet */
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg-elev); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  max-height: 55vh; min-height: 124px;
  display: flex; flex-direction: column;
  transition: transform 0.25s ease;
  z-index: 4;
  padding-bottom: var(--safe-bottom);
  touch-action: pan-y;
}
#sheet.collapsed { transform: translateY(calc(55vh - 124px)); }
#sheet-handle { width: 36px; height: 4px; background: var(--line); border-radius: 2px; margin: 8px auto 4px; }
#sheet-header { padding: 8px 14px 10px; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
#sheet-header strong { font-size: 1rem; display: block; }
.muted { color: var(--muted); font-size: 0.85rem; }
.sheet-filters { display: flex; gap: 6px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 0.75rem; padding: 5px 10px; border-radius: 999px; cursor: pointer;
}
.chip-active { background: var(--bg-elev-2); color: var(--fg); border-color: var(--bg-elev-2); }

#corral-list { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; flex: 1; }
.corral-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 10px 12px; margin: 4px 0; border-radius: 10px;
  background: var(--bg-elev-2); cursor: pointer;
}
.corral-row:active { background: #2a3140; }
.corral-row.low { box-shadow: inset 3px 0 0 var(--bad); }
.corral-name { font-weight: 600; }
.corral-meta { color: var(--muted); font-size: 0.8rem; grid-column: 1; }
.corral-stock {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem;
  grid-row: 1 / span 2; align-self: center; text-align: right;
}
.corral-stock.ok   { color: var(--ok); }
.corral-stock.warn { color: var(--warn); }
.corral-stock.bad  { color: var(--bad); }
.corral-stock small { display: block; font-size: 0.7rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }

/* modal */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; padding: 16px; padding-bottom: calc(var(--safe-bottom) + 16px);
}
#modal {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px 18px;
  width: 100%; max-width: 480px; max-height: 80vh; overflow-y: auto;
}
#modal h2 { margin: 0 0 4px; font-size: 1.15rem; }
#modal .muted { margin: 0 0 16px; }
.floor-group { margin-bottom: 14px; }
.floor-group h3 { margin: 0 0 6px; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.floor-group-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.floor-choice {
  appearance: none; border: 1px solid var(--line); background: var(--bg-elev-2); color: var(--fg);
  font: inherit; font-size: 0.85rem; padding: 8px 12px; border-radius: 10px; cursor: pointer; text-align: left;
}
.floor-choice:active, .floor-choice:hover { background: #2a3140; }
.floor-choice.active { background: var(--accent); border-color: var(--accent); color: white; }
.ghost {
  appearance: none; border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; padding: 10px 14px; border-radius: 10px; cursor: pointer; width: 100%; margin-top: 8px;
}
.ghost:active { color: var(--fg); background: var(--bg-elev-2); }

/* maplibre tweaks */
.maplibregl-ctrl-attrib {
  background: rgba(15,17,21,0.6) !important;
  color: var(--muted) !important;
}
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
