:root {
  color-scheme: light;
  --bg: #eef2f0;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --line: #d5ddd9;
  --line-strong: #9caaa4;
  --text: #17211d;
  --muted: #607169;
  --accent: #146c63;
  --accent-dark: #0d4943;
  --accent-soft: #dff0ed;
  --gold: #b7791f;
  --gold-soft: #fff4d9;
  --danger: #a23b3b;
  --shadow: 0 14px 34px rgba(23, 33, 29, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
  white-space: nowrap;
}

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

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 26px clamp(16px, 4vw, 42px) 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

.health {
  min-width: 110px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(460px, 1.08fr) minmax(340px, 0.72fr);
  grid-template-areas:
    "stations location"
    "stations query"
    "results results";
  gap: 18px;
  padding: 0 clamp(16px, 4vw, 42px) 34px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.station-panel {
  grid-area: stations;
  min-height: 720px;
}

.location-panel {
  grid-area: location;
}

.query-panel {
  grid-area: query;
}

.result-panel {
  grid-area: results;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px 8px;
}

.station-filters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: 1 / -1;
}

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(20, 108, 99, 0.16);
  outline-offset: 1px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px 16px;
}

.dataset-options {
  display: grid;
  gap: 10px;
  margin: 12px 18px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dataset-options legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dataset-options label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
}

.dataset-options input {
  width: 17px;
  min-height: 17px;
}

.table-wrap {
  overflow: auto;
}

.station-table-wrap {
  height: 430px;
  margin: 10px 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-table-wrap {
  max-height: 620px;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.result-table-wrap table {
  min-width: 1280px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: #34443e;
  font-size: 13px;
  font-weight: 900;
}

td {
  font-size: 13px;
}

tbody tr:hover {
  background: #f6fbfa;
}

.check-col {
  width: 44px;
  text-align: center;
}

.check-col input {
  width: 17px;
  min-height: 17px;
}

.station-name {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.distance-cell {
  color: var(--accent-dark);
  font-weight: 900;
}

.empty {
  height: 130px;
  color: var(--muted);
  text-align: center;
}

.selected-wrap {
  margin: 14px 18px 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.selected-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.selected-head strong {
  font-size: 14px;
}

.selected-head button {
  min-height: 32px;
  padding: 5px 9px;
}

.chips {
  display: flex;
  min-height: 38px;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 6px 8px 6px 11px;
  font-size: 12px;
  font-weight: 800;
}

.chip span {
  color: var(--muted);
  font-weight: 700;
}

.chip button {
  min-height: 22px;
  width: 22px;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
}

.status {
  margin: 0 18px 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status.warn {
  border-color: #e2bf69;
  background: var(--gold-soft);
  color: #71450b;
}

.status.error {
  border-color: #e0a3a3;
  background: #fff1f1;
  color: var(--danger);
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 18px 14px;
}

.result-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.result-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.result-summary strong {
  font-size: 26px;
  line-height: 1;
}

.issues {
  display: grid;
  gap: 8px;
  margin: 0 18px 18px;
}

.issue {
  border: 1px solid #e2bf69;
  border-radius: 8px;
  background: var(--gold-soft);
  color: #71450b;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
}

.result-controls {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-controls label {
  min-width: 118px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager button {
  min-width: 62px;
}

.pager span {
  min-width: 90px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

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

  .health {
    width: fit-content;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "location"
      "stations"
      "query"
      "results";
  }

  .station-panel {
    min-height: 620px;
  }
}

@media (max-width: 720px) {
  .controls-grid,
  .station-filters {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .panel-head,
  .result-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button,
  .panel-head button {
    width: 100%;
  }

  .station-table-wrap {
    height: 360px;
  }
}
