/* ARCSET design system
   원칙: ISA-101 고성능 HMI — 평상시는 무채색, 색은 상태(이상)와 데이터에만.
         스위스 타이포그래피 — 12열 그리드, 헤어라인, 왼쪽 정렬, 강한 위계.
         계기(instrument) — 수치는 고정폭 숫자, 단위는 작게, 라벨은 짧게. 선택은 색이 아니라 반전으로. */

@font-face { font-family: "Pretendard"; src: url("../fonts/PretendardVariable.woff2") format("woff2-variations");
  font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/plex-mono-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #efeee9;
  --surface: #fbfbf9;
  --surface-2: #f5f4f0;
  --ink: #141413;
  --ink-2: #4d4c48;
  --ink-3: #7c7a74;
  --line: #d9d7d0;
  --line-2: #e7e5df;
  --grid: #ebe9e3;
  --invert-bg: #141413;
  --invert-ink: #fbfbf9;
  --focus: #2a78d6;
  --brand: #e8590c;            /* 아크 — 로고와 '추천점' 표식에만 */

  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;          /* 데이터 계열(검증된 순서) */
  --seq-1: #cde2fb; --seq-3: #86b6ef; --seq-5: #2a78d6; --seq-7: #104281;
  --div-neg: #2a78d6; --div-mid: #f0efec; --div-pos: #e34948;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;   /* 상태 — 테마 무관 고정 */

  --f-sans: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --f-mono: "Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --rail: 232px;
  --pad: 24px;
  --r: 2px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #222220; --ink: #efeee9; --ink-2: #c3c2b7; --ink-3: #8f8e86;
    --line: #34332f; --line-2: #2a2927; --grid: #2a2927; --invert-bg: #efeee9; --invert-ink: #141413;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --seq-1: #184f95; --seq-3: #256abf; --seq-5: #5598e7; --seq-7: #b7d3f6;
    --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #222220; --ink: #efeee9; --ink-2: #c3c2b7; --ink-3: #8f8e86;
  --line: #34332f; --line-2: #2a2927; --grid: #2a2927; --invert-bg: #efeee9; --invert-ink: #141413;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --seq-1: #184f95; --seq-3: #256abf; --seq-5: #5598e7; --seq-7: #b7d3f6;
  --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--f-sans); letter-spacing: -0.005em;
  font-feature-settings: "ss06", "tnum"; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.mono, .num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------ 셸 */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; }
.brand { padding: 20px var(--pad) 18px; border-bottom: 1px solid var(--line); }
.brand .mark { text-decoration: none; color: var(--ink); width: fit-content; display: flex; align-items: center; gap: 10px; font: 600 15px/1 var(--f-mono); letter-spacing: 0.14em; }
.brand .mark svg { flex: none; }
.brand .sub { margin-top: 8px; font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.nav { padding: 10px 0; flex: 1; overflow: auto; }
.nav a { display: grid; grid-template-columns: 28px 1fr; align-items: baseline; padding: 9px var(--pad); text-decoration: none;
  color: var(--ink-2); border-left: 2px solid transparent; }
.nav a .no { font: 500 11px var(--f-mono); color: var(--ink-3); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { color: var(--ink); border-left-color: var(--ink); background: var(--surface-2); font-weight: 600; }
.nav .grp { padding: 16px var(--pad) 6px; font: 500 10.5px var(--f-mono); letter-spacing: 0.12em; color: var(--ink-3); text-transform: uppercase; }
.rail-foot { border-top: 1px solid var(--line); padding: 14px var(--pad); font-size: 12px; color: var(--ink-3); }
.rail-foot .row { display: flex; justify-content: space-between; gap: 8px; }
.rail-foot b { color: var(--ink-2); font: 500 12px var(--f-mono); }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; height: 52px; padding: 0 var(--pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 15px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.topbar .crumb { font: 500 11px var(--f-mono); color: var(--ink-3); letter-spacing: 0.1em; }
.topbar .sp { flex: 1; }
.page { padding: var(--pad); max-width: 1640px; }

/* ------------------------------------------------------------ 패널·그리드 */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; }
.c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; } .c12 { grid-column: span 12; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.panel > header { display: flex; align-items: baseline; gap: 12px; padding: 14px 18px 12px; border-bottom: 1px solid var(--line-2); }
.panel > header h2 { margin: 0; font-size: 13.5px; font-weight: 650; letter-spacing: -0.005em; white-space: nowrap; }
.panel > header .tag { font: 500 10.5px var(--f-mono); letter-spacing: 0.1em; color: var(--ink-3); text-transform: uppercase; }
.panel > header .sp { flex: 1; }
.panel > .body { padding: 16px 18px 18px; }
.panel > .body.flush { padding: 0; }
.caption { font-size: 12px; color: var(--ink-3); margin: 10px 0 0; line-height: 1.55; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 28px 0 12px; }
.section-title h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.section-title .no { font: 500 11px var(--f-mono); color: var(--ink-3); letter-spacing: 0.1em; }
.section-title p { margin: 0; color: var(--ink-3); font-size: 13px; }

/* ------------------------------------------------------------ 컨트롤 */
.field { margin-bottom: 14px; }
.field > label, .lbl { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--ink-2);
  margin-bottom: 6px; font-weight: 500; }
.field > label .u, .lbl .u { font: 400 11px var(--f-mono); color: var(--ink-3); }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 6px; font-size: 12.5px; cursor: pointer; color: var(--ink-2);
  border-right: 1px solid var(--line-2); white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); color: var(--ink); }
.seg button.on { background: var(--invert-bg); color: var(--invert-ink); font-weight: 600; }
.seg.small button { padding: 4px 8px; font-size: 11.5px; flex: none; }
.numin { display: flex; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.numin input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 7px 10px; font: 500 14px var(--f-mono); text-align: right; }
.numin button { width: 30px; border: 0; border-left: 1px solid var(--line-2); background: transparent; cursor: pointer; color: var(--ink-2); }
.numin button:hover { background: var(--surface-2); color: var(--ink); }
.range-hint { display: flex; justify-content: space-between; font: 400 10.5px var(--f-mono); color: var(--ink-3); margin-top: 4px; }
.slider { width: 100%; accent-color: var(--ink); margin: 6px 0 0; }
input[type=text], input[type=password], input[type=number].plain, select {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 7px 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: var(--r);
  border: 1px solid var(--invert-bg); background: var(--invert-bg); color: var(--invert-ink); font-weight: 600; font-size: 13px; cursor: pointer;
  text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.35; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); filter: none; }
.btn.block { width: 100%; }
.btn .k { font: 500 10.5px var(--f-mono); opacity: 0.6; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.sp { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* ------------------------------------------------------------ 상태 표시(색 + 모양 + 글자) */
.stat { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.stat i { width: 10px; height: 10px; display: inline-block; flex: none; }
.stat.good i { background: var(--good); border-radius: 50%; }
.stat.warning i { background: var(--warning); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.stat.serious i { background: var(--serious); transform: rotate(45deg) scale(0.85); }
.stat.critical i { background: var(--critical); clip-path: polygon(20% 0, 50% 30%, 80% 0, 100% 20%, 70% 50%, 100% 80%, 80% 100%, 50% 70%, 20% 100%, 0 80%, 30% 50%, 0 20%); }
.verdict { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.verdict .score { font: 600 34px/1 var(--f-mono); letter-spacing: -0.02em; }
.verdict .score small { font-size: 13px; color: var(--ink-3); font-weight: 400; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px;
  font: 500 11px var(--f-mono); color: var(--ink-2); white-space: nowrap; }
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.chip.live::before { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.chip.busy::before { background: var(--warning); animation: blink 1s infinite; }
.chip.warn { border-color: var(--warning); }
@keyframes blink { 50% { opacity: 0.3; } }
.notice { display: flex; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-left: 3px solid var(--warning);
  background: var(--surface); font-size: 12.5px; color: var(--ink-2); border-radius: var(--r); }
.notice b { color: var(--ink); }

/* ------------------------------------------------------------ 데이터시트(추천값) */
.sheet { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cell { padding: 14px 16px 14px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); min-width: 0; }
.cell:nth-child(4n) { border-right: 0; }
.cell:nth-last-child(-n+4) { border-bottom: 0; }
.cell .k { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.cell .k .sym { font: 500 11px var(--f-mono); color: var(--ink-3); }
.cell .v { margin-top: 6px; font: 500 30px/1.05 var(--f-mono); letter-spacing: -0.03em; }
.cell .v small { font: 400 12px var(--f-mono); color: var(--ink-3); margin-left: 4px; letter-spacing: 0; }
.cell .rg { margin-top: 2px; font: 400 11.5px var(--f-mono); color: var(--ink-3); }
.cell .unc { display: flex; gap: 10px; margin-top: 8px; font: 400 10.5px var(--f-mono); color: var(--ink-3); }
.cell svg { display: block; width: 100%; height: 26px; margin-top: 8px; overflow: visible; }

/* ------------------------------------------------------------ 표 */
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 11.5px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.n, table.t th.n { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
table.t tr.hl td { background: var(--surface-2); }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
.bar-in { position: relative; height: 6px; background: var(--line-2); border-radius: 3px; min-width: 60px; }
.bar-in > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink-2); border-radius: 3px; }

/* ------------------------------------------------------------ 차트 */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .ax text, .chart text.ax { font: 400 10.5px var(--f-mono); fill: var(--ink-3); }
.chart .ax line, .chart .ax path { stroke: var(--line); }
.chart .gridl line { stroke: var(--grid); }
.chart .lab { font: 500 11px var(--f-sans); fill: var(--ink-2); }
.chart .title { font: 500 11.5px var(--f-sans); fill: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; display: inline-block; }
.legend i.sq { width: 10px; height: 10px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--invert-bg); color: var(--invert-ink); padding: 8px 10px;
  border-radius: var(--r); font: 400 11.5px/1.5 var(--f-mono); max-width: 320px; box-shadow: 0 6px 18px rgba(0,0,0,.18); opacity: 0; transition: opacity .08s; }
.tip b { font-weight: 600; }
.tip .tl { font-family: var(--f-sans); font-weight: 600; margin-bottom: 2px; }
.small-multiples { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.small-multiples > div { padding: 12px 14px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); min-width: 0; }
.small-multiples > div:nth-child(4n) { border-right: 0; }
.sm-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.sm-h span { font: 400 11px var(--f-mono); color: var(--ink-3); font-weight: 400; }

/* ------------------------------------------------------------ 점검 목록 */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: baseline; padding: 9px 18px; border-bottom: 1px solid var(--line-2); }
.checks li:last-child { border-bottom: 0; }
.checks .nm { font-size: 12.5px; font-weight: 500; }
.checks .lim { font: 400 11px var(--f-mono); color: var(--ink-3); }
.checks .val { font: 500 12.5px var(--f-mono); text-align: right; }
.checks .adv { grid-column: 2 / 4; font-size: 11.5px; color: var(--ink-2); margin-top: -4px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-size: 12.5px; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; font: 500 12.5px var(--f-mono); text-align: right; }

/* ------------------------------------------------------------ 콘솔·로그 */
.console { font: 400 11.5px/1.6 var(--f-mono); background: var(--invert-bg); color: var(--invert-ink); padding: 12px 14px; height: 240px;
  overflow: auto; border-radius: var(--r); }
.console .t { opacity: 0.5; margin-right: 8px; }
.console .e { color: #ff8a80; }
.progress { height: 4px; background: var(--line-2); position: relative; overflow: hidden; border-radius: 2px; }
.progress > i { position: absolute; inset: 0 auto 0 0; background: var(--ink); transition: width .3s; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); }
.kpi { padding: 14px 18px; border-right: 1px solid var(--line-2); }
.kpi:last-child { border-right: 0; }
.kpi .k { font-size: 12px; color: var(--ink-2); }
.kpi .v { font: 500 26px/1.15 var(--f-mono); letter-spacing: -0.02em; margin-top: 4px; }
.kpi .v small { font-size: 12px; color: var(--ink-3); }
.kpi .d { font: 400 11px var(--f-mono); color: var(--ink-3); margin-top: 2px; }

/* 시뮬레이터 */
.sim-stage { position: relative; background: #121211; border-radius: var(--r); overflow: hidden; }
.sim-stage canvas { display: block; width: 100%; }
.sim-stage .hud { position: absolute; left: 12px; top: 10px; font: 500 10.5px var(--f-mono); color: #bdbbb3; letter-spacing: 0.08em; }
.sim-stage .hud b { color: #fff; font-weight: 500; }
.param { padding: 10px 0 12px; border-bottom: 1px solid var(--line-2); }
.param:last-child { border-bottom: 0; }
.param .top { display: flex; justify-content: space-between; align-items: baseline; }
.param .nm { font-size: 12.5px; font-weight: 500; }
.param .nm .sym { font: 500 11px var(--f-mono); color: var(--ink-3); margin-right: 6px; }
.param .val { font: 500 15px var(--f-mono); }
.param .val small { font-size: 11px; color: var(--ink-3); font-weight: 400; }
.param .ref { display: flex; justify-content: space-between; font: 400 10.5px var(--f-mono); color: var(--ink-3); margin-top: 2px; }

/* 문서 */
.doc { max-width: 880px; }
.doc h4 { font-size: 15px; margin: 26px 0 8px; }
.doc p, .doc li { color: var(--ink-2); line-height: 1.75; font-size: 13.5px; }
.doc .eq { font: 400 13px var(--f-mono); background: var(--surface-2); border-left: 2px solid var(--ink); padding: 10px 14px; margin: 10px 0; overflow-x: auto; }
.doc ol.ref li { font-size: 12.5px; }

.empty { padding: 40px; text-align: center; color: var(--ink-3); font-size: 13px; }
.skeleton { background: linear-gradient(90deg, var(--line-2), var(--surface-2), var(--line-2)); background-size: 200% 100%;
  animation: sk 1.2s infinite linear; border-radius: var(--r); }
@keyframes sk { to { background-position: -200% 0; } }
[hidden] { display: none !important; }
input[type=file] { font-size: 12px; color: var(--ink-2); }
input[type=file]::file-selector-button { font: 500 12px var(--f-sans); height: 30px; padding: 0 12px; margin-right: 10px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--surface); color: var(--ink); cursor: pointer; }
input[type=file]::file-selector-button:hover { border-color: var(--ink); }

@media (max-width: 1280px) {
  .c3, .c4, .c5 { grid-column: span 6; } .c7, .c8, .c9 { grid-column: span 12; } .c6 { grid-column: span 12; }
  .small-multiples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .small-multiples > div:nth-child(2n) { border-right: 0; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; min-width: 0; }
  .topbar { gap: 10px; } .topbar .crumb, .topbar .chip.warn { display: none; }
  .panel > header, .verdict { flex-wrap: wrap; }
  .panel > header .sp { flex-basis: 100%; height: 0; }
  .nav { display: flex; overflow-x: auto; padding: 0; }
  .nav a { grid-template-columns: auto; border-left: 0; border-bottom: 2px solid transparent; padding: 10px 14px; white-space: nowrap; }
  .nav a .no, .nav .grp, .rail-foot { display: none; }
  .nav a.on { border-bottom-color: var(--ink); }
  .c3, .c4, .c5, .c6 { grid-column: span 12; }
  .sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cell:nth-child(2n) { border-right: 0; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .small-multiples { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
