:root {
  color-scheme: dark;
  --bg: #071119;
  --panel: #0d1b26;
  --panel-2: #122838;
  --text: #eef7fb;
  --muted: #9fb4c0;
  --line: rgba(255, 255, 255, 0.12);
  --red: #d92e32;
  --orange: #d98b28;
  --blue: #2c81b7;
  --green: #2bd882;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

button {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(440px, 520px) minmax(0, 1fr);
  height: 100vh;
  min-height: 720px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  overflow: auto;
  background: linear-gradient(180deg, rgba(16, 42, 58, 0.96), rgba(7, 17, 25, 0.98));
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  background: var(--red);
  border-radius: 8px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand p,
.eyebrow {
  margin: 0;
  color: #b9d4e1;
  font-size: 13px;
  font-weight: 700;
}

.brand h1 {
  margin: 3px 0 0;
  font-size: 24px;
}

.summary,
.insight-card,
.timeline,
.source-panel,
.command-panel,
.crew-panel,
.welding-panel,
.reference {
  padding: 18px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary h2 {
  margin: 8px 0 10px;
  font-size: 20px;
  line-height: 1.32;
}

.summary p:last-child,
.insight-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metrics article {
  padding: 14px;
  background: #081923;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 28px;
}

.scenario-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scenario-tabs button {
  min-height: 42px;
  color: var(--text);
  background: #10283a;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.scenario-tabs button.active {
  background: #e6f5fb;
  color: #071119;
  border-color: transparent;
  font-weight: 800;
}

.insight-card h3,
.section-title h3 {
  margin: 6px 0 8px;
  font-size: 18px;
}

.route-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.route-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  background: rgba(9, 22, 31, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #d8edf5;
  font-size: 13px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.gantt {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 8px 4px;
  margin-top: 10px;
}

.gantt div {
  grid-column: var(--start) / span var(--span);
  min-height: 34px;
  padding: 8px 10px;
  background: linear-gradient(90deg, #1a74a5, #2bd882);
  border-radius: 6px;
  color: #031219;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.process-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0 12px;
}

.process-filter button {
  min-height: 34px;
  padding: 7px 8px;
  color: #dff2f8;
  background: #0a1d29;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.process-filter button.active {
  color: #06131a;
  background: #9ce7ff;
  border-color: transparent;
  font-weight: 800;
}

.schedule-board {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 12, 18, 0.45);
}

.schedule-header,
.schedule-row {
  display: grid;
  grid-template-columns: 82px repeat(12, minmax(18px, 1fr));
  align-items: center;
}

.schedule-header {
  min-height: 28px;
  background: rgba(255, 255, 255, 0.065);
  color: #b9d4e1;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.schedule-header span:first-child {
  text-align: left;
  padding-left: 10px;
}

.schedule-rows {
  display: grid;
}

.schedule-row {
  position: relative;
  width: 100%;
  min-height: 38px;
  margin: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  text-align: left;
}

.schedule-row::before {
  content: "";
  grid-column: 2 / -1;
  grid-row: 1;
  align-self: stretch;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(8.333% - 1px),
    rgba(255, 255, 255, 0.08) calc(8.333% - 1px),
    rgba(255, 255, 255, 0.08) 8.333%
  );
}

.schedule-row.active {
  background: rgba(156, 231, 255, 0.09);
}

.schedule-name {
  z-index: 1;
  padding-left: 10px;
  color: #dff2f8;
  font-size: 12px;
  font-weight: 800;
}

.schedule-bar {
  z-index: 1;
  grid-column: calc(var(--start) + 1) / span var(--span);
  grid-row: 1;
  min-height: 22px;
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--bar);
  color: #06131a;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 0 18px color-mix(in srgb, var(--bar) 55%, transparent);
}

.schedule-row.delayed .schedule-bar {
  background: #ffbd5b;
}

.schedule-row.done .schedule-bar {
  background: #5de0a2;
}

.block-inspector {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  background: rgba(9, 22, 31, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.block-inspector h4 {
  margin: 4px 0 0;
  font-size: 16px;
}

.block-inspector dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.block-inspector dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.block-inspector dt {
  color: var(--muted);
  font-size: 12px;
}

.block-inspector dd {
  margin: 0;
  color: #eef7fb;
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.source-grid,
.crew-board {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.command-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  margin-top: 10px;
}

.command-form input {
  min-width: 0;
  min-height: 40px;
  padding: 0 11px;
  color: var(--text);
  background: #071923;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.command-form input:focus {
  border-color: rgba(156, 231, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(156, 231, 255, 0.12);
}

.command-form button {
  min-height: 40px;
  color: #071119;
  background: #9ce7ff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.command-result {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 10px;
  background: rgba(9, 22, 31, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.command-result strong {
  color: #eef7fb;
  font-size: 12px;
}

.command-result span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.source-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.source-grid article,
.crew-row {
  padding: 10px;
  background: rgba(9, 22, 31, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.source-grid strong,
.crew-row strong {
  display: block;
  margin-bottom: 4px;
  color: #eef7fb;
  font-size: 12px;
}

.source-grid span,
.crew-row span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.crew-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 10px;
}

.crew-row.active {
  border-color: rgba(156, 231, 255, 0.6);
  background: rgba(156, 231, 255, 0.1);
}

.crew-meter {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.crew-meter i {
  display: block;
  width: var(--load);
  height: 100%;
  background: linear-gradient(90deg, #5de0a2, #9ce7ff);
}

.crew-count {
  color: #eef7fb;
  font-size: 12px;
  font-weight: 900;
}

.welding-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.welding-kpis article {
  padding: 10px;
  background: rgba(9, 22, 31, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.welding-kpis span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.welding-kpis strong {
  display: block;
  margin-top: 4px;
  color: #eef7fb;
  font-size: 20px;
}

.arc-chart {
  margin-top: 10px;
  padding: 10px;
  background: rgba(9, 22, 31, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.arc-chart svg {
  display: block;
  width: 100%;
  height: 104px;
}

.arc-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arc-line.voltage {
  stroke: #ffbd5b;
  filter: drop-shadow(0 0 6px rgba(255, 189, 91, 0.45));
}

.arc-line.current {
  stroke: #9ce7ff;
  filter: drop-shadow(0 0 6px rgba(156, 231, 255, 0.45));
}

.arc-axis {
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 2;
}

.arc-legend,
.welding-features {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.arc-legend span,
.welding-features span {
  padding: 6px 8px;
  color: #dff2f8;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  font-size: 11px;
}

.arc-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 50%;
}

.arc-legend .voltage {
  background: #ffbd5b;
}

.arc-legend .current {
  background: #9ce7ff;
}

.welding-cells {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.welding-cells button {
  min-height: 58px;
  padding: 8px;
  color: #dff2f8;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.welding-cells button.active {
  background: rgba(255, 189, 91, 0.15);
  border-color: rgba(255, 189, 91, 0.55);
}

.welding-cells strong,
.welding-cells span {
  display: block;
}

.welding-cells strong {
  color: #fff2cf;
  font-size: 12px;
}

.welding-cells span {
  margin-top: 3px;
  color: #a8c9d8;
  font-size: 10px;
  line-height: 1.35;
}

.measurement-methods {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.measurement-methods article {
  padding: 10px;
  background: rgba(255, 255, 255, 0.052);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.measurement-methods span,
.measurement-methods em {
  display: block;
  color: #a8c9d8;
  font-size: 10px;
  font-style: normal;
  line-height: 1.45;
}

.measurement-methods strong {
  display: block;
  margin: 4px 0;
  color: #eef7fb;
  font-size: 12px;
  line-height: 1.35;
}

.arc-signal-table {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.signal-head,
.signal-row {
  display: grid;
  grid-template-columns: 72px 76px minmax(110px, 1fr) minmax(110px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
}

.signal-head {
  color: #fff2cf;
  background: rgba(255, 189, 91, 0.12);
  font-size: 10px;
  font-weight: 800;
}

.signal-row {
  color: #cfe6ee;
  background: rgba(255, 255, 255, 0.035);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 10px;
  line-height: 1.35;
}

.signal-row strong {
  color: #eef7fb;
  font-size: 11px;
}

.defect-rules {
  margin-top: 10px;
  padding: 10px;
  background: rgba(255, 91, 91, 0.08);
  border: 1px solid rgba(255, 91, 91, 0.22);
  border-radius: 8px;
}

.defect-rules > strong {
  display: block;
  color: #ffe1e1;
  font-size: 12px;
}

.defect-rules div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.defect-rules span {
  padding: 6px 8px;
  color: #ffeceb;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  font-size: 10px;
}

.reference img {
  display: block;
  width: 100%;
  max-height: 170px;
  object-fit: cover;
  object-position: 72% 18%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #071119;
}

.scene,
.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.scene-overlay {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

.scene-overlay.top {
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.scene-overlay.top > div:first-child {
  padding: 14px 16px;
  background: rgba(5, 18, 27, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.scene-overlay p {
  margin: 0 0 3px;
  color: #a8c9d8;
  font-size: 12px;
  font-weight: 800;
}

.scene-overlay strong {
  font-size: 22px;
}

.status-strip,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-strip span,
.legend span {
  padding: 8px 10px;
  background: rgba(5, 18, 27, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #d9edf4;
  font-size: 12px;
  backdrop-filter: blur(10px);
}

.legend {
  left: 18px;
  bottom: 18px;
  right: 18px;
  justify-content: flex-start;
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
}

.legend .red {
  background: var(--red);
}

.legend .orange {
  background: var(--orange);
}

.legend .blue {
  background: var(--blue);
}

.legend .green {
  background: var(--green);
}

.legend .yellow {
  background: #f2c94c;
}

.legend .cyan {
  background: #9ce7ff;
}

.callouts {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.stage-schedule {
  position: absolute;
  z-index: 5;
  right: 18px;
  bottom: 68px;
  width: min(380px, calc(100% - 36px));
  padding: 12px;
  background: rgba(5, 18, 27, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.stage-welding {
  position: absolute;
  z-index: 5;
  right: 18px;
  top: 96px;
  width: min(300px, calc(100% - 36px));
  padding: 12px;
  background: rgba(5, 18, 27, 0.78);
  border: 1px solid rgba(255, 189, 91, 0.28);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.stage-welding .section-title h3 {
  margin: 0;
  font-size: 14px;
}

.stage-welding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.stage-welding-grid article {
  padding: 8px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.stage-welding-grid span {
  display: block;
  color: #b9d4e1;
  font-size: 10px;
}

.stage-welding-grid strong {
  display: block;
  margin-top: 3px;
  color: #eef7fb;
  font-size: 15px;
}

.stage-schedule .section-title h3 {
  margin: 0;
  font-size: 14px;
}

.stage-schedule-rows {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.stage-schedule-row {
  display: grid;
  grid-template-columns: 74px 1fr 46px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 6px 7px;
  color: #eef7fb;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.stage-schedule-row.active {
  background: rgba(156, 231, 255, 0.18);
  border-color: rgba(156, 231, 255, 0.55);
}

.stage-schedule-row strong {
  font-size: 11px;
}

.stage-schedule-row span {
  color: #b9d4e1;
  font-size: 10px;
}

.stage-schedule-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.stage-schedule-track i {
  display: block;
  width: var(--progress);
  height: 100%;
  background: var(--bar);
}

.callout {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 7px 9px;
  background: rgba(6, 25, 36, 0.8);
  border: 1px solid rgba(185, 230, 255, 0.5);
  border-radius: 6px;
  color: #eef9ff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .control-panel {
    max-height: none;
  }

  .stage {
    height: 72vh;
  }

  .scene-overlay.top {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .control-panel {
    padding: 16px;
  }

  .metrics,
  .scenario-tabs {
    grid-template-columns: 1fr;
  }

  .measurement-methods,
  .signal-head,
  .signal-row,
  .welding-cells {
    grid-template-columns: 1fr;
  }

  .status-strip {
    display: none;
  }

  .stage-schedule {
    display: none;
  }

  .scene-overlay strong {
    font-size: 18px;
  }
}
