:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-2: #161b22;
  --bg-3: #21262d;
  --panel-header-bg: #161b22;
  --panel-content-bg: #0d1117;
  --text: #e6edf3;
  --text-secondary: #c9d1d9;
  --muted: #8b949e;
  --muted-2: #5b6270;
  --accent: #539bf5;
  --accent-hover: #6cb6ff;
  --accent-subtle: rgba(83, 155, 245, 0.15);
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --schneider: #00a651;
  --border: #30363d;
  --outline: rgba(240, 246, 252, 0.1);
  --toolbar-height: 42px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(0, 166, 81, 0.14), transparent 32%),
    radial-gradient(circle at 82% 18%, rgba(83, 155, 245, 0.16), transparent 30%),
    var(--bg);
}

.auth-card {
  width: min(100%, 390px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(22, 27, 34, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.auth-wordmark {
  width: 210px;
  height: auto;
  display: block;
}

.auth-brand {
  margin-top: 18px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-product {
  margin-top: 8px;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
}

.auth-copy {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 12px;
}

.auth-form input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(13, 17, 23, 0.8);
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

.auth-form input:focus {
  border-color: rgba(83, 155, 245, 0.7);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-status {
  min-height: 18px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.auth-status.err {
  color: #ffb4ae;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 358px minmax(0, 1fr);
  overflow: hidden;
}

.app-shell.auth-pending,
.app-shell.auth-hidden {
  display: none;
}

.sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
}

.sidebar-header {
  flex-shrink: 0;
  padding: 16px 20px 15px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 17, 23, 0.42);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.logout-button {
  margin-left: auto;
  height: 26px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.logout-button:hover {
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
}

.wordmark {
  width: 174px;
  height: auto;
  display: block;
}

.poc-chip {
  flex-shrink: 0;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid rgba(83, 155, 245, 0.34);
  background: var(--accent-subtle);
  color: #cfe1ff;
  font-size: 8px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.product-title {
  margin-top: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.product-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.sidebar-content::-webkit-scrollbar {
  width: 7px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
}

.control-section + .control-section {
  margin-top: 20px;
}

.compact-section {
  padding-bottom: 4px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}

.control-row {
  margin: 0 0 15px;
}

.control-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.control-head label {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.25;
}

.value-pill {
  flex-shrink: 0;
  min-width: 64px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent-subtle);
  color: #9fccff;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: var(--bg-3);
}

input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border: 2px solid var(--bg-2);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.36);
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]:hover::-webkit-slider-thumb {
  background: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--accent-subtle), 0 1px 5px rgba(0, 0, 0, 0.36);
}

.range-bounds {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

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

.readout {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid rgba(240, 246, 252, 0.075);
  border-radius: 6px;
  background: rgba(13, 17, 23, 0.5);
}

.readout span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
}

.readout strong {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 14px 20px 16px;
  border-top: 1px solid var(--border);
  background: rgba(13, 17, 23, 0.64);
}

.action-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.button {
  height: 36px;
  border-radius: 6px;
  border: 1px solid rgba(83, 155, 245, 0.45);
  background: rgba(83, 155, 245, 0.18);
  color: #cfe1ff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.button:hover:not(:disabled) {
  background: rgba(83, 155, 245, 0.28);
  border-color: rgba(83, 155, 245, 0.65);
  color: #fff;
}

.button.secondary {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.button.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
}

.button.predict {
  border-color: rgba(0, 166, 81, 0.52);
  background: rgba(0, 166, 81, 0.2);
  color: #c8f5d6;
}

.button.predict:hover:not(:disabled) {
  border-color: rgba(0, 166, 81, 0.78);
  background: rgba(0, 166, 81, 0.32);
  color: #ffffff;
}

.button.optimise {
  border-color: rgba(163, 113, 247, 0.5);
  background: rgba(163, 113, 247, 0.16);
  color: #dec9ff;
}

.button.optimise:hover:not(:disabled) {
  border-color: rgba(163, 113, 247, 0.72);
  background: rgba(163, 113, 247, 0.26);
  color: #ffffff;
}

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

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.status::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
}

.status.ok {
  color: var(--success);
}

.status.ok::before {
  background: var(--success);
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.6);
}

.status.err {
  color: var(--danger);
}

.status.err::before {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(248, 81, 73, 0.65);
}

.status.pending {
  color: var(--warning);
}

.status.pending::before {
  background: var(--warning);
}

.status.hidden {
  display: none;
}

.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(180deg, #090c12 0%, #0d1117 52%, #07090d 100%);
  background-size: 32px 32px, 32px 32px, auto;
}

#canvas {
  position: absolute;
  inset: var(--toolbar-height) 0 0 0;
  display: block;
  width: 100%;
  height: calc(100% - var(--toolbar-height));
}

.workspace.optim-active #canvas {
  inset: calc(50% + var(--toolbar-height)) 0 0 0;
  height: calc(50% - var(--toolbar-height));
}

.canvas-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--toolbar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(180deg, rgba(8, 11, 16, 0.96) 0%, rgba(8, 11, 16, 0.88) 100%);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

.workspace.optim-active .canvas-toolbar {
  top: 50%;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.toolbar-button {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toolbar-button:hover {
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
}

.toolbar-button.active {
  border-color: rgba(83, 155, 245, 0.34);
  background: rgba(83, 155, 245, 0.18);
  color: #cfe1ff;
}

.toolbar-button svg {
  width: 16px;
  height: 16px;
}

.viewport-empty,
.loading-overlay {
  position: absolute;
  inset: var(--toolbar-height) 0 0 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  pointer-events: none;
}

.workspace.optim-active .viewport-empty,
.workspace.optim-active .loading-overlay {
  inset: calc(50% + var(--toolbar-height)) 0 0 0;
}

.empty-logo {
  width: 48px;
  height: 48px;
  opacity: 0.35;
}

.loading-overlay {
  z-index: 25;
  background: rgba(7, 10, 15, 0.78);
  backdrop-filter: blur(10px);
}

.loading-overlay.hidden,
.viewport-empty.hidden {
  display: none;
}

.loader {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(83, 155, 245, 0.18);
  border-top-color: rgba(207, 225, 255, 0.95);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.parts-panel,
.metrics-panel,
.prediction-panel {
  position: absolute;
  z-index: 18;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 10, 15, 0.68);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

.parts-panel {
  top: calc(var(--toolbar-height) + 14px);
  right: 14px;
  width: 184px;
  padding: 10px;
  border-radius: 7px;
}

.prediction-panel {
  top: calc(var(--toolbar-height) + 14px);
  left: 14px;
  width: 292px;
  padding: 12px;
  border-radius: 7px;
}

.workspace.optim-active .parts-panel,
.workspace.optim-active .prediction-panel {
  top: calc(50% + var(--toolbar-height) + 14px);
}

.prediction-panel.hidden {
  display: none;
}

.optim-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: 50%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34);
}

.optim-panel.hidden {
  display: none;
}

.optim-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(6, 10, 16, 0.72);
  backdrop-filter: blur(10px);
}

.optim-overlay.hidden {
  display: none;
}

.optim-modal {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(18, 24, 32, 0.98);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.46);
}

.optim-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.optim-modal-header h2 {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0;
}

.optim-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--border);
}

.optim-modal-footer .button {
  min-width: 92px;
}

.panel-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.panel-title-row .panel-title {
  margin-bottom: 0;
}

.panel-close {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.panel-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.prediction-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.prediction-meta span {
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  background: rgba(13, 17, 23, 0.56);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.field-select {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-select select {
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  background: rgba(13, 17, 23, 0.86);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.slice-controls {
  display: grid;
  gap: 8px;
  margin: 0 0 10px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(13, 17, 23, 0.48);
}

.slice-controls.hidden {
  display: none;
}

.slice-controls .field-select {
  margin-bottom: 0;
}

.slice-location-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.slice-location-head strong {
  color: #9fccff;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

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

.prediction-metric {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(240, 246, 252, 0.075);
  border-radius: 5px;
  background: rgba(13, 17, 23, 0.58);
}

.prediction-metric span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.prediction-metric strong {
  display: block;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prediction-colorbar {
  margin-top: 10px;
}

.colorbar-head,
.colorbar-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.colorbar-head {
  margin-bottom: 5px;
}

.colorbar-foot {
  margin-top: 5px;
}

.colorbar-strip {
  height: 9px;
  border-radius: 4px;
  background: linear-gradient(90deg, #440154 0%, #3b528b 24%, #21918c 48%, #5ec962 74%, #fde725 100%);
}

.prediction-colorbar.solid-temperature .colorbar-strip {
  background: linear-gradient(
    90deg,
    #040929 0%,
    #052e94 17%,
    #008fdb 34%,
    #00c7ad 50%,
    #e0eb33 67%,
    #fa8c08 84%,
    #db140d 100%
  );
}

.optim-panel-heading {
  margin-top: 2px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.optim-axis-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.optim-axis-controls label {
  display: grid;
  grid-template-columns: 14px 150px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.optim-axis-controls select {
  height: 30px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  background: rgba(13, 17, 23, 0.86);
  color: var(--text-secondary);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.optim-controls {
  display: grid;
  gap: 16px;
  min-height: 0;
  padding: 16px 18px;
  overflow-y: auto;
}

.optim-section {
  display: grid;
  gap: 9px;
}

.optim-section-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.optim-controls label,
.optim-range-row label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.optim-controls input {
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  background: rgba(13, 17, 23, 0.86);
  color: var(--text-secondary);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.optim-single {
  width: 120px;
}

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

.optim-range-row {
  min-width: 0;
}

.optim-range-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.optim-range-head label {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
}

.optim-range-head span {
  flex-shrink: 0;
  color: #bfa7ff;
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.dual-range {
  position: relative;
  height: 24px;
}

.dual-range-track,
.dual-range-fill {
  position: absolute;
  top: 9px;
  height: 3px;
  border-radius: 3px;
}

.dual-range-track {
  left: 0;
  right: 0;
  background: var(--bg-3);
}

.dual-range-fill {
  background: rgba(163, 113, 247, 0.62);
}

.dual-range input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 20px;
  pointer-events: none;
}

.dual-range input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
}

.dual-range input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  background: #a371f7;
}

.optim-chart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  min-height: 0;
  flex: 1;
  margin-top: 10px;
}

.optim-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid rgba(240, 246, 252, 0.075);
  border-radius: 6px;
  background: rgba(13, 17, 23, 0.58);
}

.optim-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.optim-results {
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 0;
  overflow: auto;
}

.optim-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(240, 246, 252, 0.075);
  border-radius: 5px;
  background: rgba(13, 17, 23, 0.58);
}

.optim-result.pareto {
  border-color: rgba(63, 185, 80, 0.36);
}

.optim-result.infeasible {
  border-color: rgba(139, 148, 158, 0.22);
  opacity: 0.72;
}

.optim-result strong {
  display: block;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 650;
}

.optim-result span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.optim-result button {
  height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(83, 155, 245, 0.36);
  border-radius: 5px;
  background: rgba(83, 155, 245, 0.12);
  color: #cfe1ff;
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.optim-result button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.part-list {
  display: grid;
  gap: 7px;
}

.part-toggle {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.part-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.part-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: 1px;
}

.metrics-panel {
  left: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: repeat(5, auto);
  gap: 1px;
  overflow: hidden;
  border-radius: 7px;
}

.metric {
  min-width: 72px;
  padding: 8px 10px;
  background: rgba(13, 17, 23, 0.64);
}

.metric span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric strong {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 940px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: 48vh minmax(0, 1fr);
  }

  .sidebar {
    min-height: 0;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .workspace {
    min-height: 0;
  }

  .parts-panel {
    width: 172px;
  }

  .prediction-panel {
    top: calc(var(--toolbar-height) + 14px);
    left: auto;
    right: 10px;
    width: min(292px, calc(100% - 20px));
  }

  .metrics-panel {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .metric {
    min-width: 0;
    padding: 7px 8px;
  }

  .metric strong {
    font-size: 11px;
  }
}

@media (max-width: 560px) {
  .sidebar-header,
  .sidebar-content,
  .sidebar-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .wordmark {
    width: 152px;
  }

  .canvas-toolbar {
    justify-content: flex-end;
  }

  .parts-panel {
    left: 10px;
    right: auto;
    width: 164px;
  }

  .prediction-panel {
    left: 10px;
    right: 10px;
    top: calc(var(--toolbar-height) + 114px);
    width: auto;
  }

  .metrics-panel {
    left: 10px;
    right: 10px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .metric {
    min-width: 0;
  }
}
