:root {
  --bg: #0f1420;
  --panel: #161d2c;
  --panel-2: #1c2536;
  --line: #273040;
  --line-soft: #202a3a;
  --text: #e6ebf3;
  --text-dim: #97a3b6;
  --text-faint: #6b7688;
  --accent: #4c8dff;
  --green: #1fae5e;
  --yellow: #e8a317;
  --red: #e0546b;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --sans: 'Inter', -apple-system, 'Malgun Gothic', '맑은 고딕', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ------------------------------------------------------------------ header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  background: linear-gradient(180deg, #18202f 0%, #141b28 100%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.logo-section { display: flex; align-items: center; gap: 13px; min-width: 0; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 40px;
  background: linear-gradient(135deg, #4c8dff 0%, #7c5cff 100%);
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
}
.title-group h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.title-group span { font-size: 11.5px; color: var(--text-dim); }
.header-actions { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }

.status-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 11.5px; font-family: var(--mono); color: var(--text-dim);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }
.status-badge.ready .status-dot { background: var(--green); }
.status-badge.error .status-dot { background: var(--red); }

.btn {
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  transition: all .14s ease;
}
.btn:hover { background: #232e42; border-color: #35415a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3d7ded; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: 296px 1fr; align-items: start; }
@media (max-width: 1080px) { .shell { grid-template-columns: 1fr; } }

.sidebar {
  padding: 18px 16px 40px;
  border-right: 1px solid var(--line);
  background: #131a27;
  position: sticky; top: 69px;
  max-height: calc(100vh - 69px); overflow-y: auto;
}
@media (max-width: 1080px) { .sidebar { position: static; max-height: none; } }

.main { padding: 18px 22px 60px; min-width: 0; }

.side-title {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); margin: 20px 0 10px;
}
.side-title:first-child { margin-top: 0; }

/* ----------------------------------------------------------------- control */
.ctrl { margin-bottom: 15px; }
.ctrl-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.ctrl-head label { font-size: 12.5px; color: var(--text-dim); }
.ctrl-head output { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }

input[type=range] {
  width: 100%; height: 4px; border-radius: 3px; appearance: none;
  background: var(--line); outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid #101724; cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #101724; cursor: pointer;
}
.ctrl-range { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-faint); font-family: var(--mono); }

.spec-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.spec-row label { font-size: 11.5px; color: var(--text-dim); }
.spec-row input {
  width: 72px; padding: 4px 7px; text-align: right;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); font-family: var(--mono); font-size: 12px;
}
.fixed-list { font-size: 11.5px; color: var(--text-dim); font-family: var(--mono); }
.fixed-list div { display: flex; justify-content: space-between; padding: 3px 0; }
.fixed-list b { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------------ panels */
.section-head { display: flex; align-items: baseline; gap: 11px; margin: 26px 0 12px; }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { margin: 0; font-size: 16px; font-weight: 660; letter-spacing: -.15px; }
.section-head p { margin: 0; font-size: 12px; color: var(--text-dim); }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 13px; padding: 15px 17px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2.wide-left { grid-template-columns: 1.12fr 0.88fr; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 1240px) { .grid2, .grid2.wide-left, .grid3 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- verdict */
.verdict {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 16px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--line);
  margin-bottom: 13px;
}
.verdict .recipe { font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); }
.verdict .recipe b { color: var(--text); }
.chip {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 800; color: #fff; letter-spacing: .04em;
}

.warn {
  display: flex; gap: 10px; padding: 11px 14px; margin-bottom: 12px;
  border-radius: 10px; font-size: 12.5px; line-height: 1.6;
  background: rgba(232,163,23,.09); border: 1px solid rgba(232,163,23,.30); color: #f0cd85;
}

/* ------------------------------------------------------------------- kpis */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 11px; margin-bottom: 6px; }
@media (max-width: 1400px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .kpis { grid-template-columns: repeat(2, 1fr); } }

.kpi {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--line); border-radius: 11px; padding: 11px 13px;
}
.kpi .name { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); margin-bottom: 3px; }
.kpi .val { font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: -.5px; }
.kpi .unit { font-size: 11.5px; color: var(--text-dim); font-weight: 500; margin-left: 3px; }
.kpi .sub { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); margin-top: 3px; }
.kpi .chip { font-size: 9.5px; padding: 1px 7px; }

.note { font-size: 11.5px; color: var(--text-faint); line-height: 1.65; margin: 9px 2px 0; }

/* ----------------------------------------------------------------- canvas */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { display: block; width: 100%; }
.cap { font-size: 11px; color: var(--text-faint); margin-top: 8px; line-height: 1.55; }

/* ------------------------------------------------------------------ table */
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th, table.data td {
  padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); white-space: nowrap;
}
table.data th {
  font-family: var(--sans); font-size: 11px; font-weight: 600; color: var(--text-dim);
  text-align: right; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--panel);
}
table.data td:first-child, table.data th:first-child { text-align: left; font-family: var(--sans); }
table.data tbody tr:hover { background: rgba(76,141,255,.06); }
.table-scroll { max-height: 420px; overflow: auto; }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button {
  padding: 5px 13px; border: 0; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--text-dim); font-family: var(--sans);
  font-size: 12px; font-weight: 550;
}
.seg button.on { background: var(--accent); color: #fff; }

details.info { margin-top: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
details.info summary { padding: 13px 17px; cursor: pointer; font-weight: 600; font-size: 13.5px; list-style: none; }
details.info summary::-webkit-details-marker { display: none; }
details.info summary::before { content: '▸ '; color: var(--text-dim); }
details.info[open] summary::before { content: '▾ '; }
details.info .body { padding: 2px 17px 17px; }
details.info h4 { margin: 14px 0 7px; font-size: 12.5px; color: var(--text); }
details.info p, details.info li { font-size: 12px; color: var(--text-dim); line-height: 1.7; }
details.info ul { margin: 6px 0; padding-left: 19px; }

.footer {
  margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--text-faint); line-height: 1.75;
}

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--text-dim); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.loading { display: grid; place-items: center; min-height: 62vh; gap: 13px; color: var(--text-dim); }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
