:root {
  color-scheme: light;
  --bg: #eef3f2;
  --surface: #ffffff;
  --line: #cfd9d6;
  --line-strong: #9eb0ab;
  --text: #13211e;
  --muted: #5d6f69;
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --accent-soft: #dff3ef;
  --warn: #9a5b13;
  --warn-soft: #fff3d6;
  --danger: #a23b3b;
  --shadow: 0 16px 42px rgba(24, 43, 38, 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:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 240px),
    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;
}

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: 24px;
  padding: 28px clamp(18px, 4vw, 44px) 18px;
}

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

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

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

h2 {
  font-size: 18px;
}

.key-box {
  display: grid;
  grid-template-columns: auto minmax(220px, 340px) auto;
  align-items: center;
  gap: 8px;
  min-width: min(100%, 570px);
}

.key-box label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.icon-button {
  min-width: 58px;
}

#toggleKeys {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: stretch;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(320px, 0.7fr);
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 44px) 34px;
}

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

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

.result-panel {
  grid-column: 1 / -1;
}

.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;
}

.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: 700;
  text-align: center;
}

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

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

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(15, 118, 110, 0.18);
  outline-offset: 1px;
}

.table-wrap {
  overflow: auto;
}

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

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

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

.station-table-wrap table {
  min-width: 520px;
}

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: #f7faf9;
  color: #344742;
  font-size: 12px;
}

td {
  font-size: 13px;
}

.check-col {
  width: 44px;
}

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

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

.selected-wrap {
  padding: 14px 18px 18px;
}

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

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

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

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

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

.chip button {
  min-height: 20px;
  width: 20px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0;
  color: var(--accent-dark);
}

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

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

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

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

.dataset-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
  padding: 18px;
}

.status {
  min-height: 44px;
  margin: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  color: var(--muted);
  padding: 12px;
  font-size: 13px;
}

.status.warn {
  border-color: #e3bf75;
  background: var(--warn-soft);
  color: var(--warn);
}

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

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

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

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

.result-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1;
}

.issues {
  display: grid;
  gap: 8px;
  padding: 14px 18px 18px;
}

.issue {
  border: 1px solid #ead08f;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  padding: 9px 10px;
  font-size: 12px;
}

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

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

  .key-box {
    grid-template-columns: 1fr auto;
  }

  .key-box label {
    grid-column: 1 / 2;
  }

  #toggleKeys {
    grid-column: 2;
    grid-row: 2 / span 2;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .result-controls {
    justify-content: flex-start;
  }

  .station-panel,
  .query-panel {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .controls-grid,
  .result-summary,
  .actions {
    grid-template-columns: 1fr;
  }

  .topbar,
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

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