:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --text: #17202a;
  --muted: #637083;
  --line: #d8e0ea;
  --amber: #f59e0b;
  --amber-dark: #b45309;
  --blue: #1d4ed8;
  --green: #15803d;
  --red: #b91c1c;
  --shadow: 0 10px 28px rgba(23, 32, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.topbar {
  min-height: 76px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1,
.panel-header h2,
.section-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

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

.actions,
.panel-header,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.button {
  height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.button svg {
  width: 18px;
  height: 18px;
}

.button-primary {
  background: var(--text);
  color: white;
}

.button-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

.button:disabled {
  cursor: progress;
  opacity: 0.68;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 16px auto 32px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

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

.field input,
.field select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

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

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 12px;
  align-items: stretch;
}

.map-panel,
.results-panel,
.agenda-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.map-panel {
  overflow: hidden;
  min-height: 620px;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 620px;
}

.results-panel {
  min-height: 620px;
  max-height: 620px;
  display: flex;
  flex-direction: column;
}

.panel-header,
.section-header {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ecfdf5;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.status-muted {
  background: #f1f5f9;
  color: var(--muted);
}

.auction-list {
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.auction-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.auction-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.auction-meta,
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.auction-meta {
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 8px;
  background: #f8fafc;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}

.tag-amber {
  background: #fffbeb;
  color: var(--amber-dark);
  border-color: #fde68a;
}

.tag-blue {
  background: #eff6ff;
  color: var(--blue);
  border-color: #bfdbfe;
}

.tag-green {
  background: #ecfdf5;
  color: var(--green);
  border-color: #bbf7d0;
}

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.link-button {
  height: 34px;
  border-radius: 8px;
  background: var(--text);
  color: white;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.link-button svg {
  width: 15px;
  height: 15px;
}

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

.agenda-section {
  margin-top: 12px;
}

.agenda-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
  padding: 12px;
}

.agenda-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  min-height: 140px;
  padding: 10px;
}

.agenda-day h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.agenda-item {
  display: block;
  margin-top: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.35;
}

.agenda-item span {
  color: var(--muted);
}

.empty-state {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

.leaflet-popup-content {
  margin: 10px 12px;
  min-width: 220px;
}

.popup-title {
  margin: 0 0 6px;
  font-weight: 800;
}

.popup-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-search {
    grid-column: 1 / -1;
  }

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

  .results-panel {
    max-height: none;
  }

  .agenda-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .button {
    flex: 1;
    justify-content: center;
  }

  .app-shell {
    width: min(100vw - 20px, 1480px);
  }

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

  .map-panel,
  #map {
    min-height: 460px;
  }
}
