:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --text: #1f2933;
  --muted: #65717f;
  --line: #d8dee7;
  --panel: #ffffff;
  --accent: #2364aa;
  --accent-dark: #174a7d;
  --accent-soft: #e8f1fb;
  --danger: #b42318;
  --empty: #f0f3f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Arial,
    sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 32px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

.version {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  padding: 20px 32px 32px;
}

.controls,
.chart-surface,
.data-status {
  border: 1px solid var(--line);
  background: var(--panel);
}

.controls {
  align-self: start;
  padding: 16px;
}

.control-grid {
  display: grid;
  gap: 12px;
}

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

.field span,
.panel-heading,
.section-heading,
.chart-kicker,
.status-line {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

select:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.variable-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

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

.text-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--accent);
  padding: 0 10px;
  cursor: pointer;
}

.text-button:hover {
  border-color: var(--accent);
}

.variable-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.variable-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.variable-option input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.variable-option span {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-surface {
  min-width: 0;
  padding: 16px;
}

.chart-header {
  margin-bottom: 10px;
}

.chart-kicker {
  margin: 0 0 4px;
}

#refresh-button {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  padding: 0 16px;
  cursor: pointer;
}

#refresh-button:hover {
  background: var(--accent-dark);
}

#refresh-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.status-line {
  min-height: 18px;
  margin-bottom: 8px;
}

.status-line.error {
  color: var(--danger);
}

.chart-box {
  min-height: 460px;
  border: 1px solid var(--line);
  background: #ffffff;
}

#line-chart {
  width: 100%;
  height: 460px;
}

.data-status {
  grid-column: 1 / -1;
  padding: 16px;
}

.data-status h2 {
  font-size: 16px;
}

.status-table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

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

.status-table th,
.status-table td {
  border-top: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

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

.status-table td {
  font-size: 13px;
}

.variable-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--accent-soft);
  padding: 0 8px;
}

.is-hidden {
  display: none;
}

.empty-state {
  display: grid;
  min-height: 460px;
  place-items: center;
  background: var(--empty);
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    padding: 20px;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .chart-box,
  #line-chart,
  .empty-state {
    min-height: 380px;
    height: 380px;
  }
}

@media (max-width: 560px) {
  .topbar {
    display: grid;
    gap: 8px;
  }

  h1 {
    font-size: 22px;
  }

  .chart-header {
    align-items: flex-start;
    flex-direction: column;
  }

  #refresh-button {
    width: 100%;
  }
}
