:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1c1f1d;
  --muted: #626a64;
  --line: #d9ded6;
  --green: #1f8a5b;
  --amber: #bd7a11;
  --red: #be3b33;
  --teal: #237c90;
  --shadow: 0 18px 48px rgba(28, 31, 29, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  min-height: 620px;
  overflow-x: hidden;
}

.sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.header {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
}

.primary-button {
  min-height: 40px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--ink);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.status-row {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfa;
}

.stat-value,
.stat-label {
  display: block;
}

.stat-value {
  overflow: hidden;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px;
  min-width: 0;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
}

.toggles {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  font-size: 13px;
}

.toggles input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--green);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.legend-swatch.high {
  background: var(--green);
}

.legend-swatch.mid {
  background: var(--amber);
}

.legend-swatch.low,
.legend-swatch.bad {
  background: var(--red);
}

.restaurant-list {
  display: grid;
  min-height: 0;
  gap: 8px;
  margin: 0;
  padding: 0 2px 2px;
  overflow: auto;
  list-style: none;
}

.restaurant-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(28, 31, 29, 0.04);
}

.restaurant-card.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(35, 124, 144, 0.18);
}

.restaurant-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.restaurant-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.restaurant-name {
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1.2;
}

.score-pill {
  min-width: 58px;
  border-radius: 6px;
  padding: 5px 8px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.score-pill.high {
  background: var(--green);
}

.score-pill.mid {
  background: var(--amber);
}

.score-pill.low,
.score-pill.bad {
  background: var(--red);
}

.meta-line,
.detail-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.detail-line strong {
  color: var(--ink);
}

.badge {
  border-radius: 999px;
  padding: 2px 7px;
  background: #eef4ef;
  color: #245c3d;
  font-weight: 700;
}

.badge.warning {
  background: #f8e8e5;
  color: #943129;
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.map {
  width: 100%;
  height: 100%;
  background: #e4ebe6;
}

.marker-pin {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 999px 999px 999px 4px;
  box-shadow: var(--shadow);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  transform: rotate(-45deg);
}

.marker-pin span {
  transform: rotate(45deg);
}

.marker-pin.high {
  background: var(--green);
}

.marker-pin.mid {
  background: var(--amber);
}

.marker-pin.low,
.marker-pin.bad {
  background: var(--red);
}

.marker-pin.user {
  background: var(--teal);
}

.popup {
  min-width: 220px;
}

.popup h2 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.2;
}

.popup p {
  margin: 5px 0;
  color: var(--muted);
}

.popup strong {
  color: var(--ink);
}

.fallback-map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 480px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(28, 31, 29, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(28, 31, 29, 0.07) 1px, transparent 1px),
    #e4ebe6;
  background-size: 56px 56px;
}

.fallback-note {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--shadow);
}

.fallback-pin {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: #ffffff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  transform: translate(-50%, -50%);
}

.fallback-pin.high {
  background: var(--green);
}

.fallback-pin.mid {
  background: var(--amber);
}

.fallback-pin.low,
.fallback-pin.bad {
  background: var(--red);
}

.fallback-pin.user {
  background: var(--teal);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(440px, 54vh) minmax(420px, 46vh);
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    order: 2;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .map-panel {
    order: 1;
  }
}

@media (max-width: 520px) {
  .app-shell {
    grid-template-rows: 48vh auto;
  }

  .sidebar {
    padding: 14px;
  }

  .header {
    display: grid;
    gap: 12px;
  }

  .primary-button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .filters,
  .toggles {
    grid-template-columns: 1fr;
  }

  .restaurant-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .score-pill {
    width: max-content;
  }
}
