:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #182026;
  --text-primary: #182026;
  --text-muted: #5c6b78;
  --muted: var(--text-muted);
  --accent: #0b6cff;
  --accent-soft: #e8f1ff;
  --accent-border: #b8d4ff;
  --border: #d4dde6;
  --border-subtle: #e4eaef;
  --thead-bg: #f0f4f8;
  --surface-elevated: #ffffff;
  --surface-muted: #f6f8fa;
  --success-soft: #ecfdf3;
  --success-border: #86efac;
  --success-ink: #166534;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 30, 50, 0.04);
  --shadow-md: 0 4px 14px rgba(15, 30, 50, 0.07);
  --shadow-primary: 0 6px 22px rgba(15, 30, 50, 0.08);
  --pad-card-primary: 10px 12px;
  --pad-card-secondary: 8px 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text-primary);
  background: radial-gradient(circle at 12% 16%, #ffffff 0%, var(--bg) 52%);
  font-size: 0.875rem;
  line-height: 1.45;
  font-weight: 400;
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(216px, 264px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 100vh;
  padding: 10px;
  max-width: 100%;
}

.panel {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.card.card--primary {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-primary);
  border-color: var(--border);
}

.card.card--secondary {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--surface-muted);
  border-color: var(--border-subtle);
}

.sidebar.controls.card.card--secondary {
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.sidebar.controls {
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: start;
  position: sticky;
  top: 10px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
}

.app-header h1 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.2;
}

.app-header .subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.3;
}

/* Sidebar segmented mode control */
.segmented-control.sidebar-segmented.sidebar-mode-switch {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  background: #e8ecf1;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.sidebar-mode-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 2.75em;
  padding: 5px 3px;
  font-size: 0.63rem;
  font-weight: 500;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: manual;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: none;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.sidebar-mode-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.55);
}

.sidebar-mode-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  z-index: 1;
}

.sidebar-mode-btn.is-active {
  background: var(--panel);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(11, 108, 255, 0.12), inset 0 0 0 1px rgba(11, 108, 255, 0.08);
}

.segmented-control.sidebar-segmented .sidebar-mode-btn {
  width: auto;
  min-width: 0;
  background-image: none;
  border-color: transparent;
}

.sidebar-mode-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.sidebar-mode-panel.is-active {
  display: flex;
}

.sidebar-advanced .control-details-summary {
  padding: 6px 8px;
  font-size: 0.78rem;
}

.sidebar-advanced .control-details-body {
  padding: 0 8px 8px;
}

.batch-mode-hint {
  margin: 0;
  font-size: 0.72rem;
}

.control-details {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  padding: 0;
}

.control-details-summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 8px;
  list-style: none;
  color: #1a2b3c;
}

.control-details-summary::-webkit-details-marker {
  display: none;
}

.control-details-summary::before {
  content: "";
  display: inline-block;
  width: 0.35em;
  height: 0.35em;
  margin-right: 0.45em;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  vertical-align: 0.12em;
  transition: transform 0.15s ease;
}

.control-details[open] .control-details-summary::before {
  transform: rotate(45deg);
  vertical-align: 0.08em;
}

.control-details-body {
  padding: 0 8px 8px;
  border-top: 1px solid #e8eef3;
}

.group-panel {
  border: none;
  border-radius: 0;
  padding: 0;
}

.group-panel h2 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.group-note {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 400;
  line-height: 1.38;
}

.optimized-honesty-note {
  margin-top: 0;
  font-size: 0.65rem;
  color: #6d7d8b;
  line-height: 1.42;
}

label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #2a3540;
}

.controls-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.algorithm-groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.algorithm-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--panel);
  box-shadow: none;
}

.algorithm-card:first-of-type {
  border-left: 3px solid #cfd6dd;
  background: linear-gradient(90deg, #fafbfc 0%, var(--panel) 40%);
}

.algorithm-card:last-of-type {
  border-left: 3px solid #b8d4ff;
  background: linear-gradient(90deg, #f7faff 0%, var(--panel) 45%);
}

.algorithm-card h3 {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #2c3d4d;
  letter-spacing: 0.01em;
}

.algorithm-list-grid,
.algorithm-checkbox-grid {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}

button.algorithm-pill {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 6px;
  width: 100%;
  margin: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--panel);
  padding: 4px 9px;
  font-size: 0.7rem;
  font-weight: 500;
  color: #33424e;
  line-height: 1.25;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.algorithm-pill-label {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

button.algorithm-pill:hover {
  border-color: var(--accent-border);
  background: #fafcff;
}

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

button.algorithm-pill.optimized {
  border-color: #cfe0ff;
  background: #f5f9ff;
}

button.algorithm-pill.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #063a9e;
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(11, 108, 255, 0.15);
}

button.algorithm-pill.is-selected.optimized {
  background: #e4efff;
  color: #052e7a;
}

.algorithm-checkbox {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin: 0;
  padding: 5px 7px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 28px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--panel);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.algorithm-checkbox:hover {
  background: #f8fafc;
  border-color: var(--border);
}

.algorithm-checkbox:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.algorithm-checkbox-label {
  flex: 1 1 auto;
  min-width: 0;
}

.algorithm-checkbox input[type="checkbox"] {
  margin: 0;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

.algorithm-checkbox .algo-type-badge {
  margin-left: auto;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #4a5a68;
  background: #eef1f4;
  border: 1px solid #e0e5ea;
}

.algorithm-checkbox .algo-type-badge.optimized {
  color: #0f4a9e;
  background: #e4efff;
  border-color: #c5daf8;
}

.algorithm-checkbox .algo-order-tag {
  flex-shrink: 0;
}

.algorithm-order-legend {
  margin: 0 0 4px;
  font-size: 0.62rem;
  color: var(--text-muted);
  line-height: 1.45;
  font-weight: 400;
}

.algorithm-order-legend strong {
  color: #3a4754;
  font-weight: 600;
}

.algorithm-order-legend code {
  font-size: 0.95em;
  padding: 0 2px;
  background: rgba(15, 30, 50, 0.06);
  border-radius: 3px;
}

.algo-order-tag {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin: 0 1px;
  vertical-align: middle;
  line-height: 1.2;
  white-space: nowrap;
  cursor: help;
}

.algo-order-tag--randomize {
  color: #4a5560;
  background: #eef1f4;
  border: 1px solid #e0e5ea;
}

.algo-order-tag--tiebreak {
  color: #7a5510;
  background: #fff7e8;
  border: 1px solid #edd9b8;
}

.algo-order-tag--optimize {
  color: #0a3d8a;
  background: #e8f1ff;
  border: 1px solid #c5daf8;
}

button.algorithm-pill .algo-order-tag {
  cursor: help;
}

.algorithm-empty {
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 2px 0;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-field-checkbox {
  justify-content: flex-start;
  min-height: auto;
}

.control-field-seed-actions {
  gap: 4px;
}

.control-field-seed-actions #newSeedButton {
  align-self: flex-start;
  width: auto;
  min-width: 0;
}

.active-seed-line {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
}

.profiles-status {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.profiles-status.enabled {
  color: #17653e;
}

.checkbox-row input {
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

input[type="number"],
select,
button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 0.82rem;
}

button {
  border-color: #a7c6ff;
  background: linear-gradient(180deg, #f0f6ff 0%, #e4efff 100%);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 4px;
}

.button-row-single {
  grid-template-columns: 1fr;
}

.stats {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px 8px;
}

.stats-grid p {
  margin: 1px 0;
  font-size: 0.74rem;
}

.stats-span-full {
  grid-column: 1 / -1;
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.results-region {
  min-width: 0;
}

.main-card {
  padding: var(--pad-card-secondary);
}

.main-card.card.card--primary {
  padding: var(--pad-card-primary);
  background: var(--panel);
}

.main-visual-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: start;
  min-width: 0;
}

@media (min-width: 1025px) {
  .main-visual-row {
    grid-template-columns: minmax(0, 1.8fr) minmax(260px, 0.6fr);
    gap: 8px;
    align-items: stretch;
    min-height: calc(100vh - 120px);
  }
}

.section-heading {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #1a2530;
  letter-spacing: -0.01em;
}

.section-hint {
  margin: 0 0 6px;
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.35;
}

.batch-tab-hint {
  margin-top: 0;
}

.canvas-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.canvas-sim-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #f6f9fc 0%, #eef3f8 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.canvas-sim-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 14px;
  min-width: 0;
}

.canvas-sim-toolbar__row--legend {
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(20, 40, 60, 0.08);
}

.canvas-sim-legend-keys {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 0.65rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.canvas-fill-key,
.canvas-border-key {
  margin: 0 0 2px;
}

.canvas-fill-key strong,
.canvas-border-key strong {
  color: #2c3d4d;
  font-weight: 600;
}

.legend--inline {
  flex: 1 1 220px;
  justify-content: flex-end;
}

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

.canvas-sim-toolbar__row--kpis {
  align-items: stretch;
  gap: 6px;
}

.canvas-kpi {
  flex: 1 1 0;
  min-width: 0;
  padding: 5px 8px;
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 0.62rem;
  color: var(--text-muted);
  line-height: 1.25;
}

.canvas-kpi--algo {
  flex: 1.4 1 120px;
}

.canvas-kpi__lab {
  display: block;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #5c6b78;
  margin-bottom: 2px;
}

.canvas-kpi__val {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.canvas-kpi__val--truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px 10px;
  flex-wrap: wrap;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-right: 2px;
  vertical-align: middle;
}

.legend-dot.waiting {
  background: #8a96a1;
}

.legend-dot.walking {
  background: #0b6cff;
}

.legend-dot.stowing {
  background: #ff8a00;
}

.legend-dot.seating {
  background: #7b61ff;
}

.legend-dot.seated {
  background: #2ea44f;
}

.canvas-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 400px;
  max-height: none;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 12px 16px;
  background: linear-gradient(160deg, #f0f4f8 0%, #e8eef4 45%, #f5f8fb 100%);
  border: 1px solid #cdd8e4;
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 2px 8px rgba(15, 35, 55, 0.06);
  overflow: hidden;

  container-type: size;
  container-name: planeFrame;
}

.canvas-frame canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  border: none;
  border-radius: 0;
  background: transparent;
}

@media (min-width: 1025px) {
  .canvas-panel.main-card.card.card--primary {
    height: calc(100vh - 20px);
    min-height: 700px;
    padding: 8px 10px;
  }

  .canvas-frame {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;

    container-type: size;
    container-name: planeFrame;
  }

  .canvas-frame canvas {
    display: block;
    max-height: 100%;
    max-width: 100%;
    width: auto;
    height: auto;
  }

  @supports (width: 1cqi) {
    .canvas-frame canvas {
      width: min(100cqi, calc(100cqb * 1200 / 980));
      height: min(100cqb, calc(100cqi * 980 / 1200));
      max-width: none;
      max-height: none;
    }
  }

  .algorithm-preview-section.main-card.card.card--primary {
    height: calc(100vh - 20px);
    min-height: 700px;

    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;

    padding: 8px 10px;
  }

  .algorithm-preview-section .preview-cabin-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }
}

/* Results tabs */
.results-tabs-card {
  padding: 0;
  overflow: hidden;
  background: var(--surface-muted);
}

.results-tablist {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 6px 8px 0;
  margin: 0;
  border-bottom: none;
  background: #e9eef3;
}

.results-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 8px;
  font-size: 0.7rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  border: none;
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  box-shadow: none;
}

.results-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.45);
}

.results-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  z-index: 1;
}

.results-tab.is-active {
  color: var(--accent);
  font-weight: 600;
  background: var(--panel);
  box-shadow: 0 -1px 0 var(--panel);
}

.results-tablist .results-tab {
  background-image: none;
  border-color: transparent;
  width: auto;
}

.results-tab-panel {
  display: none;
  padding: 10px 12px 12px;
  min-width: 0;
  background: var(--panel);
  border-top: 1px solid var(--border-subtle);
}

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

.batch-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.batch-kpi-card {
  position: relative;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px 6px 10px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.batch-kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.35;
}

.batch-kpi-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

.batch-kpi-value {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  word-break: break-word;
}

.batch-table-toolbar {
  margin-bottom: 6px;
}

.batch-advanced-toggle {
  width: auto;
  min-width: 0;
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.74rem;
}

.batch-metrics-simple .col-batch-advanced {
  display: none;
}

.table-scroll {
  overflow: auto;
  max-width: 100%;
  max-height: min(36vh, 340px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.72rem;
}

.data-table.compact {
  font-size: 0.68rem;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border-subtle);
  padding: 5px 8px;
  text-align: left;
  vertical-align: middle;
  line-height: 1.28;
}

.data-table.compact th,
.data-table.compact td {
  padding: 4px 7px;
}

.data-table tbody tr:nth-child(even) td {
  background: rgba(15, 30, 50, 0.025);
}

.data-table th {
  background: var(--thead-bg);
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
  font-size: 0.66rem;
  color: #2c3d4d;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(15, 30, 50, 0.06);
}

.data-table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table th.col-num {
  text-align: right;
}

.data-table .empty-row {
  text-align: center;
  color: var(--text-muted);
  font-weight: 400;
}

.type-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.2;
  white-space: nowrap;
}

.type-badge--normal {
  color: #4a5560;
  background: #eef1f4;
  border: 1px solid #e2e7ec;
}

.type-badge--optimized {
  color: #0a3d8a;
  background: #e8f1ff;
  border: 1px solid #c5daf8;
}

.data-table tr.winner td {
  background: var(--success-soft);
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 #6fc98a;
}

.data-table tbody tr.winner:nth-child(even) td {
  background: #e3f8eb;
}

.data-table td.cell-best-metric {
  background: var(--accent-soft);
  font-weight: 600;
}

.data-table tr.batch-row-best td {
  background: var(--success-soft);
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 #6fc98a;
}

.data-table tbody tr.batch-row-best:nth-child(even) td {
  background: #e3f8eb;
}

.data-table tr.batch-row-best-winrate td.col-winrate-best {
  background: #dff7e5;
}

.data-table tr.batch-row-best td.col-winrate-best {
  font-weight: 700;
}

.data-table th.batch-sort-active {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.comparison-results {
  min-width: 0;
}

.batch-comparison-results {
  margin-top: 0;
}

.batch-progress {
  margin: 4px 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Metrics tab */
.metrics-definitions {
  margin-bottom: 10px;
}

.metrics-def-heading {
  margin: 0 0 6px;
  font-size: 0.82rem;
}

.metrics-dl {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-primary);
}

.metrics-dl dt {
  font-weight: 600;
  margin-top: 6px;
  color: #2c3d4d;
}

.metrics-dl dt:first-child {
  margin-top: 0;
}

.metrics-dl dd {
  margin: 2px 0 0;
  color: var(--text-muted);
  line-height: 1.38;
  font-weight: 400;
}

.metrics-table-heading {
  margin-top: 4px;
}

/* Algorithm preview */
.preview-algo-callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f0f6ff;
  border: 1px solid var(--accent-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.preview-algo-callout__marker {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  margin-top: 1px;
}

.preview-algo-callout__body {
  flex: 1 1 auto;
  min-width: 0;
}

.preview-algo-callout__title {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #1a3555;
  letter-spacing: -0.01em;
}

.algorithm-preview-explanation {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.42;
  color: var(--ink);
  font-weight: 400;
}

.algorithm-preview-section .preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 14px;
  margin-bottom: 8px;
}

.preview-toolbar__modes {
  flex: 1 1 220px;
  min-width: 0;
}

.preview-mode-hint {
  margin: 6px 0 0;
  font-size: 0.65rem;
  line-height: 1.38;
  color: var(--text-muted);
  font-weight: 400;
}

.preview-mode-fieldset {
  border: 1px solid var(--border-subtle);
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: #fafcfd;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.preview-radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.preview-radio:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: #0a3d8a;
}

.preview-radio input {
  margin: 0;
}

.preview-field-inline {
  flex: 1 1 160px;
  min-width: 140px;
  max-width: 100%;
}

.preview-subheading {
  margin: 6px 0 3px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #2c3d4d;
}

.preview-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 6px;
  max-width: 100%;
}

.preview-heatmap-legend__label {
  flex: 0 0 auto;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.preview-heatmap-legend__bar {
  flex: 1 1 auto;
  min-width: 48px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(90deg, hsl(215, 62%, 28%) 0%, hsl(215, 55%, 52%) 50%, hsl(215, 48%, 88%) 100%);
}

.preview-strip-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #fafcfd 0%, #f3f6f9 100%);
  -webkit-overflow-scrolling: touch;
}

.preview-strip {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0;
  min-height: 34px;
  padding: 2px 2px;
}

.preview-strip-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 0 0 auto;
  margin-right: 6px;
  padding: 4px 8px 4px 4px;
  border-right: 2px solid #b8c4cf;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 6px 0 0 6px;
}

.preview-strip-group:last-child {
  border-right: none;
  margin-right: 0;
  padding-right: 4px;
}

.preview-strip-group-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: #4a5a68;
  text-align: center;
  line-height: 1.15;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.preview-strip-group-cells {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 3px;
}

.preview-strip-cell {
  flex: 0 0 auto;
  width: 11px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  cursor: default;
  transition: transform 0.1s ease, box-shadow 0.1s ease, outline-color 0.1s ease;
}

.preview-strip-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(15, 40, 70, 0.18);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  z-index: 1;
  position: relative;
}

.preview-cabin-wrap {
  overflow: auto;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fafcfd;
}

.preview-cabin {
  display: grid;
  grid-template-columns: 22px repeat(6, minmax(26px, 1fr)) 16px;
  gap: 2px;
  font-size: 0.6rem;
  line-height: 1.15;
  min-width: max-content;
}

.preview-cabin-heatmap .cabin-cell {
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.55);
  font-size: 0.58rem;
  font-weight: 700;
}

.preview-cabin .cabin-corner {
  background: transparent;
}

.preview-cabin .cabin-aisle {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.52rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
}

.preview-cabin .cabin-seat-h {
  text-align: center;
  font-weight: 700;
  color: #4a5a68;
  padding: 2px 0;
  font-size: 0.58rem;
  letter-spacing: 0.02em;
}

.preview-cabin .cabin-cell {
  text-align: center;
  padding: 2px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  min-height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.preview-cabin .cabin-cell-empty {
  color: #c5cdd4;
  font-weight: 400;
  background: #fff;
  text-shadow: none;
}

.preview-cabin .cabin-row-label {
  text-align: center;
  font-weight: 700;
  color: #4a5a68;
  font-size: 0.58rem;
  padding: 0 3px;
  font-variant-numeric: tabular-nums;
}

.preview-phases {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.preview-phase-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.66rem;
  font-weight: 500;
  background: #fff;
  line-height: 1.25;
  max-width: 100%;
}

.preview-phase-chip--neutral {
  background: #f4f6f8;
  border-color: #dce3ea;
  color: var(--text-muted);
  font-weight: 600;
}

.preview-phase-chip--empty {
  background: #fff8f0;
  border-color: #f0d9c4;
  color: #7a4a1e;
}

.preview-phase-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

@media (max-width: 1200px) {
  .layout {
    gap: 6px;
    padding: 6px;
  }

  .sidebar.controls {
    padding: 6px 8px;
  }

  .main-card {
    padding: 6px 8px;
  }
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar.controls {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .segmented-control.sidebar-segmented.sidebar-mode-switch {
    flex-wrap: nowrap;
  }

  .sidebar-mode-btn {
    flex: 1 1 0;
    min-height: 36px;
    font-size: 0.68rem;
    padding: 8px 4px;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .batch-kpi-row {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 1024px) {
  .canvas-panel.main-card.card.card--primary {
    min-height: 520px;
  }

  .canvas-frame {
    min-height: 460px;
    height: auto;
  }

  .algorithm-preview-section.main-card.card.card--primary {
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 600px) {
  .canvas-panel.main-card.card.card--primary {
    min-height: 420px;
  }

  .canvas-frame {
    min-height: 360px;
    padding: 8px;
  }
}