/* 한 화면 구성: 헤더 → KPI 띠 → 클라우드 3열 → (트래픽 차트 | 서버 리소스). 모든 치수는 rem. */
:root {
  color-scheme: light;

  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #0c1522;
  --ink-2: #344054;
  --muted: #566275;
  --line: #dde2e9;
  --line-strong: #b4bdc9;
  --panel-edge: #ccd3dc;

  --accent: #1f5fd1;
  --accent-track: #dbe6fa;
  --spark: #566275;

  --good: #0a8f0a;
  --warn: #f0a000;
  --warn-ink: #5c3d00;
  --warn-tint: #fdefcf;
  --crit: #cf3636;
  --crit-ink: #8a1c1c;
  --crit-tint: #fbe4e4;
  --neutral: #6b7686;
  --neutral-tint: #e8ecf1;

  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;

  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.3125rem;
  --fs-kpi: 3.5rem;

  --gap: 1.125rem;
  --pad: 1.25rem;
  --radius: 0.75rem;
}

/* 화면 전체를 1920×1080(120rem × 67.5rem) 기준으로 비례 축소·확대한다.
   브라우저 창이 전체 화면이 아니어도, 프로젝터 해상도가 달라도 스크롤 없이 한 화면에 들어오게 하려는 것. */
html {
  font-size: clamp(11px, min(0.83334vw, 1.48149vh), 36px);
  height: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-sm);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.page {
  min-height: 100vh;
  padding: 1.375rem 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(19rem, 1fr);
  gap: var(--gap);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
}

/* 상태 표식: 색이 아니라 모양으로도 구분된다 */
.mark { width: 0.875rem; height: 0.875rem; flex: none; display: block; fill: var(--neutral); }
.mark[data-state="ok"] { fill: var(--good); }
.mark[data-state="down"] { fill: var(--crit); }
.mark[data-state="warn"] { fill: var(--warn); }
.mark-cut { stroke: var(--surface); stroke-width: 1.8; stroke-linecap: round; fill: none; }
.mark-ink { stroke: var(--warn-ink); stroke-width: 1.6; stroke-linecap: round; fill: none; }
.mark-hollow { fill: none; stroke: var(--neutral); stroke-width: 2; stroke-linecap: round; }
.mark-dashed { stroke-dasharray: 2.6 2.6; }

/* 헤더 */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 2.5rem;
}
.brand { display: flex; align-items: baseline; gap: 1rem; }
.wordmark { font-size: 1.5rem; line-height: 1.2; letter-spacing: 0.16em; font-weight: 400; color: var(--ink); white-space: nowrap; }
.wordmark b { font-weight: 800; }
.brand-sub { font-size: var(--fs-md); color: var(--muted); white-space: nowrap; }

.top-status { display: flex; align-items: center; gap: 1.5rem; font-size: var(--fs-md); }
.probe { display: flex; align-items: center; gap: 0.5rem; color: var(--ink-2); white-space: nowrap; }
.probe .mark { width: 1rem; height: 1rem; }
.probe strong { color: var(--ink); font-weight: 700; }
.feed {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-left: 1.5rem;
  border-left: 1px solid var(--line-strong);
  white-space: nowrap;
}
.feed-mode { font-weight: 600; color: var(--ink); }
.feed-age { color: var(--muted); min-width: 5.75rem; text-align: right; }
/* 자리는 그대로 두고 보이지만 않게 해 헤더가 좌우로 움직이지 않는다 */
.feed[data-replay="true"] .feed-age { visibility: hidden; }
.probe[data-replay="true"] .mark { fill: var(--neutral); }
.feed[data-late="true"] .feed-age { color: var(--warn-ink); font-weight: 600; }

/* KPI 띠 */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { padding: 1.125rem 1.75rem 1.125rem; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi h2 { font-size: var(--fs-md); font-weight: 600; color: var(--ink-2); }
.kpi-value { display: flex; align-items: baseline; gap: 0.5rem; margin-top: 0.125rem; line-height: 1.15; white-space: nowrap; }
.kpi-value .num { font-size: var(--fs-kpi); font-weight: 700; letter-spacing: -0.02em; }
.kpi-value[data-empty] .num, .row-figure[data-empty] .num { color: var(--muted); font-weight: 400; }
.kpi-value .unit { font-size: 1.5rem; font-weight: 600; color: var(--ink-2); }
.kpi-note { margin-top: 0.25rem; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 다섯 칸 폭에서 버킷·객체 수까지 붙은 설명이 말줄임으로 잘리지 않도록 이 칸만 한 단계 작게 쓴다 */
#kpi-storage .kpi-note { font-size: var(--fs-xs); }

/* 패널 공통 머리 */
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem var(--pad) 0.5rem;
}
.panel-head h2 { font-size: var(--fs-lg); font-weight: 700; white-space: nowrap; }
.panel-title { display: flex; align-items: baseline; gap: 0.875rem; min-width: 0; }
.panel-sub { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.col-head { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); padding-bottom: 0.3125rem; white-space: nowrap; }
.rows-empty { padding: 1.25rem var(--pad); color: var(--muted); font-size: var(--fs-sm); }

/* 클라우드 3열 */
/* AWS 열은 도메인 이름이 길어 조금 더 넓게 잡는다 */
.providers { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.16fr) minmax(0, 0.94fr); gap: var(--gap); }
.provider { display: flex; flex-direction: column; min-width: 0; padding-bottom: 0.375rem; min-height: 19rem; }
.summary { display: flex; align-items: baseline; gap: 0.5rem; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; min-width: 0; }
.summary-value { font-size: var(--fs-md); font-weight: 700; color: var(--ink); }
.summary-window:not(:empty)::before { content: "· "; }

.row-grid {
  display: grid;
  grid-template-columns: 0.875rem minmax(0, 1fr) 6.25rem 7.5rem;
  column-gap: 0.75rem;
  align-items: center;
  padding-left: var(--pad);
  padding-right: var(--pad);
}
.col-figure { text-align: right; }
.row { height: 2.25rem; border-top: 1px solid var(--line); }
/* 자리가 모자라면 이름만 줄어든다(말줄임, 전체 이름은 title). 배지·칩·기준 시각은 데이터가 얼마나 오래됐는지 등을 말하므로 잘리면 안 된다. */
.row-id { display: flex; align-items: center; gap: 0.5rem; min-width: 0; overflow: hidden; }
.row-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-md); font-weight: 500; }
.tier {
  flex: none;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  padding: 0.1875rem 0.3125rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.25rem;
  color: var(--muted);
}
.chip {
  flex: none;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
  padding: 0.25rem 0.4375rem;
  border-radius: 0.25rem;
  background: var(--neutral-tint);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip[data-tone="crit"] { background: var(--crit-tint); color: var(--crit-ink); }
.chip[data-tone="warn"] { background: var(--warn-tint); color: var(--warn-ink); }
.stale { flex: none; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.row-figure { display: flex; align-items: baseline; justify-content: flex-end; gap: 0.25rem; white-space: nowrap; }
.row-figure .num { font-size: var(--fs-md); font-weight: 700; }
.row-figure .unit { font-size: var(--fs-xs); color: var(--muted); }
.row[data-state="stopped"] .row-name,
.row[data-state="idle"] .row-name,
.row[data-state="unknown"] .row-name { color: var(--ink-2); }

.spark-cell { width: 7.5rem; height: 1.75rem; display: flex; align-items: center; }
.spark { width: 100%; height: 100%; display: block; overflow: visible; }
.spark-none { color: var(--muted); font-size: var(--fs-sm); }
.spark-line { fill: none; stroke: var(--spark); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--spark); fill-opacity: 0.12; stroke: none; }

/* 아래 줄: 트래픽 차트 + 서버 리소스 */
.bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); min-height: 0; }
.traffic, .resources { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.toggle { display: inline-flex; flex: none; border: 1px solid var(--line-strong); border-radius: 0.5rem; overflow: hidden; align-self: center; }
.toggle button {
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  padding: 0.4375rem 0.875rem;
  border: 0;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.toggle button + button { border-left: 1px solid var(--line-strong); }
.toggle button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.toggle button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.chart { position: relative; flex: 1; min-height: 12rem; margin: 0 var(--pad) 0.75rem; }
.chart svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart-empty { position: absolute; inset: 0 0 2rem 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: var(--fs-sm); }
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-base { stroke: var(--line-strong); stroke-width: 1; }
.c-bar { fill: var(--accent); }
.c-band { fill: var(--ink); fill-opacity: 0.07; }
.c-tick { fill: var(--muted); font-size: var(--fs-xs); font-family: var(--font); }
.tip {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.4375rem 0.625rem;
  border-radius: 0.375rem;
  background: var(--ink);
  color: var(--surface);
  font-size: var(--fs-xs);
  white-space: nowrap;
  pointer-events: none;
}
.tip strong { font-size: var(--fs-sm); }

.res-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); column-gap: 2.25rem; padding: 0 var(--pad) 0.5rem; }
/* 이름 열은 가장 긴 서버 이름에 맞추고(상한 13rem), 머리줄과 모든 행이 같은 열 폭을 쓴다 */
.res-col {
  display: grid;
  grid-template-columns: fit-content(13rem) repeat(3, minmax(3.5rem, 1fr));
  column-gap: 1.125rem;
  align-content: start;
}
.res-rows { display: contents; }
.res-grid {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
}
.res-row { height: 2.75rem; border-top: 1px solid var(--line); }
/* 13대 이상이면 간격만 줄여 두 단 × 8행이 패널 안에 들어가게 한다(글자 크기는 그대로) */
.res-cols[data-dense="true"] .res-row { height: 2.125rem; }
.res-more { padding: 0 var(--pad) 0.5rem; font-size: var(--fs-sm); color: var(--muted); text-align: right; }
.res-name { display: flex; align-items: center; gap: 0.375rem; min-width: 0; }
.res-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-md); font-weight: 500; }
/* 좁은 칸에서도 막대 길이를 최대로 쓰기 위해 수치를 막대 위에 올린다 */
.meter { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.meter-value { font-size: var(--fs-sm); font-weight: 700; line-height: 1.1; white-space: nowrap; }
.meter-track { height: 0.375rem; border-radius: 0.1875rem; background: var(--accent-track); overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 0; border-radius: 0.1875rem; background: var(--accent); transition: width 0.4s ease; }
.meter[data-empty="true"] .meter-track { background: var(--neutral-tint); }
.meter[data-empty="true"] .meter-value { color: var(--muted); font-weight: 400; }
/* 자리는 유지하고 내용만 숨겨 열 정렬이 흔들리지 않게 한다 */
.meter[data-absent="true"], .res-grid.col-head > span[data-absent="true"] { visibility: hidden; }
.res-row[data-level="unknown"] .res-label { color: var(--muted); }

/* 좁은 화면(노트북 창 분할, 휴대폰)에서는 비례 축소 대신 세로로 쌓는다 */
@media (max-width: 1100px) {
  html { font-size: 15px; }
  .page { padding: 1rem; }
  .top { flex-wrap: wrap; }
  .top-status { flex-wrap: wrap; row-gap: 0.5rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .providers, .bottom { grid-template-columns: minmax(0, 1fr); }
  .provider { min-height: 0; }
  .chart { min-height: 15rem; }
  .res-cols { grid-auto-flow: row; }
  .res-col + .res-col .col-head { display: none; }
  .panel-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
