:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #66727f;
  --line: #dce3e8;
  --brand: #0d8f6f;
  --brand-dark: #08785d;
  --warn: #a65f00;
  --soft: #edf7f3;
  --shadow: 0 18px 45px rgba(24, 42, 58, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  gap: 18px;
  grid-template-columns: 380px minmax(0, 1fr);
  min-height: 100vh;
  padding: 20px;
}

.search-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel {
  align-self: start;
  min-width: 0;
  padding: 22px;
  position: sticky;
  top: 20px;
}

.result-panel {
  min-width: 0;
  padding: 22px;
}

.title-row,
.result-head,
.card-top,
.card-actions,
.field-row,
.result-actions,
.dialog-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.result-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.title-row > div,
.result-head > div {
  min-width: 0;
}

.tabs {
  background: #eef2f5;
  border-radius: 6px;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
}

.tab-button {
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  min-height: 36px;
  padding: 0 12px;
}

.tab-button.active {
  background: #fff;
  box-shadow: 0 1px 4px rgba(24, 42, 58, 0.08);
  color: var(--brand-dark);
}

.result-actions .ghost-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  padding: 0;
  width: 42px;
}

button svg {
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 18px;
}

p,
label span,
.meta,
.field-row {
  color: var(--muted);
}

.title-row p,
.result-head p {
  line-height: 1.5;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.filters {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  font-size: 13px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(13, 143, 111, 0.12);
}

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 42px;
  padding: 0 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  background: var(--brand);
  color: #fff;
  font-weight: 650;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.ghost-button {
  background: var(--soft);
  color: var(--brand-dark);
  font-weight: 600;
}

.icon-button {
  background: var(--soft);
  color: var(--brand-dark);
  flex: 0 0 42px;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.status-box {
  background: #fff8eb;
  border: 1px solid #f3d5a1;
  border-radius: 6px;
  color: var(--warn);
  margin: 18px 0;
  padding: 12px 14px;
}

.status-box.ok {
  background: var(--soft);
  border-color: #c8e8dc;
  color: var(--brand-dark);
}

.status-box.error {
  background: #fff1f1;
  border-color: #f0b7b7;
  color: #9e2626;
}

.time-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr);
  padding: 12px;
}

.time-picker label {
  min-width: 0;
}

.map-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.map-canvas {
  aspect-ratio: 16 / 9;
  background: #e6ecef;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 340px;
  overflow: hidden;
  position: relative;
}

.map-empty {
  color: var(--muted);
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.osm-map {
  height: 100%;
  inset: 0;
  overflow: hidden;
  position: absolute;
}

.osm-tile {
  height: 256px;
  position: absolute;
  width: 256px;
}

.osm-marker {
  align-items: center;
  background: var(--brand);
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(24, 42, 58, 0.2);
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  min-height: 0;
  padding: 0;
  position: absolute;
  transform: translate(-50%, -100%);
  width: 34px;
  z-index: 2;
}

.osm-marker.active {
  background: #c2410c;
  height: 40px;
  width: 40px;
  z-index: 3;
}

.osm-marker.user {
  background: #1d4ed8;
  pointer-events: none;
}

.osm-credit {
  background: rgba(255, 255, 255, 0.86);
  border-radius: 4px;
  bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  padding: 3px 6px;
  position: absolute;
  right: 8px;
  z-index: 4;
}

.map-zoom-controls {
  display: grid;
  gap: 6px;
  left: 10px;
  position: absolute;
  top: 10px;
  z-index: 5;
}

.map-zoom-controls button {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(16, 34, 49, 0.18);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 22px;
  font-weight: 700;
  height: 36px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 36px;
}

.map-zoom-controls button:active {
  transform: translateY(1px);
}

.map-selection {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px;
}

.results {
  display: grid;
  gap: 14px;
}

.stadium-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 148px minmax(0, 1fr);
  padding: 14px;
}

.results.compact {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.results.compact .stadium-card {
  gap: 10px;
  grid-template-columns: 88px minmax(0, 1fr);
  padding: 10px;
}

.results.compact .cover {
  aspect-ratio: 1;
}

.results.compact .stadium-name {
  font-size: 15px;
}

.results.compact .price {
  font-size: 15px;
}

.results.compact .meta {
  font-size: 12px;
  gap: 4px 8px;
  margin-top: 4px;
}

.results.compact .meta.address,
.results.compact .tags,
.results.compact .field-list {
  display: none;
}

.results.compact .card-actions {
  justify-content: flex-start;
  margin-top: 8px;
}

.results.compact .card-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.results.text-mode {
  gap: 8px;
}

.stadium-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(180px, 1.8fr) minmax(0, 3fr);
  min-height: 48px;
  padding: 7px 9px;
}

.stadium-row > * {
  min-width: 0;
}

.row-facts {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 72px 70px 64px 84px minmax(150px, 1fr) 68px;
  min-width: 0;
}

.row-facts > * {
  min-width: 0;
}

.row-name,
.row-field {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-name {
  font-size: 14px;
}

.row-price {
  color: #c2410c;
  font-weight: 760;
}

.stadium-row span {
  color: var(--muted);
  font-size: 13px;
}

.stadium-row .primary-button {
  min-height: 34px;
  padding: 0 10px;
}

.cover {
  aspect-ratio: 4 / 3;
  background: #e6ecef;
  border-radius: 6px;
  object-fit: cover;
  width: 100%;
}

.card-body {
  min-width: 0;
}

.stadium-name {
  font-size: 18px;
  line-height: 1.35;
}

.price {
  color: #c2410c;
  font-size: 18px;
  font-weight: 760;
  white-space: nowrap;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  line-height: 1.5;
  margin-top: 7px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  background: #eef2f5;
  border-radius: 999px;
  color: #4b5965;
  font-size: 12px;
  padding: 4px 8px;
}

.field-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
}

.field-row {
  align-items: center;
  background: #f8fafb;
  border-radius: 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 9px 10px;
}

.field-name {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 520px;
  padding: 20px;
  width: calc(100vw - 32px);
}

dialog::backdrop {
  background: rgba(10, 20, 30, 0.36);
}

dialog p {
  color: var(--muted);
  line-height: 1.5;
  margin: 8px 0 14px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .search-panel {
    position: static;
  }

  .stadium-card {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .map-canvas {
    min-height: 300px;
  }

  .stadium-row {
    grid-template-columns: minmax(140px, 1.2fr) minmax(0, 2fr);
  }

  .row-facts {
    grid-template-columns: 68px 64px 58px 78px minmax(110px, 1fr) 62px;
  }
}

@media (max-width: 560px) {
  .search-panel,
  .result-panel {
    padding: 20px;
  }

  .title-row,
  .result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .title-row {
    align-items: center;
    flex-direction: row;
  }

  .title-row p {
    display: none;
  }

  .result-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .stadium-card {
    grid-template-columns: 1fr;
  }

  .results.compact .stadium-card {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .cover {
    max-height: 210px;
  }

  .card-top {
    align-items: flex-start;
  }

  .map-canvas {
    aspect-ratio: 1;
    min-height: 280px;
  }

  .map-selection {
    align-items: stretch;
    flex-direction: column;
  }

  .time-picker {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .stadium-row {
    gap: 6px;
    grid-template-columns: 1fr;
  }

  .row-name {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .row-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .row-field {
    flex: 1 1 150px;
    white-space: normal;
  }

  .stadium-row .primary-button {
    margin-left: auto;
  }
}
