:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: rgba(16, 28, 47, 0.88);
  --line: rgba(134, 185, 255, 0.24);
  --text: #eef6ff;
  --muted: #9fb5cf;
  --accent: #68e1fd;
  --accent-strong: #8cffbc;
  --danger: #ff8d8d;
  --shell-max-width: 1680px;
  --status-column-width: clamp(170px, 13vw, 220px);
  --control-column-width: clamp(250px, 20vw, 320px);
  --viewer-aspect-ratio: 4 / 3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #16385f 0, transparent 36rem), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(var(--shell-max-width), calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 18px;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.masthead-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.masthead .hint {
  max-width: 760px;
  margin: 0;
  text-align: right;
}

/* 部署版本信息：显示部署时 git commit（8 位 hash），dirty 时后缀 *；用于与开发机提交快速对比 */
.version-line {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
  text-align: right;
}

.version-line code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent);
  background: rgba(104, 225, 253, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
}

.workspace {
  display: grid;
  grid-template-columns: var(--status-column-width) minmax(0, 1fr) var(--control-column-width);
  align-items: start;
  gap: 12px;
}

.status-column,
.viewer-column,
.controls-column {
  display: grid;
  align-content: start;
  gap: 12px;
}

.viewer-column {
  /* 覆盖 Grid 子项默认最小内容宽度，确保中间列不会挤入右侧控制栏。 */
  min-width: 0;
}

.viewer {
  /* 视频源切换为 4:3 等比例后仍必须受中间列宽度约束。 */
  width: 100%;
  max-width: 100%;
}

/* 命令返回的 JSON 可能很长；必须在中间列内换行，不能把 Grid 列撑入右侧控制栏。 */
.viewer-column,
.log-panel,
.command-log,
.log-entry {
  min-width: 0;
}

.log-entry {
  overflow-wrap: anywhere;
}

.status-column,
.controls-column {
  position: sticky;
  top: 10px;
}

.status,
.controls,
.log-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
  padding: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 3vw, 2.7rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 10px;
  font-size: 0.96rem;
}

.hint,
.video-message,
.roi-details,
.command-summary,
dd {
  color: var(--muted);
}

.hint {
  /* 显式声明字号，避免回退到浏览器默认 16px 而明显大于其余界面文字。 */
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.status-grid {
  display: grid;
  gap: 10px;
}

.status dl {
  margin: 0;
}

.status dt {
  margin-top: 7px;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
}

.status dd {
  min-width: 0;
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.74rem;
  line-height: 1.35;
}

.status-sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.status-sub-header h3 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.84rem;
}

.status-sub-header button {
  width: auto;
  min-width: 44px;
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 8px;
}

.status h3 {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.84rem;
}

.viewer {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  aspect-ratio: var(--viewer-aspect-ratio, 4 / 3);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #000;
}

canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

#overlay {
  cursor: crosshair;
}

.viewer.is-rotated,
.viewer.is-tall {
  /* 竖屏源不能按中间列全宽撑高，否则会被两侧 sticky 栏遮挡。 */
  height: min(calc(90vh - 24px), 1040px);
  max-height: none;
  justify-self: center;
  width: min(100%, 720px);
  max-width: min(100%, 720px);
}

.viewer:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  aspect-ratio: auto;
  background: #000;
}

.viewer-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid rgba(134, 185, 255, 0.22);
  border-radius: 999px;
  background: rgba(6, 14, 26, 0.72);
  backdrop-filter: blur(10px);
}

.viewer-tool-button {
  width: auto;
  min-width: 76px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.viewer-tool-button.is-recording {
  border-color: rgba(255, 141, 141, 0.72);
  background: rgba(127, 24, 32, 0.92);
  color: #ffe8e8;
}

.recording-status {
  align-self: center;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.recording-status.is-error {
  color: var(--danger);
}

.controls {
  display: grid;
  align-content: start;
  gap: 10px;
}

.control-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(134, 185, 255, 0.14);
  border-radius: 14px;
  background: rgba(6, 14, 26, 0.34);
}

.control-group h2 {
  margin: 0;
  color: var(--accent-strong);
}

.video-overlay-message {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  max-width: min(520px, calc(100% - 32px));
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(104, 225, 253, 0.22);
  border-radius: 14px;
  background: rgba(6, 14, 26, 0.72);
  color: var(--muted);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.video-overlay-message:empty {
  display: none;
}

.command-summary,
.roi-details {
  margin: 0;
  padding: 8px 9px;
  border: 1px solid rgba(134, 185, 255, 0.14);
  border-radius: 11px;
  background: rgba(6, 14, 26, 0.34);
  font-size: 0.84rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

/* 复选行水平对齐：复选框与文字同行居中，且复选框不被整宽拉伸。 */
.control-group label.pd-probe-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.control-group label.pd-probe-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}

/* 第三帧稳定性检测结果：居中卡片，仅点 × 关闭（不自动消失）。 */
.pd-probe-toast-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 6, 14, 0.55);
}

.pd-probe-toast {
  width: min(460px, 100%);
  padding: 18px 22px 20px;
  border: 1px solid rgba(134, 185, 255, 0.35);
  border-radius: 16px;
  background: rgba(9, 18, 32, 0.98);
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  font-size: 0.9rem;
}

.pd-probe-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.pd-probe-toast-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent-strong);
}

.pd-probe-toast-close {
  width: auto;
  padding: 2px 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease;
}

.pd-probe-toast-close:hover {
  color: var(--text);
}

.pd-probe-toast-subtitle {
  margin-bottom: 10px;
  color: var(--muted);
}

.pd-probe-toast table {
  width: 100%;
  border-collapse: collapse;
}

.pd-probe-toast thead th {
  padding: 6px 8px;
  color: var(--muted);
  font-weight: 500;
}

.pd-probe-toast th,
.pd-probe-toast td {
  padding: 8px;
  border-bottom: 1px solid rgba(134, 185, 255, 0.14);
  text-align: right;
}

.pd-probe-toast th:first-child,
.pd-probe-toast td:first-child {
  text-align: left;
}

.pd-probe-toast tbody tr:last-child td {
  border-bottom: none;
}

select,
input:not([type="range"]),
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: rgba(6, 14, 26, 0.92);
  color: var(--text);
  font: inherit;
}

input.roi-details {
  width: 100%;
  color: var(--muted);
  outline: none;
  cursor: text;
  font-size: 0.8rem;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  margin: 8px 0;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 3px;
  background: var(--line);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(6, 14, 26, 0.92);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(6, 14, 26, 0.92);
  cursor: pointer;
}

button {
  border-color: rgba(104, 225, 253, 0.42);
  background: linear-gradient(135deg, rgba(104, 225, 253, 0.22), rgba(140, 255, 188, 0.1));
  font-weight: 700;
  cursor: pointer;
}

.button-danger {
  border-color: rgba(255, 141, 141, 0.52);
  background: linear-gradient(135deg, rgba(255, 141, 141, 0.22), rgba(104, 225, 253, 0.08));
}

.button-info {
  border-color: rgba(104, 225, 253, 0.52);
  background: linear-gradient(135deg, rgba(104, 225, 253, 0.22), rgba(140, 255, 188, 0.1));
}

.simulation-dataset-input {
  /* 文件选择器由“打开扫峰仿真”触发，避免原生输入框长期占用控制栏。 */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 14, 26, 0.82);
}

.modal-content {
  position: relative;
  max-width: min(90vw, 1200px);
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.46);
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  margin-left: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(6, 14, 26, 0.72);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.ppraw-modal-status {
  color: var(--muted);
  font-size: 0.84rem;
}

.ppraw-download {
  width: auto;
  margin-left: auto;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.ppraw-viewer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ppraw-panel {
  display: grid;
  gap: 8px;
}

.ppraw-panel h3 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.ppraw-panel canvas {
  position: static;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #0b1727, #152944);
}

.ppraw-info {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.fv-modal-content {
  width: min(90vw, 900px);
}

.roi-sweep-status,
.roi-sweep-info {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.roi-sweep-step-label {
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.roi-sweep-step {
  width: 76px;
  margin-right: 8px;
  padding: 7px 8px;
  font-size: 0.8rem;
}

.roi-sweep-modal-content {
  width: min(96vw, 1440px);
  max-width: 1440px;
  padding: 18px;
}

.roi-sweep-modal-header {
  align-items: flex-start;
  justify-content: space-between;
}

.roi-sweep-title-group {
  min-width: 0;
}

.roi-sweep-title-group h2 {
  margin-bottom: 5px;
}

.roi-sweep-actions,
.roi-sweep-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.roi-sweep-actions {
  justify-content: flex-end;
}

.roi-sweep-actions button,
.roi-sweep-controls button {
  width: auto;
  min-width: 72px;
  padding: 7px 12px;
  font-size: 0.8rem;
}

.roi-sweep-actions .modal-close {
  min-width: 36px;
  padding: 0;
}

.roi-sweep-controls {
  justify-content: space-between;
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid rgba(134, 185, 255, 0.16);
  border-radius: 12px;
  background: rgba(6, 14, 26, 0.38);
}

.roi-sweep-controls .roi-sweep-control-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.roi-sweep-controls .is-selected {
  border-color: var(--accent-strong);
  background: rgba(30, 132, 90, 0.38);
  color: #effff5;
}

.roi-sweep-curve-controls {
  justify-content: flex-start;
  margin: 12px 0 0;
}

.roi-sweep-chart-scroll {
  max-height: min(68vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.roi-sweep-chart {
  position: static;
  display: block;
  max-width: none;
  border: 0;
  border-radius: 0;
  background: #fff;
}

.trend-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.trend-status {
  color: var(--muted);
  font-size: 0.78rem;
}

.trend-status.is-recording {
  color: #fb7185;
  font-weight: 700;
}

.roi-sweep-diagnostics {
  max-height: 96px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 14, 26, 0.58);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .roi-sweep-modal-content {
    width: 98vw;
    padding: 14px;
  }

  .roi-sweep-modal-header {
    display: grid;
    gap: 10px;
  }

  .roi-sweep-actions {
    justify-content: flex-start;
  }
}

.fv-info {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.fv-grid {
  position: static;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #0b1727, #152944);
}

.depth-modal-content {
  width: min(90vw, 900px);
}

.depth-info {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.depth-legend {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
}

.depth-legend-title {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}

.depth-legend-bar {
  height: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(90deg, #2661a0, #34a869, #ffbf30);
}

.depth-legend-labels {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.depth-legend-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.depth-legend-invalid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.depth-legend-invalid-swatch {
  width: 14px;
  height: 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #424c58;
}

.depth-view-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
}

.depth-tab {
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
}

.depth-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1727;
  font-weight: 600;
}

.depth-snapshot {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #0b1727, #152944);
}

.depth-grid {
  position: static;
  width: auto;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #0b1727, #152944);
  overflow: hidden;
}

.depth-grid table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.depth-grid td {
  padding: 0;
  text-align: center;
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.depth-grid td span {
  display: inline-block;
  line-height: 1.3;
  white-space: nowrap;
  color: rgba(148, 158, 168, 0.9);
}

.depth-grid td span.depth-cell-valid {
  color: #ffffff;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.7);
}

button:active {
  transform: translateY(1px);
}

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  margin: 0;
}

dt {
  color: var(--accent-strong);
}

dd {
  margin: 0;
}

.log-panel {
  margin-top: 0;
}

.command-log {
  display: grid;
  gap: 6px;
  overflow: auto;
  min-height: 78px;
  max-height: 150px;
}

.log-entry {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(6, 14, 26, 0.72);
  color: #cfe3ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.log-entry.is-ok {
  border-color: rgba(140, 255, 188, 0.32);
}

.log-entry.is-error {
  border-color: rgba(255, 141, 141, 0.48);
  color: var(--danger);
}

.is-error {
  color: var(--danger);
}

.log-bar {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
  padding: 14px;
}

.log-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.log-bar-header h2 {
  margin: 0;
  font-size: 0.96rem;
}

.log-bar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-bar-controls select {
  width: auto;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.log-bar-controls button {
  width: auto;
  padding: 4px 12px;
  font-size: 0.8rem;
}

.log-status {
  font-size: 0.8rem;
  color: var(--danger);
}

.log-status.is-connected {
  color: #4caf50;
}

.log-entries {
  overflow-y: auto;
  max-height: 240px;
  min-height: 60px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
}

.log-line {
  padding: 2px 6px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-level-0 {
  color: #ff8d8d;
  background: rgba(255, 141, 141, 0.08);
}

.log-level-1 {
  color: #ffd54f;
  background: rgba(255, 213, 79, 0.08);
}

.log-level-2 {
  color: #cfe3ff;
}

.log-level-3 {
  color: #9fb5cf;
}

.log-level-4 {
  color: #5a6f8a;
}

/* 1920px 屏幕在 150% 显示缩放时约为 1280 CSS px；1100px 时中间视频仍约 633px，故此处保留两侧栏。 */
@media (max-width: 1100px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding-top: 10px;
  }

  .masthead {
    display: grid;
    gap: 8px;
  }

  .masthead .hint {
    max-width: none;
    text-align: left;
  }

  .masthead-meta {
    align-items: flex-start;
  }

  .version-line {
    text-align: left;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .status-column,
  .viewer-column,
  .controls-column {
    display: contents;
  }

  .status-column,
  .controls-column {
    position: static;
  }

  .viewer {
    min-height: 240px;
    order: 1;
  }

  .viewer.is-rotated,
  .viewer.is-tall {
    width: min(100%, 620px);
    height: auto;
    max-height: none;
  }

  .status {
    order: 2;
  }

  .controls {
    order: 3;
  }

  .log-panel {
    order: 4;
  }
}

/* ----- 全程扫峰进度卡片 ----- */
.sweep-progress {
  position: fixed;
  z-index: 200;
  top: 16px;
  right: 16px;
  width: 360px;
  max-width: calc(100vw - 32px);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: none;
  gap: 10px;
}

.sweep-progress.is-waiting  { border-color: rgba(104,225,253,0.5); }
.sweep-progress.is-streaming { border-color: var(--accent); }
.sweep-progress.is-done     { border-color: var(--accent-strong); }
.sweep-progress.is-error    { border-color: var(--danger); }

.sweep-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sweep-progress-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.sweep-progress-phase {
  font-size: 0.8rem;
  color: var(--muted);
}

.sweep-progress-bar {
  width: 100%;
  height: 6px;
  border: none;
  border-radius: 3px;
  background: rgba(134,185,255,0.15);
  color: var(--accent);
}
.sweep-progress-bar::-webkit-progress-bar {
  background: rgba(134,185,255,0.15);
  border-radius: 3px;
}
.sweep-progress-bar::-webkit-progress-value {
  background: var(--accent);
  border-radius: 3px;
}
.sweep-progress-bar::-moz-progress-bar {
  background: var(--accent);
  border-radius: 3px;
}

.sweep-progress-detail {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.sweep-download-ready {
  justify-self: start;
  padding: 6px 16px;
  border: 1px solid var(--accent-strong);
  border-radius: 8px;
  background: rgba(140,255,188,0.12);
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
}
.sweep-download-ready:hover {
  background: rgba(140,255,188,0.25);
}

.sweep-progress.is-error .sweep-progress-detail {
  color: var(--danger);
}

@media (max-width: 600px) {
  .sweep-progress {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 14px 14px 0 0;
  }
}

/* SPC 标定结果弹窗：紧凑 17×13 表格 + 数值摘要 */
.calib-spc-modal-content {
  max-width: min(92vw, 1100px);
  padding: 22px 26px;
}

.calib-dcc-pd-modal-content {
  width: min(96vw, 1500px);
  max-width: min(96vw, 1500px);
  max-height: 94vh;
  padding: 24px 28px;
}

.dcc-pd-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px 0;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel, #1a2332);
  z-index: 2;
  padding-bottom: 4px;
}

.dcc-pd-tab {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  cursor: pointer;
}

.dcc-pd-tab.is-active {
  background: rgba(104,225,253,0.12);
  color: var(--text);
  border-color: var(--accent);
}

.dcc-pd-tab-panel {
  display: none;
}

.dcc-pd-tab-panel.is-active {
  display: block;
}

#calib-dcc-pd-panel-plots.is-active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#calib-dcc-pd-panel-tables.is-active {
  display: block;
}

.dcc-pd-table-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(420px, 1fr));
  gap: 18px;
  align-items: start;
}

.dcc-pd-table-card {
  min-width: 0;
  padding: 14px 16px 16px;
  border: 1px solid rgba(134, 185, 255, 0.18);
  border-radius: 14px;
  background: rgba(6, 14, 26, 0.28);
}

.dcc-pd-table-card h4 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
}

.calib-spc-summary {
  font-size: 13px;
  margin: 0 0 14px 0;
  color: var(--muted);
}

.grid-table {
  border-collapse: collapse;
  margin: 6px 0 16px 0;
  font-size: 11px;
  font-family: var(--mono, ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace);
}

.grid-table td {
  width: 28px;
  height: 22px;
  padding: 0;
  text-align: center;
  vertical-align: middle;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.15));
  color: #f8fafc;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.grid-table td.is-light-cell {
  color: #07111f;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.55);
}

.grid-table td.is-empty-cell {
  color: #243244;
  text-shadow: none;
}

.dcc-pd-grid-table {
  width: 100%;
  margin: 0;
  table-layout: fixed;
  font-size: 14px;
}

.dcc-pd-grid-table td {
  width: auto;
  height: 38px;
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
  border-color: rgba(255, 255, 255, 0.24);
}

.dcc-pd-roi-buttons {
  order: 1;
  display: grid;
  grid-template-columns: repeat(8, minmax(64px, 1fr));
  gap: 6px;
  margin: 8px 0 4px 0;
  width: 100%;
  box-sizing: border-box;
}

.dcc-pd-roi-button {
  font-family: var(--mono, ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.15));
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  min-width: 0;
  width: 100%;
  letter-spacing: 0.02em;
}

.dcc-pd-roi-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.dcc-pd-roi-button.is-active {
  background: rgba(104, 225, 253, 0.18);
  border-color: rgba(104, 225, 253, 0.55);
  color: #fff;
}

.dcc-pd-roi-button.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.dcc-pd-roi-stage {
  order: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  min-width: 0;        /* 防止 flex 子项被 canvas 撑爆 modal 宽度 */
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .dcc-pd-table-grid {
    grid-template-columns: 1fr;
  }

  .dcc-pd-roi-buttons {
    grid-template-columns: repeat(4, minmax(64px, 1fr));
  }
}

.dcc-pd-roi-stage-title {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono, ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace);
  padding: 4px 2px;
  letter-spacing: 0.04em;
}

.dcc-pd-roi-stage canvas {
  position: static;
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;     /* 避免在窄屏上把 modal-content 撑到需要滚很长 */
  aspect-ratio: 3 / 2;  /* 模仿 matplotlib fit_samples.png 的 3:2 比例 */
  background: #ffffff;  /* 白底，matplotlib 风格 */
  border-radius: 6px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.15));
}

.dcc-pd-roi-stage-note {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono, ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace);
  margin: 6px 2px 0;
  min-height: 1.2em;
}

.dcc-pd-roi-plots {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 12px;
  margin: 8px 0 18px 0;
  /* 强制填满 grid 父容器宽度：modal content padding 由 .calib-dcc-pd-modal-content 给定。 */
  width: 100%;
  box-sizing: border-box;
}

.dcc-pd-roi-plot {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 6px 8px 6px;
  background: rgba(255,255,255,0.03);
  min-width: 0;            /* grid 子项允许收缩到 minmax 下限 */
}

.dcc-pd-roi-plot-title {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono, ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace);
  text-align: center;
  padding: 2px 0 4px 0;
  letter-spacing: 0.04em;
}

.dcc-pd-roi-plot canvas {
  display: block;
  width: 100%;
  height: auto;            /* 由 JS 按 wrap.clientWidth × dpr 设置 intrinsic；CSS 只显示尺寸 */
  aspect-ratio: 16 / 9;    /* 显示纵横比，canvas 内绘制按相同纵横比布局 */
  background: #101820;
  border-radius: 4px;
}

@media (max-width: 900px) {
  .dcc-pd-roi-plots {
    grid-template-columns: 1fr;
  }
}

.grid-table tr:first-child td {
  border-top: 2px solid var(--line, rgba(255, 255, 255, 0.15));
}

#calib-spc-dump {
  display: inline-block;
  margin: 0 0 14px 0;
  text-decoration: none;
}
