*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f7;
  --card: rgba(255,255,255,0.92);
  --border: rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.05);
  --text: #1d1d1f;
  --text2: #6e6e73;
  --text3: #aeaeb2;
  --blue: #0071e3;
  --red: #ff3b30;
  --red-soft: rgba(255,59,48,0.1);
  --orange: #ff9f0a;
  --green: #28a745;
  --green-soft: rgba(52,199,89,0.12);
  --teal: #30b0c7;
  --teal-dark: #1a7a8a;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Noto Sans KR', BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 13px; }

.titlebar {
  height: 52px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.titlebar-left, .titlebar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.home-btn { color: var(--teal); text-decoration: none; font-weight: 500; padding: 5px 8px; border-radius: 8px; white-space: nowrap; }
.home-btn:hover { background: rgba(48,176,199,0.08); }
.titlebar-divider { width: 1px; height: 16px; background: var(--border); }
.app-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(145deg, #30b0c7, #1a8fa8);
  display: flex; align-items: center; justify-content: center;
}
.app-icon svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-name { font-size: 15px; font-weight: 600; letter-spacing: -0.3px; white-space: nowrap; }
.app-sub { color: var(--text2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.off { background: rgba(118,118,128,0.12); color: var(--text2); }
.pill.on { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--red-soft); color: var(--red); }

.estop {
  background: var(--red); color: #fff; border: none; border-radius: 8px;
  padding: 7px 14px; font-weight: 700; cursor: pointer; letter-spacing: 0.02em;
}
.estop:disabled { opacity: 0.35; cursor: default; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 20px 60px; }

.card {
  background: var(--card); border: 1px solid var(--border2); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 14px;
}
.s-title { font-size: 11px; font-weight: 600; color: var(--text2); letter-spacing: 0.4px; margin-bottom: 10px; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.field > span { font-size: 11px; font-weight: 500; color: var(--text2); }
.field.check { flex-direction: row; align-items: center; gap: 6px; min-width: auto; height: 34px; }

input[type=number], input[type=text], select {
  height: 34px; background: rgba(118,118,128,0.08); border: 1px solid transparent;
  border-radius: 8px; padding: 0 10px; color: var(--text); outline: none;
}
input:focus, select:focus { border-color: var(--teal); background: rgba(48,176,199,0.05); }
input:disabled, select:disabled { opacity: 0.5; }

.btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.12);
  background: rgba(118,118,128,0.08); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: rgba(118,118,128,0.16); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--teal-dark); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: default; }

.msg { margin-top: 8px; font-size: 12px; color: var(--text2); min-height: 16px; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }

.live {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px;
}
.tile { background: var(--card); border: 1px solid var(--border2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.tile .k { font-size: 11px; color: var(--text2); }
.tile .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .v small { font-size: 12px; font-weight: 400; color: var(--text2); margin-left: 2px; }
.tile.alarm { background: var(--red-soft); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button {
  border: none; background: transparent; padding: 7px 12px; border-radius: 8px;
  color: var(--text2); cursor: pointer; font-weight: 500; position: relative;
}
.tabs button:hover { background: rgba(118,118,128,0.1); }
.tabs button.active { background: var(--text); color: #fff; }
.tabs button .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; vertical-align: 1px; }
.dot.pass { background: var(--green); }
.dot.fail { background: var(--red); }
.dot.info { background: var(--text3); }

.banner { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 12px; }
.banner ul { margin-left: 18px; }

.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 14px; }
.grid > .card { margin-bottom: 14px; }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form .field { min-width: 0; }
.form .field input, .form .field select { width: 100%; }
.form .field.crit > span::after {
  content: '기준'; margin-left: 6px; font-size: 10px; font-weight: 600; color: var(--teal-dark);
  background: rgba(48,176,199,0.12); padding: 1px 5px; border-radius: 4px;
}
.form .field .help { font-size: 11px; color: var(--text3); line-height: 1.35; }
.form .field.wide { grid-column: 1 / -1; }

.run-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.verdict { margin-left: auto; font-weight: 700; font-size: 15px; padding: 4px 12px; border-radius: 8px; }
.verdict.pass { background: var(--green-soft); color: var(--green); }
.verdict.fail { background: var(--red-soft); color: var(--red); }
.verdict.info { background: rgba(118,118,128,0.12); color: var(--text2); }

.progress { height: 6px; background: rgba(118,118,128,0.12); border-radius: 3px; margin: 12px 0 4px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--teal); transition: width 0.15s; }
.prog-text { font-size: 11px; color: var(--text2); min-height: 14px; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border2); }
th { font-size: 11px; font-weight: 600; color: var(--text2); }
td.num { text-align: right; font-family: var(--mono); font-size: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.badge.pass { background: var(--green-soft); color: var(--green); }
.badge.fail { background: var(--red-soft); color: var(--red); }
.badge.info { background: rgba(118,118,128,0.12); color: var(--text2); }
.metrics { margin-top: 10px; }

.warnings { list-style: none; margin-top: 10px; }
.warnings li { font-size: 12px; color: #9a6700; background: rgba(255,159,10,0.1); padding: 6px 10px; border-radius: 6px; margin-top: 4px; }

.chart-box { position: relative; height: 320px; }
.chart-box.small { height: 220px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }

.manual-big { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; }
.manual-big input { font-size: 28px; height: 52px; width: 160px; font-weight: 600; }
.manual-big span { font-size: 20px; color: var(--text2); }
input[type=range] { width: 100%; margin: 8px 0 12px; accent-color: var(--teal); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.hint { font-size: 11px; color: var(--text3); margin-top: 8px; }
.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.readout .k { font-size: 12px; color: var(--text2); }
.readout .v { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }

.log {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  background: #1d1d1f; color: #e5e5ea; border-radius: 8px; padding: 10px 12px;
  height: 460px; overflow: auto; white-space: pre; margin-top: 10px;
}

.report-head { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 16px; margin-bottom: 14px; }
.report-head div { font-size: 12px; }
.report-head b { color: var(--text2); font-weight: 500; margin-right: 6px; }
.overall { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.overall.pass { color: var(--green); }
.overall.fail { color: var(--red); }
pre.json { font-family: var(--mono); font-size: 11px; max-height: 360px; overflow: auto; background: rgba(118,118,128,0.06); padding: 10px; border-radius: 8px; margin-top: 8px; }

[hidden] { display: none !important; }

@media (max-width: 900px) {
  .grid, .chart-grid { grid-template-columns: 1fr; }
  .live { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .app-sub { display: none; }
}

@media print {
  body { background: #fff; }
  .titlebar, .conn, .live, .tabs, .banner, .panel:not([data-panel=report]), .report-controls { display: none !important; }
  .panel[data-panel=report] { display: block !important; }
  .card { border: none; padding: 0; }
}

.badge.run { background: rgba(0,113,227,0.12); color: var(--blue); }
.rep-h2 { font-size: 14px; font-weight: 600; margin: 22px 0 8px; }
.rep-item { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 14px; }
.rep-item h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.rep-charts { margin-top: 12px; }
.rep-detail { margin-top: 10px; }

@media print {
  .rep-item { break-inside: avoid; }
  .rep-h2 { break-after: avoid; }
  .chart-box { height: 240px; }
}

#autoSteps td:first-child, #autoSteps td.num, #repBody td.num, #repBody tr > td:first-child { white-space: nowrap; }

/* 사이트 간 순환 화살표. 본문(최대 1180px)과 겹치지 않는 넓은 화면에서만 — 좁으면 조작 버튼을 가린다 */
.portal-arrow {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 90;
  width: 44px; height: 44px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12); color: var(--text2); text-decoration: none;
  transition: box-shadow 0.2s ease, color 0.2s ease;
}
.portal-arrow svg { width: 18px; height: 18px; }
.portal-arrow:hover { color: var(--blue); box-shadow: 0 2px 10px rgba(0,0,0,0.16); }
.portal-arrow.left { left: 14px; }
.portal-arrow.right { right: 14px; }
@media (max-width: 1240px) { .portal-arrow { display: none; } }
@media print { .portal-nav { display: none !important; } }

/* ── 연결 바 · 접이식 설정 ─────────────────────────────── */
.conn-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.conn-state { display: flex; align-items: center; gap: 10px; min-width: 0; }
.conn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text3); flex-shrink: 0; box-shadow: 0 0 0 4px rgba(174,174,178,0.18); }
.conn-dot.on { background: #34c759; box-shadow: 0 0 0 4px rgba(52,199,89,0.18); }
.conn-dot.warn { background: var(--red); box-shadow: 0 0 0 4px rgba(255,59,48,0.18); }
.conn-title { font-size: 14px; font-weight: 600; }
.conn-sub { font-size: 12px; color: var(--text2); margin-top: 1px; }
.conn-actions { display: flex; gap: 8px; flex-wrap: wrap; }

details.fold > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--text2);
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: ''; width: 6px; height: 6px; flex-shrink: 0;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.18s ease; margin-right: 2px;
}
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > summary:hover { color: var(--text); }
.fold-hint { font-weight: 400; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fold-body { margin-top: 12px; }
.conn details.fold { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border2); }
details.card.fold > summary { font-size: 13px; color: var(--text); }

/* ── 자동 시험 히어로 ──────────────────────────────────── */
.hero { padding: 22px 24px; background: linear-gradient(180deg, #ffffff 0%, rgba(255,255,255,0.92) 100%); box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.04); }
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.hero-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--teal-dark); text-transform: uppercase; }
.hero-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.hero-head > div { flex: 1; min-width: 0; }
.hero-desc { font-size: 12px; color: var(--text2); margin-top: 6px; line-height: 1.55; }

.viz { display: flex; align-items: center; gap: 26px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border2); }
.ring-track { fill: none; stroke: rgba(118,118,128,0.12); stroke-width: 10; }
.ring-fill { fill: none; stroke: url(#ringGrad); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.35s ease, stroke 0.3s ease; }
.ring-fill.pass { stroke: #34c759; }
.ring-fill.fail { stroke: var(--red); }

.viz-main { flex: 1; min-width: 0; }
.viz-stats { display: flex; align-items: flex-end; gap: 26px; margin-bottom: 14px; flex-wrap: wrap; }
.stat .k { font-size: 11px; color: var(--text2); }
.stat .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat .v.pass { color: var(--green); }
.stat .v.fail { color: var(--red); }

.track { display: flex; gap: 5px; }
.seg { min-width: 56px; display: flex; flex-direction: column; gap: 6px; }
.seg-bar { position: relative; height: 12px; border-radius: 6px; background: rgba(118,118,128,0.12); overflow: hidden; }
.seg-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 6px; transition: width 0.3s ease, background 0.3s ease; }
.seg-label { font-size: 11px; font-weight: 600; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-time { font-size: 10px; color: var(--text3); margin-top: -4px; font-variant-numeric: tabular-nums; }
.seg.run .seg-fill {
  background: linear-gradient(90deg, #30b0c7, #0a84d6);
  background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,0.22) 0 6px, transparent 6px 12px), linear-gradient(90deg, #30b0c7, #0a84d6);
  background-size: 17px 17px, 100% 100%;
  animation: seg-stripes 0.9s linear infinite;
}
.seg.run .seg-label { color: var(--blue); }
.seg.pass .seg-fill { width: 100%; background: #34c759; }
.seg.info .seg-fill { width: 100%; background: #8e9bb0; }
.seg.fail .seg-fill, .seg.error .seg-fill, .seg.aborted .seg-fill { width: 100%; background: var(--red); }
.seg.fail .seg-label, .seg.error .seg-label, .seg.aborted .seg-label { color: var(--red); }
.seg.skip .seg-bar { background: repeating-linear-gradient(-45deg, rgba(118,118,128,0.14) 0 4px, rgba(118,118,128,0.06) 4px 8px); }
.seg.skip .seg-label { color: var(--text3); }
@keyframes seg-stripes { from { background-position: 0 0, 0 0; } to { background-position: 17px 0, 0 0; } }
@media (prefers-reduced-motion: reduce) { .seg.run .seg-fill { animation: none; } }

.auto-chip {
  border: none; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 5px 11px; border-radius: 999px; color: #0a6ea8; background: rgba(10,132,214,0.1);
  font-variant-numeric: tabular-nums;
}
.auto-chip.pass { color: var(--green); background: var(--green-soft); }
.auto-chip.fail { color: var(--red); background: var(--red-soft); }

.run-card { margin-bottom: 14px; }

@media (max-width: 900px) {
  .viz { flex-direction: column; align-items: stretch; }
}
@media print { .hero, .auto-chip { display: none !important; } }

.msg:empty { display: none; }
#autoText { margin-top: 12px; }

.badge { white-space: nowrap; }

/* ── 원형 버튼: 대기=시작, 진행=진행률, 완료=판정·성적서 보기 ── */
.ring-group { position: relative; width: 156px; height: 156px; flex-shrink: 0; }
.ring-btn {
  position: relative; display: block; width: 156px; height: 156px; padding: 0; border: none; border-radius: 50%;
  background: transparent; cursor: pointer; font: inherit; color: var(--text);
  transition: transform 0.18s ease;
}
.ring-btn:focus-visible { outline: 3px solid rgba(10,132,214,0.35); outline-offset: 4px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring-center {
  position: absolute; inset: 15px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  transition: background 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
}
.ring-icon svg { width: 34px; height: 34px; fill: currentColor; margin-left: 5px; display: block; }
.ring-pct { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.ring-pct small { font-size: 14px; font-weight: 600; color: var(--text2); margin-left: 1px; }
.ring-pct.big { font-size: 28px; letter-spacing: -0.01em; }
.ring-pct.pass { color: var(--green); }
.ring-pct.fail { color: var(--red); }
.ring-label { font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: 0.01em; }

.ring-btn[data-phase=idle]:not(:disabled) .ring-center {
  background: linear-gradient(135deg, #30b0c7 0%, #0a84d6 100%); color: #fff;
  box-shadow: 0 10px 26px rgba(10,132,214,0.30), inset 0 1px 0 rgba(255,255,255,0.28);
}
.ring-btn[data-phase=idle]:not(:disabled) .ring-label { color: #fff; }
.ring-btn[data-phase=idle]:not(:disabled):hover { transform: scale(1.035); }
.ring-btn[data-phase=idle]:not(:disabled):active { transform: scale(0.99); }
.ring-btn[data-phase=idle]:not(:disabled) .ring-track { stroke: rgba(48,176,199,0.16); }
.ring-btn[data-phase=idle]:disabled { cursor: default; }
.ring-btn[data-phase=idle]:disabled .ring-center { background: rgba(118,118,128,0.07); color: var(--text3); }
.ring-btn[data-phase=idle]:disabled .ring-label { color: var(--text3); }
.ring-btn[data-phase=run] { cursor: default; }
.ring-btn[data-phase=run] .ring-center { background: #fff; }
.ring-btn[data-phase=done] .ring-center { background: rgba(52,199,89,0.08); }
.ring-btn[data-phase=done].fail .ring-center { background: rgba(255,59,48,0.07); }
.ring-btn[data-phase=done]:hover { transform: scale(1.03); }
.ring-btn[data-phase=done]:hover .ring-label { color: var(--blue); }

.ring-side {
  position: absolute; right: -2px; bottom: 6px; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
  background: #fff; border: 1px solid var(--border); color: var(--text2);
  box-shadow: 0 3px 10px rgba(0,0,0,0.12); transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.ring-side svg { width: 16px; height: 16px; fill: currentColor; }
.ring-side svg.stroke { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ring-side:hover:not(:disabled) { transform: scale(1.08); }
.ring-side.stop { color: var(--red); }
.ring-side.stop:hover { background: #fff5f4; }
.ring-side.restart { color: var(--blue); }
.ring-side.restart:hover:not(:disabled) { background: #f2f8fe; }
.ring-side:disabled { opacity: 0.4; cursor: default; }

a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.guide-link { font-size: 12px; font-weight: 600; color: var(--teal-dark); text-decoration: none; white-space: nowrap; padding: 4px 8px; border-radius: 8px; }
.guide-link:hover { background: rgba(48,176,199,0.08); }
