/* ==========================================================================
   训练档案 - 火情简报板
   白底 / 细分隔线 / 表格优先，顶部训练简报为视觉主角，深色模式同步
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-hover: #f0f2f5;
  --border: #e5e7eb;
  --border-strong: #d0d7de;
  --text: #1f2328;
  --text-secondary: #57606a;
  --text-faint: #8b949e;

  --accent: #c91d6d;
  --accent-strong: #a81259;
  --accent-soft: #fdf1f7;
  --accent-border: #f0bcd9;
  --ember-1: #ee5f9e;
  --ember-2: #b31255;
  --green: #1a7f37;
  --green-soft: #e6f4ea;
  --danger: #d1242f;
  --danger-soft: #ffeceb;

  --series-blue: #0969da;
  --series-orange: #bc4c00;
  --series-aqua: #1b7c83;

  --radius: 6px;
  --shadow: 0 8px 28px rgba(31, 35, 40, 0.16);
  --font:
    -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
}

[data-theme="dark"] {
  --bg: #16181d;
  --bg-subtle: #1c1f26;
  --bg-hover: #232730;
  --border: #2b3038;
  --border-strong: #3d444d;
  --text: #e6edf3;
  --text-secondary: #9aa4ae;
  --text-faint: #6e7781;

  --accent: #e45a9f;
  --accent-strong: #ef76b1;
  --accent-soft: #2b1a24;
  --accent-border: #5c3350;
  --ember-1: #ee5f9e;
  --ember-2: #c23a78;
  --green: #3fb950;
  --green-soft: #12261a;
  --danger: #f85149;
  --danger-soft: #2d1517;

  --series-blue: #58a6ff;
  --series-orange: #f0883e;
  --series-aqua: #39c5cf;

  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

/* ---------- 基础 ---------- */

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

::selection {
  background: var(--accent-soft);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-faint);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-danger {
  background: var(--bg);
  border-color: #f0b6b2;
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-quiet:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.btn-small {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.link-btn {
  border: 0;
  background: none;
  padding: 2px 4px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.link-btn:hover {
  color: var(--accent);
  text-decoration: underline;
}

.text-button {
  border: 0;
  background: none;
  padding: 6px 2px;
  color: var(--accent);
  font-size: 12.5px;
}

.text-button:hover {
  text-decoration: underline;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
}

.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  flex: 0 0 auto;
}

.brand-mark svg {
  width: 26px;
  height: 26px;
  display: block;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.brand-copy span {
  font-size: 11px;
  color: var(--text-faint);
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text-faint);
}

.search-box:focus-within {
  border-color: var(--accent);
  background: var(--bg);
}

.search-box input {
  width: 200px;
  border: 0;
  background: transparent;
  font-size: 13px;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-faint);
}

#record-sort {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font-size: 13px;
  color: var(--text-secondary);
}

#record-sort:hover {
  background: var(--bg-hover);
}

.session-zone {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 4px;
  border-left: 1px solid var(--border);
}

.session-user {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

/* ---------- 页面与训练简报 ---------- */

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px 96px;
}

.briefing {
  display: grid;
  grid-template-columns: minmax(320px, 5fr) 7fr;
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
  margin-bottom: 16px;
}

.briefing-hero {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 16px 22px;
  border-right: 1px solid var(--border);
}

.briefing-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.briefing-kicker .flame-mark {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: var(--ember-1);
}

.briefing-kicker .flame-mark path:last-child {
  fill: var(--bg);
}

.filter-note {
  margin-left: auto;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--accent-strong);
}

.briefing-value {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.briefing-value strong {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.briefing-value span {
  font-size: 12px;
  color: var(--text-faint);
}

.hero-rule {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ember-1), var(--ember-2) 42%, transparent 96%);
  margin-top: 3px;
}

.briefing-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.briefing-sub b {
  color: var(--text);
  font-weight: 600;
}

.briefing-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.briefing-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 14px 18px;
  border-left: 1px solid var(--border);
}

.briefing-stat:first-child {
  border-left: 0;
}

.briefing-stat span {
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.briefing-stat strong {
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.briefing-empty {
  padding: 14px 22px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- 主表格 ---------- */

.table-frame {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: auto;
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.runs-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.runs-table th.num,
.runs-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.runs-table th.sortable {
  cursor: pointer;
}

.runs-table th.sortable:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.runs-table th[aria-sort="ascending"],
.runs-table th[aria-sort="descending"] {
  color: var(--text);
}

.runs-table th[aria-sort] .sort-arrow {
  color: var(--accent);
}

.sort-arrow {
  margin-left: 3px;
  font-size: 10px;
  color: var(--text-faint);
}

.runs-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.runs-table tbody tr {
  cursor: pointer;
  transition: background 0.08s ease;
}

.runs-table tbody tr:hover {
  background: var(--bg-subtle);
}

.runs-table tbody tr:last-child td {
  border-bottom: 0;
}

.runs-table tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.col-check {
  width: 34px;
  padding-right: 4px !important;
  text-align: center;
}

.compare-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.compare-check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.model-cell {
  display: flex;
  flex-direction: column;
  max-width: 260px;
  min-width: 120px;
}

.model-cell strong {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-cell span {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.metric-primary {
  font-weight: 650;
  color: var(--accent-strong);
}

.best-mark {
  color: var(--green);
  font-size: 9px;
  margin-right: 2px;
  vertical-align: 1px;
}

.metric-cell {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
}

.metric-bar {
  display: block;
  height: 3px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--bg-hover);
  overflow: hidden;
}

.metric-bar i {
  display: block;
  height: 100%;
  width: var(--bar-width);
  border-radius: 999px;
  background: var(--bar-color, var(--border-strong));
  transition: width 0.3s ease;
}

td.metric-primary .metric-bar i {
  background: var(--accent);
}

.metric-cell .best-mark {
  margin-right: 0;
}

.empty-state {
  padding: 56px 16px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-flame {
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
}

.empty-flame path:first-child {
  fill: var(--accent-soft);
  stroke: var(--accent-border);
  stroke-width: 22;
}

.empty-flame path:last-child {
  fill: var(--accent-border);
}

.empty-state strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state p {
  margin: 0 0 14px;
  font-size: 13px;
}

.page-footer {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-faint);
}

.page-footer .link-btn {
  font-size: 12.5px;
}

/* ---------- 底部对比条 ---------- */

.compare-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.compare-bar-text {
  color: var(--text-secondary);
  padding-right: 4px;
}

.compare-bar-text strong {
  color: var(--accent);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.compare-bar-names {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-faint);
}

.compare-bar-names:empty {
  display: none;
}

/* ---------- 抽屉 ---------- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 21, 26, 0.38);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(580px, 94vw);
  height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: drawer-in 0.16s ease;
}

.drawer-wide {
  width: min(800px, 96vw);
}

@keyframes drawer-in {
  from {
    transform: translateX(24px);
    opacity: 0.6;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-kicker {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
}

/* ---------- 详情抽屉 ---------- */

.run-detail {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.detail-meta {
  font-size: 12px;
  color: var(--text-faint);
}

.detail-title {
  margin: 4px 0;
  font-size: 20px;
  font-weight: 650;
  word-break: break-all;
}

.detail-description {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 0 0 auto;
}

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 6px 22px;
  padding: 2px 2px 0;
  border-top: 1px solid var(--border);
}

.detail-kpi {
  display: flex;
  flex-direction: column;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.detail-kpi.is-key span {
  color: var(--accent);
}

.detail-kpi.is-key strong {
  color: var(--accent-strong);
}

.detail-kpi span {
  font-size: 11px;
  color: var(--text-secondary);
}

.detail-kpi strong {
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.detail-kpi small {
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 14px 8px;
}

.inspector-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.inspector-facts > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.inspector-facts dt {
  color: var(--text-secondary);
  font-size: 12.5px;
  white-space: nowrap;
}

.inspector-facts dd {
  margin: 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 图表 ---------- */

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

.chart-panel,
.data-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-header h3,
.data-panel h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel-header p,
.data-panel p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-line {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--legend-color);
  flex: 0 0 auto;
}

.chart-wrap {
  position: relative;
}

.line-chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-gridline {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis-line {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--text-faint);
  font-size: 10px;
  font-family: var(--font);
}

.chart-line {
  fill: none;
  stroke: var(--line-color);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  stroke: none;
}

.chart-end-dot {
  fill: var(--line-color);
}

.chart-crosshair {
  stroke: var(--text-faint);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0;
  pointer-events: none;
}

.chart-hover-layer {
  fill: transparent;
  cursor: crosshair;
  outline: none;
}

.chart-hover-layer:focus-visible {
  stroke: var(--accent);
  stroke-width: 1.5;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
}

.tooltip-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}

.tooltip-row strong {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.chart-data-table {
  margin-top: 8px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chart-data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.chart-data-table th,
.chart-data-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart-data-table th:first-child,
.chart-data-table td:first-child {
  text-align: left;
}

.chart-data-table th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 600;
}

.chart-data-table tr:last-child td {
  border-bottom: 0;
}

.no-chart-data {
  margin-top: 10px;
  padding: 26px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

/* ---------- 详情下方：类别与配置 ---------- */

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

.class-table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 12.5px;
}

.class-table th {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.class-table th:first-child {
  text-align: left;
}

.class-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.class-table td:first-child {
  text-align: left;
}

.class-table tr:last-child td {
  border-bottom: 0;
}

.class-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.class-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--class-color);
  flex: 0 0 auto;
}

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

.config-group h4 {
  margin: 0 0 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.config-list {
  margin: 0;
}

.config-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 12.5px;
}

.config-list dt {
  color: var(--text-secondary);
  white-space: nowrap;
}

.config-list dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 对比抽屉 ---------- */

.compare-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.compare-models {
  display: grid;
  grid-template-columns: 150px repeat(var(--compare-count), minmax(120px, 1fr));
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12.5px;
}

.compare-label-cell,
.compare-value-cell,
.compare-model-cell {
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  min-width: 0;
}

.compare-label-cell:nth-child(-n + 1),
.compare-model-cell {
  border-top: 0;
}

.compare-label-cell {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
}

.compare-value-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.compare-value-cell.is-best {
  color: var(--green);
  font-weight: 650;
}

.compare-value-cell.is-best::before {
  content: "▲ ";
  font-size: 9px;
  vertical-align: 1px;
}

.compare-model-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-subtle);
  border-left-color: var(--border);
}

.compare-model-cell strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-model-cell span {
  font-size: 11.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-bars {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.metric-bars h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.metric-bar-group {
  margin-top: 14px;
}

.metric-bar-title {
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.metric-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 7px 0;
}

.metric-bar-name {
  width: 220px;
  flex: 0 0 auto;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-bar-track {
  flex: 1 1 auto;
  height: 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: var(--bar-width);
  background: var(--bar-color);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.metric-bar-value {
  width: 64px;
  flex: 0 0 auto;
  text-align: right;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.compare-empty {
  padding: 56px 16px;
  text-align: center;
  color: var(--text-secondary);
}

.compare-empty strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
}

.compare-empty p {
  margin: 0;
  font-size: 13px;
}

/* ---------- 骨架屏 ---------- */

.loading-frame {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px;
}

.skeleton {
  height: 16px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

.skeleton-hero {
  height: 220px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- 弹窗 ---------- */

dialog.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  overflow: visible;
}

dialog.modal::backdrop {
  background: rgba(17, 21, 26, 0.42);
}

.modal-card {
  display: block;
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
  animation: modal-in 0.14s ease;
}

.modal-small .modal-card {
  width: min(430px, 92vw);
}

@keyframes modal-in {
  from {
    transform: translateY(10px);
    opacity: 0.7;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 0;
}

.modal-kicker {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.modal-header h2 {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 650;
}

.modal-copy {
  margin: 0;
  padding: 8px 20px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px 20px;
}

/* ---------- 登录弹窗 ---------- */

.login-row {
  display: flex;
  gap: 8px;
  padding: 16px 20px 20px;
}

.login-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  outline: none;
}

.login-error {
  margin: 0;
  padding: 0 20px 16px;
  color: var(--danger);
  font-size: 12.5px;
}

/* ---------- 上传弹窗 ---------- */

.upload-state {
  padding: 16px 20px 20px;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 30px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone-symbol {
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-secondary);
}

.drop-zone strong {
  font-size: 13.5px;
  font-weight: 600;
}

.drop-zone > span:last-child {
  font-size: 12px;
  color: var(--text-faint);
}

.form-help {
  margin: 12px 2px 0;
  font-size: 12px;
  color: var(--text-faint);
}

.file-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.file-summary span {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

.file-summary strong {
  font-size: 13.5px;
  font-weight: 600;
  word-break: break-all;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 4px;
}

.preview-item {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.preview-item span {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

.preview-item strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-message {
  padding: 36px 24px;
  text-align: center;
}

.state-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 700;
}

.success-mark {
  background: var(--green-soft);
  color: var(--green);
}

.error-mark {
  background: var(--danger-soft);
  color: var(--danger);
}

.loading-mark {
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.state-message strong {
  display: block;
  font-size: 15px;
}

.state-message p {
  margin: 6px 0 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.state-message .btn {
  margin-top: 4px;
}

/* ---------- 提示消息 ---------- */

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  width: min(320px, 84vw);
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.16s ease;
}

.toast strong {
  display: block;
  font-weight: 600;
}

.toast span {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---------- 响应式 ---------- */

@media (max-width: 960px) {
  .chart-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .brand-copy span {
    display: none;
  }

  .search-box input {
    width: 140px;
  }

  .briefing {
    grid-template-columns: minmax(280px, 2fr) 3fr;
  }

  .briefing-value strong {
    font-size: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 0 14px;
    gap: 10px;
  }

  .page {
    padding: 12px 14px 110px;
  }

  .search-box input {
    width: 110px;
  }

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

  .config-groups,
  .inspector-facts {
    grid-template-columns: 1fr;
  }

  .compare-models {
    grid-template-columns: 110px repeat(var(--compare-count), minmax(96px, 1fr));
  }

  .metric-bar-name {
    width: 120px;
  }

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

  .briefing-hero {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

  .briefing-stat:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .briefing-stat:nth-child(4) {
    border-top: 1px solid var(--border);
  }

  .compare-bar-names {
    display: none;
  }
}
