:root {
  color-scheme: light;
  --ink: #16202a;
  --muted: #5d6873;
  --line: #d7dde3;
  --panel: #f7f8fa;
  --paper: #ffffff;
  --solved: #24745b;
  --open: #b03232;
  --accent: #245b8f;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  height: 100%;
  margin: 0;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 390px) 1fr;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.panel-header,
.filters,
.stats,
.legend,
.status,
.records-title,
.sources {
  padding-left: 18px;
  padding-right: 18px;
}

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

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

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: 0;
}

.scope {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

input {
  width: 100%;
  padding: 0 9px;
  color: var(--ink);
  background: var(--paper);
}

button {
  cursor: pointer;
  color: var(--paper);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

button:hover {
  filter: brightness(0.94);
}

#loadData {
  grid-column: 1 / -1;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 14px;
  padding-bottom: 12px;
}

.stats div {
  padding: 10px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats span {
  display: block;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.stats small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.legend {
  display: grid;
  gap: 8px;
  padding-top: 4px;
  padding-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 7px;
  border-radius: 50%;
  vertical-align: -1px;
}

.dot-solved {
  background: var(--solved);
}

.dot-open {
  background: var(--open);
}

.status {
  margin: 0;
  padding-top: 10px;
  padding-bottom: 10px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.4;
}

.records {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.records-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  padding-bottom: 8px;
}

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

#fitMap {
  min-height: 30px;
  padding: 0 10px;
  color: var(--accent);
  background: transparent;
  border-color: var(--accent);
  font-size: 13px;
}

#recordList {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0 10px 12px 18px;
  overflow: auto;
}

.record-item {
  margin: 0 0 8px;
  padding: 10px 10px 10px 12px;
  list-style-position: inside;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--solved);
  border-radius: 8px;
}

.record-item.open {
  border-left-color: var(--open);
}

.record-button {
  display: grid;
  width: 100%;
  min-height: auto;
  padding: 0;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-weight: 600;
}

.record-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding-top: 12px;
  padding-bottom: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.map-wrap {
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

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

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

.popup-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(380px, 48vh) minmax(0, 1fr);
  }

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

  .map-wrap {
    order: 1;
  }

  h1 {
    font-size: 24px;
  }
}
