:root {
  --bg: #f3f3f1;
  --panel: #f7f7f5;
  --panel-2: #efefeb;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --border: #d9d9d4;
  --button: #ecece8;
  --button-active: #111111;
  --button-active-text: #ffffff;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  height: 100vh;
  background: var(--bg);
}

.map-wrap,
#map {
  background: #efeee9;
}

#map {
  width: 100%;
  height: 100%;
}

.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.topbar > div,
.legend {
  pointer-events: auto;
  background: rgba(247,247,245,0.97);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  color: var(--text);
}

.eyebrow {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #666;
  margin-bottom: 4px;
  font-weight: 700;
}

.title h1 {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 28px;
  line-height: 1.05;
  color: #111;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.title p,
.status p {
  margin: 4px 0 0;
  color: #666;
  font-size: 12px;
  font-family: Arial, Helvetica, sans-serif;
}

.status strong {
  display: block;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  color: #111;
}

.toggle-bar {
  margin-top: 10px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toggle-btn {
  background: var(--button);
  color: #222;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-family: Arial, Helvetica, sans-serif;
}

.toggle-btn.active {
  background: var(--button-active);
  color: var(--button-active-text);
  border-color: #111;
}

.panel {
  border-left: 1px solid var(--border);
  background: #f7f7f5;
  display: flex;
  flex-direction: column;
  min-height: 0;
  color: var(--text);
}

.panel-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-section.compact {
  padding-top: 12px;
  padding-bottom: 12px;
}

.panel-section.seat-priority {
  padding: 16px;
  background: #ecece8;
  box-shadow: none;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #555;
  font-weight: 700;
  font-family: Arial, Helvetica, sans-serif;
}

.big-number {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: #111;
}

.sub {
  font-size: 12px;
  color: #666;
  margin-top: 6px;
  font-family: Arial, Helvetica, sans-serif;
}

.seat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
  font-family: Arial, Helvetica, sans-serif;
}

.seat-table th,
.seat-table td {
  padding: 6px 6px;
  border-bottom: 1px solid #dddcd6;
  text-align: left;
  vertical-align: top;
}

.seat-table th {
  color: #666;
  font-weight: 700;
  background: transparent;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.seat-table td strong { color: #111; }

.seat-table .num {
  text-align: right;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  min-height: 0;
  flex: 0 0 22vh;
  max-height: 22vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: Arial, Helvetica, sans-serif;
}

thead th {
  text-align: left;
  position: sticky;
  top: 0;
  background: #ecece8;
  z-index: 2;
  color: #666;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid #dddcd6;
  vertical-align: top;
}

tbody tr:hover {
  background: rgba(0,0,0,0.03);
  cursor: pointer;
}

.party-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.16);
}

.legend {
  line-height: 1.45;
  padding: 10px 12px;
  color: #222;
  background: rgba(247,247,245,0.97);
  font-family: Arial, Helvetica, sans-serif;
}

.legend strong {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  font-size: 12px;
  color: #222;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.14);
  flex: 0 0 12px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  padding: 2px 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
}

.floating-popup {
  position: absolute;
  width: min(330px, calc(100vw - 48px));
  z-index: 1100;
  display: none;
  padding: 12px 14px;
  border-radius: 6px;
  background: #f7f7f4;
  color: #222;
  border: 1px solid #d2d2cb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  font-family: Arial, Helvetica, sans-serif;
}

.floating-popup.visible {
  display: block;
}

.floating-popup h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.15;
  color: #222;
  font-weight: 800;
}

.popup-metric {
  margin: 4px 0;
  font-size: 12px;
  color: #444;
}

.popup-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.popup-table th,
.popup-table td {
  padding: 6px 7px;
  border-bottom: 1px solid rgba(0,0,0,0.10);
  color: #222;
}

.popup-table thead th {
  position: static;
  top: auto;
  background: #ecece7;
  color: #666;
  z-index: auto;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.popup-table td:last-child,
.popup-table th:last-child,
.popup-table td:nth-last-child(2),
.popup-table th:nth-last-child(2) {
  text-align: right;
  white-space: nowrap;
}

.winner-row {
  background: rgba(0,0,0,0.03);
  font-weight: 700;
}

.muted { color: #777; }

.leaflet-control-zoom,
.leaflet-control-attribution {
  box-shadow: none;
  font-family: Arial, Helvetica, sans-serif;
}

.leaflet-control-zoom a {
  border-radius: 6px !important;
  margin-bottom: 4px;
  border: 1px solid rgba(0,0,0,0.10);
  color: #222;
}

.leaflet-control-attribution {
  background: rgba(247,247,245,0.95);
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 54vh 46vh;
    height: 100dvh;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--border);
    overflow: hidden;
  }

  .panel-section {
    padding: 12px 14px;
  }

  .panel-section.seat-priority {
    padding: 12px 14px;
  }

  .table-wrap {
    flex: 1 1 auto;
    max-height: none;
    overflow: auto;
  }

  .topbar {
    top: 10px;
    left: 10px;
    right: 10px;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
  }

  .topbar > div,
  .legend {
    padding: 8px 10px;
    border-radius: 6px;
  }

  .title h1 {
    font-size: 22px;
  }

  .title p,
  .status p,
  .eyebrow {
    font-size: 11px;
  }

  .toggle-bar {
    gap: 6px;
    margin-top: 8px;
  }

  .toggle-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .floating-popup {
    width: min(300px, calc(100vw - 24px));
    padding: 10px 12px;
    border-radius: 6px;
  }

  .floating-popup h3 {
    font-size: 15px;
  }

  .popup-table {
    font-size: 11px;
  }

  .seat-table,
  table {
    font-size: 12px;
  }

  .leaflet-control-zoom {
    transform: scale(0.92);
    transform-origin: top left;
  }
}

@media (max-width: 640px) {
  .app {
    grid-template-rows: 50vh 50vh;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    width: min(92vw, 340px);
  }

  .status {
    align-self: flex-start;
  }

  .legend {
    max-width: 220px;
    font-size: 11px;
  }

  .seat-table th:nth-child(3),
  .seat-table td:nth-child(3),
  .seat-table th:nth-child(4),
  .seat-table td:nth-child(4) {
    display: none;
  }

  .popup-table th:nth-child(2),
  .popup-table td:nth-child(2) {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}