:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --neutral-series: #c3c2b7;
  --good: #0ca30c;
  --critical: #d03b3b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --accent-soft: #184f95;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --neutral-series: #52514e;
    --shadow: none;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242423;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --accent-soft: #184f95;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --neutral-series: #52514e;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    'Apple SD Gothic Neo',
    'Malgun Gothic',
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 16px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--series-1), var(--series-3));
  flex: none;
}

.brand__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand__sub {
  margin: 0;
  color: var(--text-2);
  font-size: 12px;
}

.topbar__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-2);
  font-weight: 500;
}

.segmented button[aria-checked='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 600;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface);
  white-space: nowrap;
}

.chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.chip--ok .chip__dot {
  background: var(--good);
}

.chip--bad .chip__dot {
  background: var(--critical);
}

.chip--running .chip__dot {
  background: var(--series-4);
}

/* 파일로만 갱신하는 플랫폼이 아직 파일을 받지 못한 상태 */
.chip--wait .chip__dot {
  background: var(--muted);
}

/* 리디 가져오기 안내 */
.steps {
  margin: 4px 0 10px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-2);
}

.steps li {
  margin: 4px 0;
}

.steps code,
.note code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  word-break: break-all;
}

a.chip-link {
  color: inherit;
  text-decoration: none;
}

button.chip-link {
  font: inherit;
  color: var(--text);
}

.ridi-cat {
  margin-top: 10px;
}

.ridi-cat__head {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-2);
}

.chip--provider {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--text);
}

.tabs {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 8px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
}

.tabs button {
  border: 0;
  background: transparent;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tabs button[aria-selected='true'] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.view {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: grid;
  gap: 16px;
}

.footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.card__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.card__desc {
  margin: 2px 0 0;
  color: var(--text-2);
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kpi__label {
  color: var(--text-2);
  font-size: 12px;
}

.kpi__value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.kpi__sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.chart {
  position: relative;
  height: 320px;
}

.chart--tall {
  height: 420px;
}

.chart--short {
  height: 240px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
}

th {
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  background: var(--surface);
  position: sticky;
  top: 0;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover td {
  background: var(--surface-2);
}

.thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
  flex: none;
}

.title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.title-cell__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.title-cell__title {
  font-weight: 600;
  color: var(--text);
}

.title-cell__meta {
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  margin-right: 4px;
  white-space: nowrap;
}

.tag--new {
  background: var(--accent-soft);
  color: var(--text);
}

.tag--p {
  color: #fff;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-2);
}

.field input,
.field select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  min-width: 120px;
}

.field input[type='text'] {
  min-width: 180px;
}

.field--check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-bottom: 7px;
}

.btn {
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--text-2);
  font-size: 13px;
  flex-wrap: wrap;
}

.pager__buttons {
  display: flex;
  gap: 6px;
}

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

.note {
  color: var(--text-2);
  font-size: 12px;
  margin: 8px 0 0;
}

.legend-inline {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-2);
}

.legend-inline span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 5px;
  background: var(--sw);
  vertical-align: -1px;
}

.rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: 28px;
}

.bar-list {
  display: grid;
  gap: 6px;
}

.bar-list__row {
  display: grid;
  grid-template-columns: minmax(80px, 140px) 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-list__track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.bar-list__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.bar-list__value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.error {
  border-color: var(--critical);
  color: var(--critical);
}

@media (max-width: 640px) {
  .topbar__inner {
    padding-top: 10px;
  }

  .kpi__value {
    font-size: 22px;
  }

  .chart {
    height: 260px;
  }
}

/* 통합 검색창 */
.search {
  position: relative;
  min-width: 240px;
  flex: 1 1 240px;
  max-width: 360px;
}

.search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: var(--surface);
}

/* 자동완성 제안 목록 */
.suggest {
  position: relative;
}

.suggest__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 100%;
  width: max-content;
  max-width: min(480px, 90vw);
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(11, 11, 11, 0.12);
}

.suggest__item {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.suggest__item:hover,
.suggest__item.is-active {
  background: var(--surface-2);
}

.suggest__type {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

.suggest__name {
  font-weight: 600;
  color: var(--text);
}

.suggest__meta {
  grid-column: 2;
  font-size: 11px;
  color: var(--muted);
}

/* 범례: 첫 글자 묶음, 이름 칩 */
.initials {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 12px 0;
}

.initial {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-2);
}

.initial.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.initial__count {
  margin-left: 4px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

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

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  text-align: left;
}

.chip-link:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.chip-link__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-link__count {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chip-link__multi {
  font-size: 10px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
}

.chip-link__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

@media (max-width: 640px) {
  .search {
    max-width: none;
    flex-basis: 100%;
  }
}
