:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #1e2528;
  --muted: #657176;
  --line: #d8ded8;
  --accent: #1f7a5a;
  --accent-strong: #11513d;
  --amber: #b56913;
  --red: #a33b31;
  --blue: #2867a7;
  --shadow: 0 8px 24px rgba(35, 43, 45, 0.09);
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcf9;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 760;
  line-height: 1.12;
}

h2 {
  font-size: 16px;
  font-weight: 740;
}

#runMeta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: #243034;
  font-size: 13px;
}

.summary-strip span {
  min-width: 104px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(420px, 1.2fr) minmax(340px, 0.85fr);
  height: calc(100vh - 75px);
  min-height: 620px;
}

.filters,
.list-pane {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fbfcf9;
}

.filters {
  display: grid;
  align-content: start;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
}

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

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

.field span,
.toggles,
.switch-line {
  color: #354044;
  font-size: 12px;
  font-weight: 680;
}

input,
select,
button {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd4ce;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

input,
select {
  padding: 8px 10px;
}

button {
  grid-column: 1 / -1;
  cursor: pointer;
  background: var(--accent);
  color: #ffffff;
  font-weight: 730;
}

button:hover,
button:focus-visible {
  background: var(--accent-strong);
}

.toggles {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 2px;
}

.toggles label,
.switch-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.toggles input,
.switch-line input {
  width: 18px;
  min-height: 18px;
}

.switch-line {
  grid-column: 1 / -1;
}

.active-filter-summary {
  grid-column: 1 / -1;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.map-pane {
  position: relative;
  min-width: 0;
  border-right: 1px solid var(--line);
}

#map {
  height: 100%;
  min-height: 420px;
  z-index: 1;
}

.map-status,
.map-empty-state {
  position: absolute;
  left: 14px;
  z-index: 500;
  border: 1px solid rgba(216, 222, 216, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.map-status {
  top: 14px;
  padding: 8px 10px;
  color: #2d383c;
  font-size: 13px;
}

.map-empty-state {
  top: 56px;
  max-width: min(320px, calc(100% - 28px));
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.detail-panel {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 500;
  width: min(420px, calc(100% - 28px));
  max-height: 44%;
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(216, 222, 216, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.detail-panel h3 {
  margin: 0 0 7px;
  font-size: 17px;
  line-height: 1.22;
}

.detail-panel .meta,
.event-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.list-pane {
  border-right: 0;
}

.list-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcf9;
}

.list-head select {
  width: 190px;
}

.event-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.event-card {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 3px 12px rgba(35, 43, 45, 0.04);
  cursor: pointer;
}

.event-card:hover,
.event-card:focus-visible,
.event-card.is-selected {
  border-color: var(--accent);
  outline: none;
}

.event-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.28;
}

.event-card p,
.detail-panel p {
  color: #344146;
  font-size: 13px;
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 7px;
  border: 1px solid #d3dad4;
  border-radius: 999px;
  background: #f7f8f5;
  color: #2d383c;
  font-size: 12px;
  font-weight: 650;
}

.pill.ok {
  border-color: #bbd9ca;
  background: #eaf6ef;
  color: #11513d;
}

.pill.warn {
  border-color: #ead0a5;
  background: #fff6e8;
  color: #75430c;
}

.pill.bad {
  border-color: #e3b9b4;
  background: #fff0ee;
  color: #78281f;
}

.pill.info {
  border-color: #b9d0e8;
  background: #eef6ff;
  color: #214f82;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.link-row a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  color: #0f503b;
  font-size: 13px;
  font-weight: 740;
  text-decoration: none;
}

.link-row a.secondary {
  border-color: #cbd4ce;
  color: #354044;
}

.muted,
.empty-state {
  color: var(--muted);
}

.empty-state {
  padding: 24px 10px;
  text-align: center;
  font-size: 14px;
}

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

.popup-title {
  font-weight: 760;
  line-height: 1.25;
}

.popup-line {
  margin-top: 5px;
  color: #4b5a60;
  font-size: 12px;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 280px minmax(420px, 1fr);
    grid-template-rows: minmax(430px, 58vh) minmax(280px, 1fr);
  }

  .list-pane {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }
}

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

  .summary-strip {
    justify-content: flex-start;
    width: 100%;
  }

  .summary-strip span {
    flex: 1 1 92px;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 0;
  }

  .filters {
    grid-template-columns: 1fr;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .map-pane {
    height: 56vh;
    min-height: 390px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 42%;
  }
}
