:root {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1f2840;
  --line: #2c3654;
  --text: #e8ecf5;
  --muted: #8d97b0;
  --accent: #f5b938;

  --open: #2fbf71;
  --pending: #f0a020;
  --taken: #e0475b;

  --floor: #141b2b;
  --floor-grid: #1c2438;
  --feature: #2a3350;

  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: .02em; }
.brand .venue { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; font-size: .8rem; color: var(--muted);
}
.chip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.chip.open i { background: var(--open); }
.chip.pending i { background: var(--pending); }
.chip.taken i { background: var(--taken); }

.chip.tier i { background: var(--tier); }
.chip .price { color: var(--text); }

.color-by { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; }
.color-by-label { color: var(--muted); margin-right: 4px; }
.color-by input { position: absolute; opacity: 0; pointer-events: none; }
.color-by span:not(.color-by-label) {
  display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; color: var(--muted);
}
.color-by input:checked + span { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.color-by input:focus-visible + span { outline: 2px solid var(--accent); }

.tier-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--tier); vertical-align: -1px; }

.actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .9rem; }
.switch input { accent-color: var(--accent); width: 18px; height: 18px; }
.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #1a1300; border-color: var(--accent); font-weight: 600; }

/* ---------- Layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.map-wrap { position: relative; padding: 16px; min-height: 0; overflow: hidden; }
#floor-map { width: 100%; height: 100%; min-height: 360px; display: block; }

/* ---------- SVG map ----------
   Strokes use vector-effect: non-scaling-stroke, so widths here are screen pixels
   regardless of venue units or zoom level. */
#floor-map { touch-action: none; cursor: grab; user-select: none; }
#floor-map.panning { cursor: grabbing; }
#floor-map.panning .booth { cursor: grabbing; }
.floor { fill: var(--floor); stroke: var(--line); stroke-width: 1.5; }
.grid-line { stroke: var(--floor-grid); stroke-width: 1; }
.feature { fill: var(--feature); stroke: var(--line); stroke-width: 1; }
.feature.stage { fill: #3a4566; }
.feature.table { fill: #262f49; }
.feature.sponsor { fill: rgb(245 185 56 / .14); stroke: var(--accent); stroke-dasharray: 5 3; }
.feature.entrance { fill: rgb(245 185 56 / .1); stroke: var(--accent); stroke-dasharray: 6 4; stroke-width: 1.5; }
.feature.obstacle { fill: #4a5578; }
.feature-label {
  fill: var(--muted); text-anchor: middle; dominant-baseline: central; pointer-events: none;
  font-weight: 600; letter-spacing: .04em;
}
.feature-label.heading { fill: var(--text); font-weight: 700; letter-spacing: .08em; }

.booth { cursor: pointer; outline: none; }
.booth .shape { stroke: var(--bg); stroke-width: 1; transition: filter .12s, stroke .12s; }
.booth.open .shape { fill: var(--open); }
.booth.pending .shape { fill: var(--pending); }
.booth.taken .shape { fill: var(--taken); }
/* Color-by-tier mode: fill with the tier color; fade taken booths, outline pending ones. */
.by-tier .booth .shape { fill: var(--tier, #888); }
.by-tier .booth.taken { opacity: .3; }
.by-tier .booth.pending .shape { stroke: var(--pending); stroke-width: 2.5; }
.booth:hover .shape, .booth:focus-visible .shape { filter: brightness(1.2); stroke: #fff; stroke-width: 1.5; }
.booth.selected .shape { stroke: #fff; stroke-width: 3; }
.booth.selected { filter: drop-shadow(0 0 4px rgb(255 255 255 / .5)); }
.booth .num {
  fill: #0d1220; font-size: var(--booth-font, 3px); font-weight: 700; text-anchor: middle;
  dominant-baseline: central; pointer-events: none;
}

/* Zoom controls */
.zoom {
  position: absolute; right: 26px; bottom: 26px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: 0 4px 16px rgb(0 0 0 / .35);
}
.zoom button {
  width: 38px; height: 36px; background: none; border: 0; color: var(--text);
  font: 600 1.1rem/1 system-ui, sans-serif; cursor: pointer;
}
.zoom button + button { border-top: 1px solid var(--line); }
.zoom button:hover { background: var(--surface-2); }
.zoom button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.zoom .level { font-size: .7rem; color: var(--muted); text-align: center; padding: 4px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.map-hint {
  position: absolute; left: 26px; bottom: 26px; margin: 0; font-size: .75rem; color: var(--muted);
  pointer-events: none; background: rgb(23 30 46 / .85); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px;
}
.booth.flash .shape { animation: flash .5s ease-out; }
@keyframes flash { from { filter: brightness(1.8); } to { filter: none; } }

/* ---------- Side panel ---------- */
.panel { border-left: 1px solid var(--line); background: var(--surface); padding: 20px; overflow: auto; }
.panel-empty { color: var(--muted); font-size: .9rem; }
.eyebrow { margin: 0; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.panel h2 { margin: 2px 0 8px; font-size: 2rem; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #0d1220;
}
.badge.open { background: var(--open); }
.badge.pending { background: var(--pending); }
.badge.taken { background: var(--taken); }
.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 18px 0; font-size: .9rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; word-break: break-word; }

.admin-form { border-top: 1px solid var(--line); padding-top: 16px; }
.admin-form fieldset { border: 0; padding: 0; margin: 0 0 14px; }
.admin-form legend, .field > span { font-size: .8rem; color: var(--muted); margin-bottom: 6px; display: block; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 8px 0; border-radius: 8px;
  border: 1px solid var(--line); font-size: .85rem; background: var(--surface-2);
}
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg input[value="open"]:checked + span { background: var(--open); color: #0d1220; border-color: var(--open); }
.seg input[value="pending"]:checked + span { background: var(--pending); color: #0d1220; border-color: var(--pending); }
.seg input[value="taken"]:checked + span { background: var(--taken); color: #0d1220; border-color: var(--taken); }
.field input {
  width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit;
}
.field input:focus { outline: none; border-color: var(--accent); }
.hint { color: var(--muted); font-size: .75rem; margin: 10px 0 0; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; z-index: 10; pointer-events: none; background: #0b0f19; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: .8rem; box-shadow: 0 6px 20px rgb(0 0 0 / .4);
  white-space: nowrap;
}
.tooltip strong { display: block; }
.tooltip span { color: var(--muted); }

/* ---------- Load error ---------- */
.load-error {
  position: absolute; inset: 16px; display: grid; place-content: center; text-align: center;
  gap: 8px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 24px; color: var(--muted);
}
.load-error code { color: var(--text); }

/* ---------- Narrow screens ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: minmax(320px, 1fr) auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .actions { margin-left: 0; }
}

/* ---------- Search ---------- */
.searchbar { padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.searchbar input {
  width: 100%; max-width: 360px; padding: 7px 12px; font: inherit;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
}
.searchbar input:focus { outline: none; border-color: var(--accent); }
#floor-map .booth.dim { opacity: .15; }
#floor-map .booth.match .shape { stroke: #fff; stroke-width: 2.5; }
