:root {
  --ink: #18222f;
  --muted: #5f6d7c;
  --line: #dde5ea;
  --surface: #ffffff;
  --page: #f5f7f9;
  --accent: #137469;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

h1, h2 { margin: 0; font-size: 16px; }
h2 small { font-weight: 400; margin-left: 6px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.notice { margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; background: var(--surface); }
small { font-size: 12px; }

/* 사이드바 레이아웃: 좁은 화면에서는 위쪽 가로 메뉴로 바뀝니다. */
body.app { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 0 10px; font-size: 15px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; padding: 8px 10px; border-radius: 7px; color: var(--muted); text-decoration: none; }
.sidebar nav a:hover { background: var(--page); }
.sidebar nav a[aria-current] { background: var(--page); color: var(--ink); font-weight: 600; }
.nav-label { padding: 14px 10px 4px; font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.account { display: grid; gap: 4px; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 12px; }
.account span { overflow-wrap: anywhere; }
.account button { justify-self: start; }

@media (max-width: 760px) {
  body.app { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .nav-label { display: none; }
  .account { display: flex; gap: 10px; align-items: center; margin-left: auto; padding: 0; border-top: 0; }
}

.page-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.page-head h1 { font-size: 20px; }
/* 제공자 화면 바로가기: "Claude Console [사용량] [비용]" */
.console-links { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-left: 12px; border-left: 1px solid var(--line); }
.console-links > span { color: var(--muted); font-size: 13px; margin-right: 2px; }
.empty { text-align: center; padding: 40px 20px; }
.empty .actions { justify-content: center; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
[data-provider="openai"]:is(.swatch, .share-seg) { background: #2a78d6; }
[data-provider="anthropic"]:is(.swatch, .share-seg) { background: #eb6834; }
[data-provider="gemini"]:is(.swatch, .share-seg) { background: #1baf7a; }
[data-provider="byteplus"]:is(.swatch, .share-seg) { background: #eda100; }
[data-provider="wavespeed"]:is(.swatch, .share-seg) { background: #8b5cf6; }
[data-provider="apify"]:is(.swatch, .share-seg) { background: #d6457f; }
[data-provider="serpapi"]:is(.swatch, .share-seg) { background: #14a3b8; }

main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  align-content: start;
  padding: 24px 16px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  min-width: 0;
}
.card-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid { display: grid; gap: 16px; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }

button, select, input, textarea, a.button {
  font: inherit;
  color: inherit;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
button { cursor: pointer; }
a.button { display: inline-block; text-decoration: none; }
a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; }
button:disabled { opacity: 0.6; cursor: progress; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.link { border: 0; padding: 0; background: none; color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: grid; gap: 4px; }
label > span { font-size: 12px; color: var(--muted); }

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

/* 보기 전환 탭: 기간별 사용량 / 실시간 부하 */
.view-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.view-tabs a { padding: 8px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; }
.view-tabs a[aria-current] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
/* 탭 줄: 탭은 왼쪽, 기간 선택은 오른쪽. 좁은 화면에서는 기간 선택이 아래로 내려갑니다. */
.filter-panel { display: grid; gap: 12px; }
.view-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 16px; border-bottom: 1px solid var(--line); }
.view-bar .view-tabs { border-bottom: 0; }
.view-bar .filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: none; margin-left: auto; padding-bottom: 8px; }
/* 두 탭 모두 필터 네 칸의 너비를 확보해 API 키의 시작 위치를 고정합니다. */
.view-bar .provider-filters { width: 684px; max-width: 100%; justify-content: flex-start; }
.view-bar .provider-filters > label:has(select:is([name="days"], [name="hours"])) { margin-left: auto; }
.view-bar .filters label { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.view-bar .filters select, .view-bar .filters input { width: auto; }
.view-bar .filters select:is([name="days"], [name="hours"]) { width: 110px; }
.view-bar .filters select:is([name="api_key"], [name="model"]) { width: 220px; max-width: 100%; }
.view-bar .load-filters select { width: 110px; }
.filter-panel > .date-range { justify-content: flex-end; gap: 8px; }
.filter-panel > .date-range label { flex: 0 1 220px; min-width: 0; }
.filter-panel > .date-range input { width: 100%; min-width: 0; }
.filter-panel > .date-range :is(input, button) { min-height: 38px; }
.tabs a {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
}
.tabs a[aria-current] { background: var(--ink); border-color: var(--ink); color: #fff; }

.key-form { display: grid; gap: 12px; max-width: 560px; margin-top: 12px; }
.key-form input { width: 100%; }
.key-guide { margin: 16px 0; padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--page); overflow-wrap: anywhere; }
.key-guide-steps { display: grid; gap: 14px; margin: 0; padding-left: 22px; }
.key-guide-steps > li::marker { color: var(--accent); font-weight: 600; }
.key-guide p { margin: 4px 0 0; color: var(--muted); }
.key-guide details { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.key-guide ul { display: grid; gap: 8px; margin-bottom: 0; padding-left: 22px; color: var(--muted); }
td .actions { justify-content: flex-end; }

/* 필터 개수와 관계없이 같은 너비로 정렬하고, 좁은 화면에서는 칸 수를 줄입니다. */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; align-items: end; max-width: 960px; }
.filters label { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.filters select, .filters input { width: 100%; min-width: 0; }
.filters :is(select, input, button) { min-height: 38px; }
.filters .date-range { grid-column: 1 / -1; }
.date-range { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.date-range label { flex: 1 1 140px; }
/* 한도 표: 지표마다 최대·한도·사용률 세 칸을 묶고, 숫자는 오른쪽 정렬합니다. */
.limit-table th, .limit-table td { white-space: nowrap; }
.limit-table td { text-align: right; font-variant-numeric: tabular-nums; }
.limit-table td:nth-child(2):not(.group-start) { text-align: left; }
.limit-table thead th { text-align: center; }
.limit-table thead th[rowspan] { text-align: left; vertical-align: bottom; }
.limit-table .group-start { border-left: 1px solid var(--line); }
.limit-table tbody th { text-align: left; font-weight: 500; color: var(--ink); font-size: 13px; }
.limit-table .model-list { display: block; font-weight: 400; font-size: 11px; white-space: normal; max-width: 240px; }
.date-range[hidden] { display: none; }

.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile { display: grid; gap: 2px; align-content: start; }
.tile .headroom { color: var(--accent); font-weight: 600; }
.tile strong { font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.money-krw { color: var(--muted); }
.cost-tile strong { overflow-wrap: anywhere; }
.cost-tile strong .money-krw { font-size: 0.72em; }
/* 종합: 비용을 가장 크게 보여줍니다. */
.tiles.cost-first { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); }
.tile-hero strong { font-size: 36px; color: var(--ink); }
.cost-first .tile:not(.tile-hero) strong { font-size: 22px; overflow-wrap: anywhere; }
.share-bar { display: flex; height: 10px; margin-top: 12px; border-radius: 999px; overflow: hidden; background: var(--page); }
.share-seg { display: block; height: 100%; }
.share-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 12px; }
.share-legend strong { font-size: 12px; font-weight: 600; }
.cost-table td.cost { font-weight: 600; color: var(--ink); }
.cost-table td small { margin-left: 6px; }
.share-cell { display: inline-flex; align-items: center; gap: 8px; }
.share-track { display: inline-block; width: 72px; height: 6px; border-radius: 999px; overflow: hidden; background: var(--page); }
@media (max-width: 720px) {
  .tiles.cost-first { grid-template-columns: minmax(0, 1fr); }
  .view-bar .filters { margin-left: 0; justify-content: flex-start; }
}

.note { margin: 4px 0 0; font-size: 12px; }
.chart { position: relative; height: 240px; margin-top: 12px; }
.chart.tall { height: 340px; }
.chart-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}
.chart-toggle[hidden] { display: none; }
.chart-toggle:hover { background: var(--page); }
.chart-toggle input {
  appearance: none;
  width: 30px;
  height: 18px;
  margin: 0;
  padding: 2px;
  border: 0;
  border-radius: 999px;
  background: #7c8a99;
  cursor: inherit;
}
.chart-toggle input::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
}
.chart-toggle input:checked { background: var(--accent); }
.chart-toggle input:checked::before { transform: translateX(12px); }
.chart-toggle span { color: var(--ink); font-weight: 600; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; font-weight: 500; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
td[colspan] { text-align: left; }
/* 키 목록: 긴 이름·계정은 줄바꿈하고 날짜와 관리 버튼의 너비를 확보합니다. */
.keys-table { table-layout: fixed; min-width: 640px; }
.keys-table th, .keys-table td { text-align: left; white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.keys-table th:nth-child(3) { width: 104px; }
.keys-table th:nth-child(4) { width: 100px; }
.keys-table th:nth-child(5) { width: 148px; }
.keys-table td:nth-child(3) { white-space: nowrap; }
.keys-table .actions { display: grid; gap: 6px; justify-content: stretch; }
.keys-table .actions > :is(button, a) { text-align: center; white-space: nowrap; }
details summary { cursor: pointer; }
details summary h2 { display: inline; }
.card:has(table) { overflow-x: auto; }
.usage-tables { align-items: stretch; }
.card.usage-table-card { display: flex; flex-direction: column; overflow: hidden; }
.table-scroll { overflow-x: auto; margin: 12px 0 16px; }
.table-scroll table { margin-top: 0; }
.usage-table-card th, .usage-table-card td { padding: 9px 8px; }
#daily-table { scroll-margin-top: 20px; }
#api-key-table { scroll-margin-top: 20px; }
.key-usage td:nth-child(2) { text-align: left; }
.key-usage th:nth-child(2) { text-align: left; }
.key-usage td small { margin-left: 6px; }
.key-usage .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.key-usage .badge { padding: 1px 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }
.key-usage tr[aria-current] td { background: var(--page); font-weight: 600; }
.key-usage tr.idle td { color: var(--muted); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.pagination-links { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.pagination-links .button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; white-space: nowrap; }
.pagination-links .pagination-direction { width: 48px; }
.pagination-links .pagination-gap { width: 16px; text-align: center; }
.pagination-links .button:not([aria-current]):not(:disabled):hover { background: var(--page); border-color: var(--accent); }
.pagination-links .button[aria-current] { font-weight: 600; }
.pagination-links .button:disabled { background: var(--page); color: var(--muted); cursor: default; opacity: 0.65; }

@media (max-width: 520px) {
  .chart-toggle { min-height: 44px; }
  .usage-table-card th, .usage-table-card td { padding: 9px 5px; font-size: 12px; }
  .pagination { justify-content: center; }
  .pagination > small { flex-basis: 100%; text-align: center; }
  .pagination-links { margin-inline-start: 0; }
  .pagination-links .button { height: 44px; }
  .pagination-links[data-many-pages] :is(.pagination-number:not([aria-current]), .pagination-gap) { display: none; }
}

.footnote { margin: 0; font-size: 12px; }

/* 서비스별 수집 안내 */
.source-card h3 { margin: 0; font-size: 13px; }
.source-method { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.source-badge { background: var(--page); border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.source-description { margin: 12px 0; line-height: 1.7; }
.source-content { margin-top: 16px; overflow-wrap: anywhere; }
.source-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; padding: 12px; background: var(--page); border-radius: 7px; }
.source-facts dt { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.source-facts dd { margin: 0; font-size: 12px; font-weight: 600; }
.source-steps { display: grid; gap: 12px; margin: 0; font-size: 13px; }
.source-steps > div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; }
.source-steps dt { font-weight: 600; }
.source-steps dd { margin: 0; line-height: 1.7; }
.source-note { padding: 12px 14px; border-left: 3px solid #c9a861; border-radius: 0 6px 6px 0; background: #faf7ef; font-size: 12px; line-height: 1.7; margin: 16px 0; }
.source-references { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 16px; }
.source-references ul { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 6px 0 10px; padding: 0; font-size: 12px; }
.source-references a { display: inline-block; padding: 5px 0; text-underline-offset: 3px; }

@media (max-width: 520px) {
  .view-tabs a { padding-inline: 8px; min-height: 44px; display: flex; align-items: center; }
  .source-card { padding: 16px; }
  .source-card .card-head { gap: 8px; }
  .source-facts { grid-template-columns: 1fr; }
  .source-steps > div { grid-template-columns: 1fr; gap: 3px; }
}

body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
body.login form { display: grid; gap: 14px; width: min(100%, 340px); }

/* 값을 보여줄 수 없는 섹션: 자리는 지키고 상태와 이유만 한 줄로 보여줍니다. */
.section-notice { padding-block: 12px; }
.section-notice h2 { margin-bottom: 2px; color: var(--muted); }
.notice-line .checked { margin-left: 6px; white-space: nowrap; }
.status-badge { display: inline-block; margin-right: 6px; padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--muted); }
.status-badge[data-status="supported"] { color: #1f7a45; border-color: #b9dfc8; }
.status-badge[data-status="unsupported"] { color: #5b6673; background: #f1f3f5; }
.status-badge[data-status="uncollected"] { color: #8a5a00; border-color: #ecd9a8; }
.status-badge[data-status="unverified"] { color: #8a5a00; border-style: dashed; }
.tile.unavailable strong { color: var(--muted); }
.tile .status-badge { justify-self: start; margin-right: 0; }
.support-table h3 { margin: 12px 0 6px; font-size: 14px; }
