:root {
  color-scheme: light;
  --page: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #dddcd6;
  --grid: #e7e6e1;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6f6e69;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #8a8983;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: #383835;
    --grid: #2c2c2a;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --info: #8a8983;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #121211;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border: #383835;
  --grid: #2c2c2a;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #9a998f;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --info: #8a8983;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; }
h3 { font-size: 13px; margin: 12px 0 6px; color: var(--text-secondary); }
.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.top {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
}
.top p { margin: 2px 0 0; font-size: 12.5px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
select, button {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }

.tabs {
  display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: thin;
}
.tabs button {
  border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  padding: 8px 12px; color: var(--text-secondary); white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
footer { padding: 8px 16px 24px; font-size: 12px; text-align: center; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); margin-bottom: 12px; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; min-width: 0; margin-bottom: 12px;
}
.grid > .card { margin-bottom: 0; }
.card .sub { font-size: 12px; color: var(--text-muted); margin: -4px 0 8px; }

.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .note { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 5px 8px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; position: sticky; top: 0; background: var(--surface-1); }
tr:hover td { background: var(--surface-2); }
td.wrap { overflow-wrap: anywhere; min-width: 160px; }
.empty { color: var(--text-muted); padding: 8px 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 12px; color: var(--text-primary);
}
.badge::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--info); flex: none; }
.badge.high::before, .badge.down::before, .badge.critical::before { background: var(--critical); }
.badge.medium::before, .badge.warn::before { background: var(--serious); }
.badge.low::before { background: var(--warning); }
.badge.ok::before, .badge.good::before { background: var(--good); border-radius: 50%; }
.chip {
  display: inline-block; font-size: 11.5px; padding: 0 6px; margin: 1px 3px 1px 0; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary); white-space: nowrap;
}

.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: grid; grid-template-columns: 74px 64px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--grid); }
.alerts li:last-child { border-bottom: none; }
.alerts .rule { grid-column: 3; font-size: 11.5px; color: var(--text-muted); }
@media (max-width: 560px) {
  .alerts li { grid-template-columns: 1fr; gap: 2px; }
  .alerts .rule { grid-column: 1; }
}

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 4px; border-radius: 2px; display: inline-block; }
.legend i.bar { height: 10px; width: 10px; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--text-muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--text-primary); fill-opacity: 0.05; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }

.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; min-width: 80px; }
.meter > div { height: 100%; background: var(--series-1); border-radius: 4px; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 320px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.tooltip .t { color: var(--text-secondary); margin-bottom: 3px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .row span:first-child { display: inline-flex; align-items: center; gap: 5px; }
.tooltip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.mini { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.mini .card { margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 13px; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
pre.log { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; color: var(--text-secondary); }
.error { color: var(--critical); }

/* 패스키 로그인 · 등록 화면(D-23) */
.auth-page main.auth-box {
  max-width: 420px; margin: 8vh auto 24px; padding: 24px 20px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.auth-page main.auth-box.wide { max-width: 640px; margin-top: 4vh; }
.auth-box h1 { font-size: 18px; }
.auth-box h2 { margin: 12px 0 0; }
.auth-box p { margin: 0; }
.auth-box label { font-size: 13px; color: var(--text-secondary); }
.auth-box input[type="text"] {
  font: inherit; color: var(--text-primary); background: var(--page);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
.auth-box button { padding: 10px 14px; }
/* 흰 글자와 대비 4.5:1 이상이 되게 두 모드 모두 같은 진한 파랑 */
button.primary { background: #1f66c2; border-color: #1f66c2; color: #fff; font-weight: 600; font-size: 15px; }
button.primary:disabled { opacity: 0.6; cursor: progress; }
.auth-msg { min-height: 1.45em; font-size: 13px; }
.auth-msg.ok { color: var(--good); }
.auth-msg.error { color: var(--critical); }
.auth-links { font-size: 13px; text-align: center; }
.auth-links a, .auth-box a { color: var(--accent); }
