/* MachBeat Simulation Center v3 — stage-driven layout */

.sim-v3 { padding-top: 72px; padding-bottom: 80px; min-height: 100vh; }

/* Stage rail */
.stage-rail {
  display: flex; gap: 0; align-items: center; flex-wrap: wrap;
  padding: 14px 0 18px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.stage-item {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--mute); padding: 4px 0;
}
.stage-item .dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--line-2); background: transparent;
}
.stage-item.done { color: var(--teal); }
.stage-item.done .dot { background: var(--teal); border-color: var(--teal); }
.stage-item.current { color: var(--orange); font-weight: 700; }
.stage-item.current .dot {
  background: var(--orange); border-color: var(--orange);
  box-shadow: 0 0 10px var(--orange);
}
.stage-sep { width: 24px; height: 1px; background: var(--line-2); margin: 0 6px; }

.sim-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; padding: 5px 11px; border-radius: 999px;
  background: var(--orange-soft); color: var(--orange);
  border: 1px solid rgba(255,106,0,.45); font-weight: 700;
}

.sim-intro { margin: 18px 0 24px; }
.sim-intro h1 { font-size: clamp(26px, 3.5vw, 36px); margin: 10px 0 8px; }
.sim-intro .sub { color: var(--ink-2); max-width: 54ch; font-size: 15px; }
.sim-intro .disclaimer { font-size: 12px; color: var(--mute); margin-top: 10px; }

/* Sticky status bar */
.status-bar {
  position: sticky; top: 70px; z-index: 40;
  display: none; flex-wrap: wrap; gap: 16px 28px; align-items: center;
  padding: 12px 18px; margin-bottom: 20px;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 12px; backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.status-bar.visible { display: flex; }
.status-bar .sb-id { font-weight: 800; font-size: 14px; }
.status-bar .sb-status {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: .08em; display: flex; align-items: center; gap: 6px;
}
.status-bar .sb-metric { font-size: 12px; color: var(--ink-2); }
.status-bar .sb-metric strong { color: var(--ink); font-size: 14px; }

.dot-status {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.dot-status.HEALTHY { background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.dot-status.DEGRADING { background: #e8a317; }
.dot-status.WARNING { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.dot-status.CRITICAL { background: #ff4455; animation: pulse 1s infinite; }
.dot-status.FAILED { background: #666; }
@keyframes pulse { 50% { opacity: .4; } }

/* Stage panels */
.stage-panel { display: none; animation: fadeIn .35s ease; }
.stage-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Configure */
.cfg-grid {
  display: grid; grid-template-columns: 1fr 1.2fr; gap: 24px; align-items: start;
}
@media (max-width: 860px) { .cfg-grid { grid-template-columns: 1fr; } }

.cfg-card, .panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px;
}
.cfg-card h2, .panel > h2 {
  font-size: 11px; font-family: var(--mono); letter-spacing: .14em;
  text-transform: uppercase; color: var(--mute); margin-bottom: 16px;
}
.cfg-card label {
  display: block; font-family: var(--mono); font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--mute);
  margin: 14px 0 6px;
}
.cfg-card label:first-of-type { margin-top: 0; }
.cfg-card input, .cfg-card select {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink); font-size: 14px;
}

.scenario-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
@media (max-width: 520px) { .scenario-grid { grid-template-columns: 1fr; } }
.scenario-card {
  text-align: left; padding: 16px; border-radius: 12px;
  border: 1px solid var(--line-2); cursor: pointer; min-height: 88px;
  transition: border-color .15s, background .15s;
}
.scenario-card:hover { border-color: var(--ink-2); }
.scenario-card.active {
  border-color: var(--orange); background: var(--orange-soft);
}
.scenario-card strong { display: block; font-size: 13px; margin-bottom: 4px; }
.scenario-card span { font-size: 12px; color: var(--mute); line-height: 1.4; }

.scenario-info {
  margin-top: 14px; padding: 14px; border-radius: 10px;
  background: var(--bg-2); font-size: 13px; line-height: 1.55; color: var(--ink-2);
}
.scenario-info h3 { font-size: 14px; color: var(--ink); margin-bottom: 6px; }
.scenario-info .watch { margin-top: 8px; font-size: 12px; }

.speed-row { display: flex; gap: 6px; flex-wrap: wrap; }
.speed-btn {
  flex: 1; min-width: 48px; padding: 9px 4px; border-radius: 8px;
  border: 1px solid var(--line-2); font-family: var(--mono); font-size: 12px; font-weight: 600;
}
.speed-btn.active { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); }

.cfg-actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
.cfg-actions .btn-primary { min-width: 200px; height: 52px; font-size: 15px; }

.mode-row { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.mode-btn {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-2);
  font-size: 11px; font-weight: 600;
}
.mode-btn.active { background: var(--orange); color: #140a02; border-color: var(--orange); }

/* Observe — machine hero */
.machine-hero {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; margin-bottom: 16px;
}
@media (max-width: 800px) { .machine-hero { grid-template-columns: 1fr; } }

.motor-stage {
  position: relative; min-height: 280px;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,106,0,.12), transparent 55%),
    var(--bg);
  border-radius: 14px; border: 1px solid var(--line); overflow: hidden;
}
.motor-stage .motor-svg { width: min(240px, 70%); height: auto; }
.motor-stage .rotor { transform-origin: 90px 90px; animation: spin 2.4s linear infinite; }
.motor-stage.DEGRADING .rotor { animation: spin 2s linear infinite, shake .4s ease-in-out infinite; }
.motor-stage.WARNING .rotor,
.motor-stage.CRITICAL .rotor { animation: spin 1.3s linear infinite, shake .28s ease-in-out infinite; }
.motor-stage.FAILED .rotor { animation: none; opacity: .35; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake {
  0%,100% { transform: rotate(0) translateX(0); }
  50% { transform: rotate(1.5deg) translateX(1px); }
}
.motor-badge {
  position: absolute; top: 14px; left: 14px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}

.machine-stats { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.stat-row .k { color: var(--mute); font-size: 12px; }
.stat-row .v { font-weight: 700; font-size: 18px; }
.health-hero { text-align: center; padding: 16px 0; }
.health-hero .num { font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -.04em; }
.health-hero .num small { font-size: 22px; color: var(--mute); font-weight: 600; }
.health-hero .delta { font-size: 12px; color: var(--mute); margin-top: 6px; }
.health-hero .delta.down { color: var(--orange); }

/* Sensor cards */
.sensor-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px;
}
@media (max-width: 900px) { .sensor-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .sensor-grid { grid-template-columns: 1fr; } }
.sensor-card {
  padding: 14px; border-radius: 12px; background: var(--card);
  border: 1px solid var(--line);
}
.sensor-card .sl {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--mute);
}
.sensor-card .sv { font-size: 26px; font-weight: 800; margin: 4px 0; letter-spacing: -.02em; }
.sensor-card .sv .u { font-size: 13px; font-weight: 500; color: var(--mute); }
.sensor-card .exp { font-size: 11px; color: var(--mute); margin-top: 4px; }
.sensor-card .dev { font-size: 12px; font-weight: 600; margin-top: 6px; }
.sensor-card .dev.up { color: var(--orange); }
.sensor-card .flag {
  font-family: var(--mono); font-size: 9px; letter-spacing: .08em;
  margin-top: 6px; color: var(--mute);
}
.sensor-card .flag.above { color: var(--orange); }

/* Chart + what changed */
.observe-grid {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 16px;
}
@media (max-width: 860px) { .observe-grid { grid-template-columns: 1fr; } }
.chart-box { height: 260px; position: relative; }
.chart-toggles { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.chart-toggles label {
  font-size: 12px; display: flex; align-items: center; gap: 5px; cursor: pointer;
}
.chart-toggles input { accent-color: var(--orange); }

.changed-list { list-style: none; padding: 0; margin: 0; }
.changed-list li {
  display: flex; justify-content: space-between; padding: 10px 0;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.changed-list .up { color: var(--orange); font-weight: 700; }
.changed-list .down { color: var(--teal); font-weight: 700; }
.changed-note { font-size: 13px; color: var(--ink-2); margin-top: 12px; line-height: 1.5; }

.baseline-table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px;
}
.baseline-table th, .baseline-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left;
}
.baseline-table th {
  font-family: var(--mono); font-size: 10px; color: var(--mute); text-transform: uppercase;
}

/* Detect / Act panels */
.detect-card {
  border: 1px solid var(--orange); background: var(--orange-soft);
  border-radius: 14px; padding: 20px; margin-bottom: 16px;
}
.detect-card h2 { color: var(--orange); font-size: 18px; margin-bottom: 8px; }
.evidence-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px;
}
@media (max-width: 520px) { .evidence-grid { grid-template-columns: 1fr; } }
.evidence-item {
  padding: 10px 12px; border-radius: 8px; background: var(--bg-2);
  font-size: 13px; display: flex; justify-content: space-between;
}
.evidence-item .lvl-HIGH { color: #ff4455; font-weight: 700; }
.evidence-item .lvl-MEDIUM { color: var(--orange); font-weight: 700; }
.evidence-item .lvl-LOW { color: var(--mute); }

.health-breakdown {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px;
  margin-top: 12px; font-size: 12px;
}
.health-breakdown div {
  padding: 8px 10px; background: var(--bg-2); border-radius: 8px;
}

.risk-block { margin-top: 16px; }
.risk-pct { font-size: 36px; font-weight: 800; color: var(--orange); }
.risk-explain { font-size: 12px; color: var(--mute); margin-top: 6px; line-height: 1.45; }
.rul-box {
  margin-top: 12px; padding: 12px; border-radius: 10px;
  background: var(--bg-2); font-size: 13px;
}

/* Alert */
.alert-card {
  border: 1px solid var(--orange); border-radius: 14px; padding: 20px;
  background: linear-gradient(135deg, var(--orange-soft), transparent);
  margin-bottom: 16px;
}
.alert-card .sev {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  color: var(--orange); font-weight: 700;
}
.alert-card h2 { font-size: 20px; margin: 8px 0; }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.lc-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 12px 0; }
.lc-step {
  font-family: var(--mono); font-size: 9px; padding: 4px 7px; border-radius: 4px;
  background: var(--bg-2); color: var(--mute); text-transform: uppercase;
}
.lc-step.done { background: var(--teal-soft); color: var(--teal); }
.lc-step.now { background: var(--orange-soft); color: var(--orange); }

/* Timeline */
.tl-list { list-style: none; padding: 0; margin: 0; }
.tl-item {
  display: grid; grid-template-columns: 24px 64px 1fr; gap: 10px;
  padding: 8px 0; font-size: 13px; align-items: start;
}
.tl-item .mark {
  width: 12px; height: 12px; border-radius: 50%; margin-top: 4px;
  border: 2px solid var(--line-2); background: transparent;
}
.tl-item.done .mark { background: var(--teal); border-color: var(--teal); }
.tl-item.current .mark {
  background: var(--orange); border-color: var(--orange);
  box-shadow: 0 0 8px var(--orange);
}
.tl-item.future { opacity: .45; }
.tl-item.future .mark { border-style: dashed; }
.tl-item time { font-family: var(--mono); font-size: 10px; color: var(--mute); }

/* Technical collapsible */
.tech-details { margin-top: 16px; }
.tech-details summary {
  cursor: pointer; font-family: var(--mono); font-size: 11px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--mute);
  padding: 12px 0;
}
.tech-body { padding: 12px 0 4px; }
.telemetry-table {
  width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11px;
}
.telemetry-table th, .telemetry-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left;
}
.telemetry-table th { color: var(--mute); font-size: 9px; text-transform: uppercase; }
.telemetry-wrap { max-height: 200px; overflow: auto; }

/* Recovery + report */
.recovery-path {
  font-family: var(--mono); font-size: 12px; line-height: 2; color: var(--ink-2);
}
.report-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px;
}
.report-grid div {
  padding: 12px; background: var(--bg-2); border-radius: 10px; border: 1px solid var(--line);
}
.report-grid span {
  display: block; font-family: var(--mono); font-size: 9px;
  color: var(--mute); text-transform: uppercase;
}
.report-grid strong { font-size: 16px; margin-top: 4px; display: block; }

.compare-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px;
}
@media (max-width: 600px) { .compare-row { grid-template-columns: 1fr; } }
.compare-box {
  padding: 16px; border-radius: 12px; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; line-height: 2;
}
.compare-box.bad { border-color: rgba(255,68,85,.35); }
.compare-box.good { border-color: rgba(11,184,166,.35); }

.sim-controls {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 20px;
}

.cta-end {
  margin-top: 32px; padding: 28px; border-radius: 16px;
  border: 1px solid var(--line); text-align: center; background: var(--band);
}
.cta-end h2 { margin-bottom: 10px; }
.cta-end p { color: var(--ink-2); max-width: 52ch; margin: 0 auto 18px; }

/* Modals */
.modal {
  display: none; position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.75); align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  max-width: 480px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px;
}
.modal-box.wide { max-width: 860px; }
.modal-box h3 { margin-bottom: 12px; }
.modal-box .field { margin-bottom: 12px; }
.modal-box .field label { display: block; font-size: 11px; color: var(--mute); margin-bottom: 4px; }
.modal-box input, .modal-box select, .modal-box textarea {
  width: 100%; padding: 9px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink);
}
.finding-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.finding-btn {
  padding: 12px; border-radius: 8px; border: 1px solid var(--line-2);
  text-align: left; font-size: 13px;
}
.finding-btn:hover { border-color: var(--orange); background: var(--orange-soft); }

.guided-banner {
  padding: 12px 16px; background: var(--teal-soft); border: 1px solid var(--teal);
  border-radius: 10px; margin-bottom: 16px; font-size: 14px;
}

.dq-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; font-size: 12px;
}
@media (max-width: 600px) { .dq-grid { grid-template-columns: 1fr 1fr; } }
.dq-grid div { padding: 8px; background: var(--bg-2); border-radius: 8px; }

.beginner-hide { display: none !important; }
body.mode-engineer .beginner-hide,
body.mode-architecture .beginner-hide { display: block !important; }
body.mode-architecture .arch-only { display: block !important; }
.arch-only { display: none !important; }

#platformConfig { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }

.boot-overlay {
  position: fixed; inset: 0; z-index: 350;
  background: rgba(0,0,0,.72); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.boot-overlay[hidden] { display: none !important; }
.boot-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 32px; min-width: min(360px, 90vw); text-align: center;
}
.boot-card h3 { margin: 14px 0 18px; font-size: 16px; }
.boot-bar {
  height: 4px; background: var(--bg-3); border-radius: 999px; overflow: hidden;
}
.boot-bar i {
  display: block; height: 100%; width: 0; background: var(--orange);
  transition: width .4s ease;
}

.tl-item { cursor: pointer; }
.tl-item:hover { background: var(--bg-2); border-radius: 8px; }
.tl-detail {
  margin-top: 10px; padding: 12px; border-radius: 10px;
  background: var(--bg-2); font-size: 13px; color: var(--ink-2); display: none;
}
.tl-detail.open { display: block; }

.intro-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.info-btn {
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-2);
  font-size: 10px; font-weight: 700; color: var(--mute); padding: 0; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
}
.info-btn:hover { border-color: var(--orange); color: var(--orange); }
.clock-note { font-size: 11px; color: var(--mute); margin: 0 0 10px; font-family: var(--mono); }
.sensor-card .why { font-size: 11px; color: var(--mute); margin-top: 8px; line-height: 1.4; }
.engineer-only[hidden] { display: none !important; }
body.mode-engineer .engineer-only,
body.mode-architecture .engineer-only { display: flex !important; }

.tour-spotlight {
  position: fixed; z-index: 360; pointer-events: none;
  border: 2px solid var(--orange); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
  transition: all .35s ease;
}
.tour-spotlight[hidden] { display: none !important; }

.fluct-examples {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 14px;
}
@media (max-width: 700px) { .fluct-examples { grid-template-columns: 1fr; } }
.fluct-box {
  padding: 12px; border-radius: 10px; border: 1px solid var(--line); font-family: var(--mono); font-size: 11px; line-height: 1.7;
}
.fluct-box strong { display: block; margin-bottom: 6px; font-family: var(--font); font-size: 13px; }
.fluct-box.ok { border-color: rgba(11,184,166,.4); }
.fluct-box.warn { border-color: rgba(255,106,0,.4); }
.fluct-box.bad { border-color: rgba(255,68,85,.4); }
