/* ============================================================================
   CALIBER WORKS: Ballistics Lab & Ammunition Manufacturing Sim Stylesheet
   Light-Gray Industrial Laboratory Theme (Dark Monitor Canvases Preserved)
   ============================================================================ */

:root {
  --bg-base: #e2e7ef;
  --bg-panel: #f4f6fa;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border-dim: #cbd5e1;
  --border-highlight: #94a3b8;
  --text-main: #1e293b;
  --text-muted: #526173;
  --accent-cyan: #0284c7;
  --accent-green: #099268;
  --accent-amber: #d97706;
  --accent-orange: #e8590c;
  --accent-red: #dc2626;
  --font-sans: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
}

html {
  /* Keep the shared header aligned when switching between short and long tabs. */
  scrollbar-gutter: stable;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

.front-page-active > .app-header,
.front-page-active > main {
  display: none;
}

.front-page {
  flex: 1;
  display: grid;
  place-items: center;
  padding: clamp(28px, 7vh, 80px) 20px;
  background: radial-gradient(ellipse at 50% 30%, #f8fafc, var(--bg-base) 75%);
}

.front-page-card {
  width: min(100%, 660px);
  padding: clamp(24px, 4vw, 40px) clamp(20px, 5vw, 48px);
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-top: 4px solid var(--accent-cyan);
  border-radius: 12px;
  box-shadow: 0 20px 60px #1e293b12;
  text-align: center;
}

.front-page-eyebrow {
  font: 10px var(--font-mono);
  letter-spacing: .12em;
  color: var(--text-muted);
}

.front-page h1 {
  margin: 16px 0 8px;
  font-size: clamp(28px, 6vw, 48px);
  line-height: 1.15;
  letter-spacing: .04em;
}

.front-page-caption {
  color: var(--text-muted);
}

.front-page-art {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 28px;
  overflow: hidden;
  background: #d5d9de;
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  box-shadow: 0 8px 20px #17263318;
}

.front-page-art figure {
  min-width: 0;
  background: #d5d9de;
}

.front-page-art canvas {
  display: block;
  width: 100%;
  height: 220px;
}

@media (max-width: 600px) {
  .front-page-art canvas {
    height: 180px;
  }
}

.front-page-actions {
  display: grid;
  gap: 12px;
  max-width: 320px;
  margin: 28px auto 0;
}

.front-page-notices {
  margin-top: 28px;
  padding: 16px 18px;
  border: 1px solid #e6c38a;
  border-left: 4px solid var(--accent-amber);
  border-radius: 6px;
  background: #fffbeb;
  text-align: left;
  font-size: 13px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.front-page-notices p + p {
  margin-top: 10px;
}

.front-page-author {
  margin-top: 16px;
  color: var(--text-muted);
}

.front-page-author a {
  color: inherit;
}

.new-play-dialog {
  width: min(440px, calc(100% - 32px));
  margin: auto;
  padding: 28px;
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  background: var(--bg-panel);
  color: var(--text-main);
}

.new-play-dialog::backdrop {
  background: #0f172a99;
}

.new-play-dialog p {
  margin: 16px 0 24px;
}

.new-play-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.site-footer {
  margin-top: auto;
  padding: 20px clamp(16px, 3vw, 32px);
  border-top: 1px solid var(--border-dim);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.site-footer-about {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  flex: 1 1 420px;
  min-width: 0;
}

.site-footer-disclaimer {
  flex: 1 1 240px;
  min-width: 0;
  font-size: 10px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.site-footer-brand {
  font-weight: 700;
  letter-spacing: 0.06em;
}

.site-footer-credits {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  min-width: 0;
}

.site-footer-credits > div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-width: 0;
}

.site-footer dd {
  min-width: 8em;
  overflow-wrap: anywhere;
}

.site-footer a {
  color: var(--accent-cyan);
  text-underline-offset: 3px;
}

.site-footer a:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 3px;
}

/* Keep telemetry and navigation together as the header wraps on smaller screens. */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

/* Topbar */
.topbar {
  background: linear-gradient(180deg, #f8fafc 0%, #eaeff6 100%);
  border-bottom: 1px solid var(--border-highlight);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-emblem {
  font-size: 24px;
  color: var(--accent-cyan);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #0f172a;
}

.brand-sub {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(2, 132, 199, 0.12);
  border: 1px solid rgba(2, 132, 199, 0.28);
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.brand-caption {
  font-size: 11px;
  color: var(--text-muted);
}

.telemetry-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.tele-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 6px 12px;
  min-width: 135px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.tele-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.tele-history-trigger { color: var(--text-main); font: inherit; text-align: left; cursor: pointer; }
.tele-history-trigger:hover { border-color: var(--accent-cyan); background: var(--bg-hover, #edf4fa); }
.tele-history-trigger:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 3px; }
.tele-history-trigger .tele-label { display: flex; justify-content: space-between; gap: 12px; }
#telemetry-history-modal { max-width: 760px; }
#telemetry-history-content { padding: 20px var(--dialog-inset) 28px; overflow-y: auto; min-height: 0; line-height: 1.8; }
#telemetry-history-content .product-history-chart { margin: 16px 0; }
.telemetry-history-current { margin: 0 0 8px; font-size: 14px; }
.telemetry-history-current strong { margin-left: 8px; font-family: var(--font-mono); font-size: 22px; }

.tele-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 2px;
}

.tele-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.tele-delta, .tele-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.tele-warning-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-red);
  margin-top: 3px;
}

.timeline-card {
  min-width: 175px;
}

.timeline-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.week-gauge-track {
  height: 6px;
  background: #dce3ed;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 5px;
  border: 1px solid var(--border-dim);
}

.week-gauge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0284c7, #099268);
  transition: width 0.08s linear;
}

.text-danger {
  color: var(--accent-red) !important;
  font-weight: 600;
}

/* Modal (Bankruptcy / Game Over) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.modal-card {
  background: var(--bg-panel);
  border: 2px solid var(--accent-red);
  border-radius: 10px;
  max-width: 540px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.35);
  text-align: center;
}

.modal-badge-danger {
  display: inline-block;
  background: rgba(220, 38, 38, 0.12);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.modal-title {
  font-size: 18px;
  color: var(--text-main);
  margin-bottom: 8px;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.modal-stats-box {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 12px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.time-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-short-label, #btn-header-more { display: none; }

@media (max-width: 768px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 70px;
    grid-template-areas: "funds funds reputation" "timeline advance more";
    gap: 4px 8px;
    padding: 6px 10px;
  }
  .topbar .telemetry-strip, .topbar .time-controls { display: contents; }
  .app-header .header-full-label, .app-header .brand-block,
  .app-header #card-lines, .app-header #btn-mute, .app-header #btn-reset,
  .app-header #btn-achievements, .app-header #btn-tutorial,
  .app-header .timeline-label-row, .app-header #stat-month,
  .app-header #card-reputation .tele-unit, .app-header #stat-rep-delta,
  .app-header .tab-num, .app-header .tab-badge { display: none; }
  .app-header .header-short-label { display: inline; }
  .app-header .tele-card {
    min-width: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 3px;
  }
  .app-header #card-funds {
    grid-area: funds;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    column-gap: 6px;
    min-height: 36px;
  }
  .app-header #card-reputation {
    grid-area: reputation;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    min-height: 36px;
  }
  .app-header .tele-label { letter-spacing: 0; white-space: nowrap; }
  .app-header .tele-label > span[aria-hidden] { display: none; }
  .app-header .tele-value { font-size: 13px; overflow-wrap: anywhere; }
  .app-header .tele-value-row { margin: 0; flex-wrap: wrap; gap: 2px 6px; min-width: 0; }
  .app-header .tele-delta { font-size: 10px; }
  .app-header .tele-warning-sub { flex-basis: 100%; font-size: 0; margin: 0; }
  .app-header .tele-warning-sub::after { content: attr(data-compact); font-size: 11px; }
  .app-header .timeline-card { grid-area: timeline; }
  .app-header .week-gauge-track { margin-top: 3px; height: 4px; }
  .app-header #btn-next-week { grid-area: advance; min-height: 44px; padding: 8px 10px; }
  .app-header #btn-header-more { grid-area: more; display: inline-flex; min-width: 44px; min-height: 44px; justify-self: end; }
  .app-header .main-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0 6px; gap: 0; }
  .app-header .tab-btn { min-width: 0; justify-content: center; min-height: 44px; padding: 8px 2px; font-size: 12px; gap: 0; }
  .topbar.header-expanded {
    grid-template-areas: "funds funds reputation" "timeline advance more" "brand brand brand" "lines lines lines" "achievements achievements achievements" "tutorial tutorial tutorial" "sound reset reset";
    max-height: calc(80dvh - 44px);
    overflow-y: auto;
    row-gap: 8px;
  }
  .header-expanded .brand-block { display: flex; grid-area: brand; padding-top: 8px; border-top: 1px solid var(--border-dim); }
  .header-expanded #card-lines { display: block; grid-area: lines; }
  .header-expanded .timeline-label-row { display: flex; }
  .header-expanded #stat-month, .header-expanded #stat-rep-delta,
  .header-expanded #card-reputation .tele-unit { display: inline; }
  .header-expanded #card-reputation { flex-wrap: wrap; }
  .header-expanded #btn-mute { display: inline-flex; grid-area: sound; min-height: 44px; justify-self: start; }
  .header-expanded #btn-reset { display: inline-flex; grid-area: reset; min-height: 44px; justify-self: end; }
  .header-expanded #btn-achievements { display: inline-flex; grid-area: achievements; min-height: 44px; }
  .header-expanded #btn-tutorial { display: inline-flex; grid-area: tutorial; min-height: 44px; }
  #range-operation-report > .panel-header { flex-wrap: wrap; gap: 6px; }
  #range-operation-report > .panel-header h2 { font-size: 14px; }
}

@media (max-width: 360px) {
  .app-header .tab-btn { font-size: 11px; }
}

/* Color utilities */
.accent-green { color: var(--accent-green) !important; }
.accent-amber { color: var(--accent-amber) !important; }
.accent-cyan { color: var(--accent-cyan) !important; }
.accent-red { color: var(--accent-red) !important; }

/* Buttons */
.btn {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-lg {
  font-size: 14px;
  font-weight: 700;
  padding: 11px 18px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

#btn-next-week:disabled {
  background: #64748b;
  box-shadow: none;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

.btn-outline {
  background: var(--bg-card);
  border-color: var(--border-highlight);
  color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: #f0f9ff;
}

.btn-outline.active {
  border-color: var(--accent-green);
  color: var(--accent-green);
  background: rgba(9, 146, 104, 0.12);
}

.btn-icon {
  background: var(--bg-card);
  border-color: var(--border-dim);
  color: var(--text-main);
  padding: 7px 10px;
}

.btn-danger-ghost:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: #fef2f2;
}

.btn-fire {
  width: 100%;
  background: linear-gradient(135deg, #f59f00, #e8590c);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 11px 18px;
  box-shadow: 0 3px 10px rgba(232, 89, 12, 0.28);
}

.btn-fire:hover:not(:disabled) {
  background: linear-gradient(135deg, #f76707, #d9480f);
  transform: translateY(-1px);
}

.btn-launch {
  background: linear-gradient(135deg, #0ca678, #099268);
  color: #fff;
  font-weight: 700;
  padding: 11px 18px;
  width: 100%;
  box-shadow: 0 2px 8px rgba(9, 146, 104, 0.25);
}

.btn-launch:hover:not(:disabled) {
  background: linear-gradient(135deg, #12b886, #0ca678);
}

.btn-sm {
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  padding: 5px 10px;
  font-size: 11.5px;
}

.btn-sm:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* Navigation Tabs */
.main-tabs {
  display: flex;
  background: #d6dde8;
  border-bottom: 1px solid var(--border-highlight);
  padding: 0 18px;
  gap: 6px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.4);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: var(--bg-panel);
}

.tab-num {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.75;
}

.tab-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 10px;
}

.tab-badge.accent {
  background: rgba(217, 119, 6, 0.14);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

/* Workspace & Panels */
.workspace {
  flex: 1;
  padding: 14px 18px 28px;
  max-width: 1580px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Wizard Stepper Bar */
.wizard-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 10px 18px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.step-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 6px;
  opacity: 0.55;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.step-node.active {
  opacity: 1;
  background: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.35);
}

.step-node.done {
  opacity: 0.9;
}

.step-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
}

.step-node.active .step-circle {
  background: var(--accent-cyan);
  color: #ffffff;
  border-color: var(--accent-cyan);
}

.step-node.done .step-circle {
  background: var(--accent-green);
  color: #ffffff;
  border-color: var(--accent-green);
}

.step-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.step-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.step-arrow {
  color: var(--text-muted);
  font-size: 14px;
  opacity: 0.6;
}

.wizard-page {
  display: none;
  animation: fadeInPage 0.2s ease-out;
}

.wizard-page.active {
  display: block;
}

@keyframes fadeInPage {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-1-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .page-1-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 8px;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-header.compact {
  padding-bottom: 6px;
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.02em;
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.badge-cyan {
  background: rgba(2, 132, 199, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(2, 132, 199, 0.32);
}

.badge-amber {
  background: rgba(217, 119, 6, 0.12);
  color: var(--accent-amber);
  border: 1px solid rgba(217, 119, 6, 0.32);
}

.badge-orange {
  background: rgba(232, 89, 12, 0.12);
  color: var(--accent-orange);
  border: 1px solid rgba(232, 89, 12, 0.32);
}

.badge-green {
  background: rgba(9, 146, 104, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(9, 146, 104, 0.32);
}

.badge-red {
  background: rgba(220, 38, 38, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(220, 38, 38, 0.32);
}

/* Controls & Sliders */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-box {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 12px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.recipe-help-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.recipe-info-button {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--accent-cyan);
  border-radius: 50%;
  background: #e0f2fe;
  color: #0369a1;
  font: 700 13px Georgia, serif;
  cursor: help;
}

.recipe-info-button:hover,
.recipe-info-button:focus-visible {
  background: #0284c7;
  color: #fff;
  outline: 2px solid #0284c7;
  outline-offset: 2px;
}

.recipe-help-tooltip {
  position: fixed;
  z-index: 10003;
  width: 320px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid #67e8f9;
  border-radius: 8px;
  background: #101c2b;
  color: #edf6ff;
  box-shadow: 0 8px 24px #0003;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.7;
}

.recipe-help-tooltip[hidden] { display: none; }

.lab-select, .lab-input {
  background: var(--bg-input);
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  width: 100%;
}

.lab-select:focus, .lab-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.helper-text {
  font-size: 12px;
  color: var(--text-muted);
}

.helper-text.mini {
  font-size: 11px;
  line-height: 1.35;
}

.components-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sliders-box {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.slider-val-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mono-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-amber);
  min-width: 56px;
  text-align: center;
}

.step-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  cursor: pointer;
}

.step-btn:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: #e0f2fe;
}

.density-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
}

.density-pill.warn {
  background: rgba(220, 38, 38, 0.15);
  color: var(--accent-red);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-cyan);
  height: 5px;
  /* Only the thumb starts a drag; touching the track must not change values. */
  pointer-events: none;
  touch-action: pan-y;
}

input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  cursor: ew-resize;
}

input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  cursor: ew-resize;
}

/* Switch by the current pointer, including on PCs with both mouse and touch. */
html[data-slider-pointer="mouse"] input[type="range"] {
  pointer-events: auto;
  cursor: pointer;
}

.line-vol-slider,
.line-price-slider {
  height: 24px;
  touch-action: pan-y;
}

/* Blueprint & Cost Breakdown on Step 1 (Keep dark monitor colors for canvas) */
.blueprint-large-wrap {
  background: #090e14;
  border: 1px solid #334155;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
}

#canvas-blueprint {
  width: 100%;
  height: 290px;
  display: block;
}

.cost-breakdown-box {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cost-breakdown-box h3 {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.cost-line {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}

.cost-line strong {
  font-family: var(--font-mono);
}

.cost-line.total {
  font-size: 13px;
  color: var(--text-main);
}

.cost-line.box-total {
  font-size: 14px;
  margin-top: 2px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-dim);
  margin: 3px 0;
}

.wizard-nav-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
}

.wizard-nav-footer.split {
  justify-content: space-between;
  flex-wrap: wrap;
}

/* Step 2: Platform Setup */
.platform-setup-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

@media (max-width: 850px) {
  .platform-setup-grid {
    grid-template-columns: 1fr;
  }
}

.preset-chips, .distance-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip-btn, .dist-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover, .chip-btn.active,
.dist-btn:hover, .dist-btn.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(2, 132, 199, 0.12);
  font-weight: 700;
}

/* Keep dark monitor colors for gun preview & live action monitor */
.gun-preview-box {
  background: #070c12;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px;
}

.gun-preview-box .chart-caption,
.chart-box .chart-caption {
  color: #94a3b8;
}

#canvas-platform-preview {
  width: 100%;
  height: 190px;
  display: block;
}

/* Step 3: Live 10-Shot Firing Range */
.firing-range-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.range-header-bar {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-wrap: wrap;
}

.range-controls-block {
  display: flex;
  gap: 8px;
}

.range-visual-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 1120px) {
  .range-visual-grid {
    grid-template-columns: 1fr;
  }
}

.gun-live-wrap, .target-live-wrap {
  background: #070c12;
  border: 1px solid #334155;
  border-radius: 6px;
  overflow: hidden;
}

#canvas-gun-live {
  width: 100%;
  height: 220px;
  display: block;
}

@media (max-width: 768px) {
  #canvas-gun-live, #canvas-platform-preview { height: 280px; }
}

#canvas-target-live {
  width: 100%;
  height: 255px;
  display: block;
}

/* 10-Shot Chronograph Table */
.chrono-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 8px 10px;
}

.chrono-table-wrap > summary.chart-caption {
  cursor: pointer;
  margin: 0;
  padding: 4px 0;
}

.chrono-table-wrap > summary:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 3px;
}

@media (max-width: 1120px) {
  .chrono-table-wrap > summary.chart-caption { padding: 10px 0; }
}

.chrono-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}

.chrono-table th {
  text-align: left;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-highlight);
}

.chrono-table td {
  padding: 4.5px 8px;
  border-bottom: 1px solid #e2e8f0;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.chrono-table tr.row-malfunction {
  background: rgba(232, 89, 12, 0.1);
}

.chrono-table tr.row-catastrophic {
  background: rgba(220, 38, 38, 0.14);
  color: #b91c1c;
  font-weight: 700;
}

/* Telemetry Gauges Grid */
.gauges-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.gauges-grid.compact-3x2 {
  grid-template-columns: repeat(3, 1fr);
}

.gauge-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
}

.gauge-card.highlight {
  border-color: var(--accent-amber);
  background: rgba(217, 119, 6, 0.06);
}

.gauge-card.danger {
  border-color: var(--accent-red);
  background: rgba(220, 38, 38, 0.07);
}

.gauge-title {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.gauge-main {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.gauge-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
}

.gauge-bar-track {
  height: 5px;
  background: #dce3ed;
  border-radius: 3px;
  overflow: hidden;
  margin: 2px 0;
}

.gauge-bar-fill {
  height: 100%;
  background: var(--accent-green);
  width: 50%;
  transition: width 0.2s ease, background 0.2s ease;
}

.chart-box {
  background: #090e14;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
}

.chart-caption {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
  padding-left: 4px;
}

#canvas-ballistics {
  width: 100%;
  height: 165px;
  display: block;
}

/* Suitability & Diagnostics */
.diagnostics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 900px) {
  .diagnostics-grid {
    grid-template-columns: 1fr;
  }
}

.diag-box {
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 105px;
}

.diag-box h3 {
  font-size: 11.5px;
  color: #334155;
  margin-bottom: 8px;
}

.badge-list, .issues-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suit-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--accent-cyan);
  padding: 6px 8px;
  border-radius: 4px;
}

.suit-head {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 12px;
}

.suit-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.usage-section { min-width: 0; margin-bottom: 12px; }
.audience-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.audience-tags .badge { white-space: normal; line-height: 1.6; }
.audience-tags small { font-weight: normal; }
.audience-earned { animation: audience-earned 180ms ease-out; }
@keyframes audience-earned { from { opacity: .65; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .audience-earned { animation: none; } }
.usage-section h4 { font-size: 13px; margin: 4px 0 8px; }
.usage-section .suit-item { margin-bottom: 6px; }
.usage-section .suit-head { gap: 8px; flex-wrap: wrap; }
.usage-table-scroll { overflow-x: auto; max-width: 100%; }
.usage-table { width: 100%; min-width: 520px; font-size: 11px; border-collapse: collapse; }
.usage-table th, .usage-table td { padding: 7px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.usage-table td:first-child { min-width: 140px; }
.usage-table th, .usage-table td:nth-child(2), .usage-table td:nth-child(3) { white-space: nowrap; }

.issue-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--accent-amber);
  padding: 6px 8px;
  border-radius: 4px;
}

.issue-item.critical {
  border-left-color: var(--accent-red);
  background: rgba(220, 38, 38, 0.06);
}

.issue-item.critical .issue-title {
  color: var(--accent-red);
}

.issue-item.warning {
  border-left-color: var(--accent-orange);
  background: rgba(232, 89, 12, 0.06);
}

.issue-item.warning .issue-title {
  color: var(--accent-orange);
}

.issue-item.ok {
  border-left-color: var(--accent-green);
  background: rgba(9, 146, 104, 0.06);
}

.issue-title {
  font-weight: 700;
  font-size: 12px;
}

.issue-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Step 4: Commercialization */
.step4-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 750px) {
  .step4-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.commercial-box {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid var(--border-highlight);
  border-radius: 6px;
  padding: 16px 18px;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.price-metrics-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.price-metrics-row strong {
  font-family: var(--font-mono);
  color: var(--text-main);
}

.forecast-box {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.forecast-box.horizontal {
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
}

.forecast-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}

.forecast-item strong {
  font-family: var(--font-mono);
}

/* Catalog Tab & Flowing Sales Timeline */
.catalog-layout {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .catalog-layout {
    grid-template-columns: 1fr;
  }
}

.catalog-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 12px;
}

.production-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-catalog-dialog {
  --dialog-edge: 48px;
  --dialog-inset: 32px;
  width: min(1400px, calc(100% - var(--dialog-edge) * 2));
  margin: auto;
  max-width: none;
  max-height: calc(100dvh - var(--dialog-edge) * 2);
  padding: 0;
  border: 1px solid var(--border-highlight);
  border-radius: 16px;
  background: var(--bg-panel);
  color: var(--text-main);
  box-shadow: 0 16px 56px rgba(15, 23, 42, 0.3);
  overflow: hidden;
}

.product-catalog-dialog::backdrop {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
}

.caliber-unlocked-dialog { width: min(620px, calc(100% - var(--dialog-edge) * 2)); overflow-y: auto; }
.caliber-unlocked-dialog .product-catalog-window { max-height: none; }
.caliber-unlocked-dialog h2 { margin-top: 14px; overflow-wrap: anywhere; }
.caliber-unlocked-content { padding: 0 var(--dialog-inset) 28px; }
.caliber-unlocked-content p { color: var(--text-muted); line-height: 1.8; }
.caliber-unlocked-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.caliber-unlocked-actions .btn { flex: 1 1 220px; text-align: center; white-space: normal; text-decoration: none; }
.caliber-picker-trigger { text-align: left; cursor: pointer; white-space: normal; }
.caliber-picker-toolbar label { max-width: 100%; }
.caliber-picker-list { overflow-y: auto; min-height: 0; padding: 16px var(--dialog-inset) 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; overscroll-behavior: contain; }
.caliber-picker-heading { grid-column: 1 / -1; font-size: 15px; margin: 12px 0 0; }
.caliber-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; border: 1px solid var(--border-dim); border-radius: 8px; color: var(--text-main); background: var(--bg-card); text-align: left; cursor: pointer; min-width: 0; }
.caliber-choice:hover, .caliber-choice.selected { border-color: var(--accent-cyan); background: var(--bg-panel); }
.caliber-choice:focus-visible, .caliber-picker-trigger:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }
.caliber-choice-name { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.caliber-choice-meta { color: var(--text-muted); font-size: 12px; }
.caliber-choice-status { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 600px) {
  #caliber-picker-modal .panel-header > div { display: contents; }
  #caliber-picker-title { grid-column: 1; grid-row: 1; }
  #btn-close-caliber-picker { grid-column: 2; grid-row: 1; }
  #caliber-picker-description { grid-column: 1 / -1; grid-row: 2; margin-top: 0; }
  #caliber-picker-modal .panel-header { gap: 10px; padding-top: 16px; padding-bottom: 16px; }
}

.product-catalog-window {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--dialog-edge) * 2 - 2px);
  min-height: 0;
}

.product-catalog-window > .panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  flex-shrink: 0;
  padding: 24px var(--dialog-inset);
  gap: 20px;
}

.product-catalog-window > .panel-header > div {
  flex: 1;
  min-width: 0;
}

.product-catalog-window .helper-text {
  margin-top: 10px;
  line-height: 1.8;
}

.product-catalog-window > .panel-header h2 { font-size: 18px; line-height: 1.5; }
.product-catalog-window > .panel-header > button { flex-shrink: 0; padding: 10px 20px; }

.product-catalog-window > :is(#factory-quality-content, #warehouse-panel, .product-catalog-items) {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  scrollbar-gutter: stable;
  padding: 28px var(--dialog-inset) 36px;
}

.product-catalog-items {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}

#factory-quality-status {
  flex-shrink: 0;
  padding: 16px var(--dialog-inset) 0;
  line-height: 1.7;
}

#factory-quality-status:empty {
  display: none;
}

.product-catalog-items > .product-card { padding: 14px; gap: 8px; border-radius: 10px; }
.product-catalog-items .prod-header { gap: 16px; flex-wrap: wrap; }
.product-catalog-items .prod-stats-grid { padding: 8px; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.product-catalog-items .prod-actions { flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.product-catalog-items .product-reviews { line-height: 1.8; }
.product-catalog-items details { margin: 8px 0; }

.catalog-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 12px var(--dialog-inset); border-bottom: 1px solid var(--border-dim); flex-shrink: 0; }
.catalog-toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; min-width: 0; }
.catalog-toolbar select, #product-history-months { max-width: 100%; min-height: 36px; padding: 6px 10px; color: var(--text-main); background: var(--bg-card); border: 1px solid var(--border-highlight); border-radius: 6px; }
#catalog-visible-count { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.prod-components { font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.product-catalog-items .prod-title { overflow-wrap: anywhere; }
.product-catalog-items > .product-card { cursor: pointer; }
.product-catalog-items > .product-card:hover { border-color: var(--accent-cyan); }
.product-catalog-items > .product-card:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }
.product-detail-specs { padding-left: 22px; margin: 0 0 20px; }
.product-detail-blueprint { margin: 0 0 20px; min-width: 0; }
.product-detail-blueprint figcaption { margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.product-detail-blueprint canvas { display: block; width: 100%; max-width: 720px; height: 290px; border: 1px solid var(--border-highlight); border-radius: 8px; }
.product-detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.product-detail-specs li { margin: 6px 0; }
.product-history-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-dim); }
.product-catalog-items { gap: 12px; align-items: start; }
.product-catalog-items .prod-actions { gap: 6px; margin-top: 0; }
#product-detail-content { padding: 20px var(--dialog-inset) 32px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; line-height: 1.8; overflow-wrap: anywhere; }
#product-detail-content > .audience-tags, #product-detail-content > .product-reviews { margin-top: 20px; }
.product-history-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.product-history-chart { margin: 0; padding: 12px; border: 1px solid var(--border-highlight); border-radius: 8px; background: var(--bg-card); min-width: 0; }
.product-history-chart figcaption { font-size: 13px; font-weight: 600; }
.product-history-chart svg { width: 100%; height: auto; display: block; color: var(--text-muted); }
.product-history-chart text { fill: currentColor; font-size: 13px; }
.product-history-table { overflow-x: auto; }
.product-history-table table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.product-history-table :is(td, th) { padding: 8px; border-bottom: 1px solid var(--border-dim); text-align: right; }
@media (max-width: 640px) {
  .product-history-charts { grid-template-columns: 1fr; }
  .catalog-toolbar { gap: 8px; }
  .catalog-toolbar label:first-child { flex-basis: 100%; }
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.prod-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.prod-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.prod-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.prod-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.prod-stat span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
}

.prod-stat strong {
  font-family: var(--font-mono);
}

.prod-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

/* Market Trend Banner */
.market-trend-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-left: 4px solid var(--accent-cyan);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.market-trend-banner.positive {
  border-left-color: var(--accent-green);
  background: rgba(9, 146, 104, 0.05);
}

.market-trend-banner.negative {
  border-left-color: var(--accent-red);
  background: rgba(220, 38, 38, 0.05);
}

.trend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 12px;
}

/* Flowing Timeline Stream Bar in Market Tab */
.market-timeline-stream {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.stream-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}

.stream-week-label {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--accent-cyan);
}

.stream-status-text {
  color: var(--text-muted);
  font-size: 11px;
  flex: 1;
  text-align: center;
}

.stream-pct-label {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
  min-width: 36px;
  text-align: right;
}

.stream-track {
  position: relative;
  height: 16px;
  background: #e2e8f0;
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  overflow: hidden;
}

.stream-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.35), rgba(9, 146, 104, 0.55));
  transition: width 0.06s linear;
}

.stream-conveyor-Belt {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 10px,
    rgba(2, 132, 199, 0.14) 10px,
    rgba(2, 132, 199, 0.14) 20px
  );
  background-size: 28px 28px;
  opacity: 0.35;
}

.market-timeline-stream.running .stream-conveyor-Belt {
  opacity: 1;
  animation: conveyorFlow 0.55s linear infinite;
}

@keyframes conveyorFlow {
  from { background-position: 0 0; }
  to { background-position: 28px 0; }
}

.stream-runner-icon {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
  transition: left 0.06s linear;
}

/* Ledger Log Flowing Timeline */
.ledger-list.timeline-flow {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 620px;
  overflow-y: auto;
  padding-left: 18px;
  padding-right: 4px;
}

.ledger-list.timeline-flow::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: 3px;
  background: linear-gradient(180deg, var(--accent-cyan), var(--border-dim));
  border-radius: 2px;
}

.ledger-list.timeline-flow.running::before {
  background: repeating-linear-gradient(
    180deg,
    var(--accent-cyan) 0px,
    var(--accent-green) 14px,
    var(--accent-cyan) 28px
  );
  background-size: 100% 28px;
  animation: railFlowDown 0.7s linear infinite;
}

@keyframes railFlowDown {
  from { background-position: 0 0; }
  to { background-position: 0 28px; }
}

.ledger-entry {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-left: 4px solid var(--accent-green);
  border-radius: 6px;
  padding: 9px 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.3s ease;
}

.ledger-entry::before {
  content: "";
  position: absolute;
  left: -17px;
  top: 13px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-green);
  border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px var(--accent-green);
}

.ledger-entry.loss {
  border-left-color: var(--accent-red);
}

.ledger-entry.loss::before {
  background: var(--accent-red);
  box-shadow: 0 0 0 1px var(--accent-red);
}

.ledger-entry.flow-enter {
  animation: ledgerSlideFlowIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes ledgerSlideFlowIn {
  0% {
    opacity: 0;
    transform: translateY(-24px) scale(0.98);
    background-color: #e0f2fe;
  }
  65% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    background-color: var(--bg-card);
  }
}

.ledger-head {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 12.5px;
  gap: 8px;
  flex-wrap: wrap;
}

.ledger-details {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.production-note {
  color: var(--text-main);
}

.line-speed-upgrade {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  font-size: 12px;
}

/* Contracts & R&D Grids */
.contracts-grid, .rd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.rd-layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.contract-card, .rd-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.contract-card.completed, .rd-card.unlocked {
  border-color: rgba(9, 146, 104, 0.5);
  background: rgba(9, 146, 104, 0.05);
}

.rd-card.milestone {
  border: 2px solid var(--accent-amber);
  background: rgba(217, 119, 6, 0.05);
}

.rd-card.locked-prereq {
  opacity: 0.72;
  background: #f8fafc;
  border-style: dashed;
}

.prereq-box {
  background: #f1f5f9;
  border: 1px solid var(--border-dim);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.prereq-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.bonus-note {
  color: var(--accent-green);
  font-weight: 700;
  background: rgba(9, 146, 104, 0.08);
  padding: 3px 6px;
  border-radius: 4px;
  margin-bottom: 3px;
}

.timeline-reduction { color: var(--accent-orange); }
.event-note:has(.timeline-reduction), .bonus-note:has(.timeline-reduction) { background: rgba(232, 89, 12, 0.08); }
.event-note {
  color: var(--accent-cyan);
  font-weight: 700;
  background: rgba(2, 132, 199, 0.08);
  padding: 3px 6px;
  border-radius: 4px;
  margin-bottom: 3px;
}

.req-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.req-tag {
  background: #f1f5f9;
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
}

/* Toast Notifications */
.achievement-notifications { bottom: 90px !important; }
.achievement-toast { border-color: var(--accent-amber); border-left-color: var(--accent-amber); min-width: 230px; }
.achievement-toast small, .achievement-toast strong { display: block; }
.achievement-toast small { margin-bottom: 5px; color: #7b5800; }
.achievement-toast strong { font-size: 15px; }
#achievements-content { padding: 18px; overflow-y: auto; }
#achievements-content progress { width: 100%; accent-color: var(--accent-amber); margin: 10px 0 18px; }
.achievement-progress { margin: 0; }
.achievement-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.achievement-card { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid var(--border-dim); border-radius: 8px; background: #f8fafc; }
.achievement-card.unlocked { background: #fffbee; border-color: #e3c66a; }
.achievement-card h3 { margin: 0 0 6px; font-size: 15px; overflow-wrap: anywhere; }
.achievement-card p { margin: 0; font-size: 13px; color: var(--text-muted); }
.achievement-card small { display: block; margin-top: 8px; font-size: 11px; }
@media (max-width: 640px) { .achievement-list { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .achievement-toast { animation: none; } }
.toast-container {
  position: fixed;
  inset: auto;
  bottom: 18px;
  right: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  max-width: calc(100vw - 36px);
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: #ffffff;
  border: 1px solid var(--accent-cyan);
  border-left: 4px solid var(--accent-cyan);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.18);
  font-size: 12.5px;
  font-weight: 600;
  max-width: 360px;
  animation: slideIn 0.2s ease-out;
}

.toast.warn {
  border-color: var(--accent-amber);
  border-left-color: var(--accent-amber);
}

.toast.error {
  border-color: var(--accent-red);
  border-left-color: var(--accent-red);
}

@keyframes slideIn {
  from { transform: translateY(15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========================================================================== */
/* VISUAL CALIBER GENEALOGY TECH TREE (TAB 03)                                */
/* ========================================================================== */

.tree-status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-dim);
}

.tree-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-dot.unlocked {
  background: rgba(9, 146, 104, 0.2);
  border: 2px solid var(--accent-green);
}

.legend-dot.available {
  background: rgba(2, 132, 199, 0.2);
  border: 2px solid var(--accent-cyan);
}

.legend-dot.locked {
  background: #e2e8f0;
  border: 2px dashed #94a3b8;
}

.calibers-tree-viewport {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: #f1f5f9;
}

.tree-branch-section {
  background: #ffffff;
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.tree-branch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border-dim);
}

.tree-branch-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tree-branch-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tree-branch-scroll {
  overflow-x: auto;
  padding: 18px 20px;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 18px 18px;
  background-color: #f8fafc;
}

.tree-branch-canvas {
  position: relative;
  display: inline-block;
  min-width: 100%;
}

.tree-connector-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.tree-columns-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: stretch;
  gap: 56px;
}

.tree-col {
  display: flex;
  flex-direction: column;
  min-width: 248px;
  max-width: 248px;
}

.tree-col-header {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(226, 232, 240, 0.75);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 3px 8px;
  margin-bottom: 12px;
  text-align: center;
}

.tree-col-nodes {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  flex: 1;
}

.tree-node {
  position: relative;
  background: #ffffff;
  border: 2px solid var(--border-highlight);
  border-radius: 8px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.06);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.tree-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.tree-node.state-unlocked {
  border-color: var(--accent-green);
  background: linear-gradient(180deg, #ffffff 0%, rgba(9, 146, 104, 0.05) 100%);
}

.tree-node.state-available {
  border-color: var(--accent-cyan);
  background: linear-gradient(180deg, #ffffff 0%, rgba(2, 132, 199, 0.07) 100%);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12), 0 4px 10px rgba(2, 132, 199, 0.1);
}

.tree-node.state-locked {
  border-color: #cbd5e1;
  border-style: dashed;
  background: #f8fafc;
  opacity: 0.84;
}

.tree-node.highlight-related {
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.35), 0 6px 16px rgba(15, 23, 42, 0.14);
  border-color: var(--accent-amber);
}

/* Connection Ports on Left & Right of Node */
.node-port-in,
.node-port-out {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: #cbd5e1;
  border: 2px solid #ffffff;
  z-index: 3;
}

.node-port-in {
  left: -6px;
}

.node-port-out {
  right: -6px;
}

.tree-node.state-unlocked .node-port-in,
.tree-node.state-unlocked .node-port-out {
  background: var(--accent-green);
}

.tree-node.state-available .node-port-in {
  background: var(--accent-cyan);
}

.node-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.node-title-wrap {
  flex: 1;
  min-width: 0;
}

.node-short-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-full-name {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-caliber-info {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-cyan);
  background: rgba(2, 132, 199, 0.1);
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-caliber-info:hover {
  background: var(--accent-cyan);
  color: #ffffff;
  transform: scale(1.08);
}

.tree-node.state-mystery {
  border-color: #cbd5e1;
  border-style: dashed;
  background: #f1f5f9;
  opacity: 0.78;
}

.tree-node.state-mystery .node-short-name {
  color: #64748b;
  letter-spacing: 0.08em;
}

.node-lineage-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(2, 132, 199, 0.08);
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1.25;
}

.tree-node.state-mystery .node-lineage-tag {
  color: #64748b;
  background: #e2e8f0;
}

.node-cross-prereq {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.node-specs-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 3px 6px;
  border-radius: 4px;
}

.node-action-btn.development-pending {
  color: var(--accent-orange);
  border-color: var(--accent-orange);
  animation: developmentPendingPulse 1.6s ease-in-out infinite;
}

@keyframes developmentPendingPulse {
  0%, 100% {
    background-color: rgba(232, 89, 12, 0.04);
    box-shadow: 0 0 0 0 rgba(232, 89, 12, 0);
  }
  50% {
    background-color: rgba(232, 89, 12, 0.2);
    box-shadow: 0 0 0 3px rgba(232, 89, 12, 0.16);
  }
}

@media (prefers-reduced-motion: reduce) {
  .node-action-btn.development-pending {
    animation: none;
    background-color: rgba(232, 89, 12, 0.12);
  }
}

.node-action-btn {
  width: 100%;
  font-size: 11.5px;
  padding: 5px 8px;
  margin-top: 2px;
}

/* Caliber Information Modal */
.caliber-info-modal-card {
  max-width: 540px;
  text-align: left;
  border-color: var(--accent-cyan);
}

.cal-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* Production Lines & Unsold Inventory Risk Styles */
.catalog-layout > *, .catalog-left-stack > .panel { min-width: 0; }

.line-overview-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 14px 0 8px;
}
.line-overview-heading h3 { font-size: 13px; }
.line-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--border-highlight);
}
.line-indicator {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--border-dim);
  border-top: 3px solid var(--accent-green);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-main);
  font: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}
.line-indicator:hover { background: #eef7fc; border-color: var(--accent-cyan); }
.line-indicator:focus-visible, .prod-line-card:focus {
  outline: 3px solid var(--accent-cyan);
  outline-offset: 3px;
}
.line-indicator-idle { border-top-color: var(--border-highlight); background: #f8fafc; }
.line-indicator-warning { border-top-color: var(--accent-amber); }
.line-indicator-heading { display: flex; justify-content: space-between; align-items: center; gap: 3px; }
.line-indicator-heading > strong { font-size: 12px; white-space: nowrap; }
.line-indicator-status { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.line-indicator-product {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  line-height: 1.5;
  height: 3em;
  font-weight: 600;
}
.line-indicator-metrics { display: grid; gap: 5px; font-size: 10px; }
.line-indicator-metrics > span { display: flex; justify-content: space-between; gap: 3px; align-items: baseline; }
.line-indicator-metrics > span > span { color: var(--text-muted); white-space: nowrap; }
.line-indicator-metrics strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; min-width: 0; }
.line-indicator-shipping[data-mode="ship"] strong { color: var(--accent-green); }
.line-indicator-shipping[data-mode="stock"] strong { color: var(--accent-orange); }
@media (min-width: 1600px) {
  .workspace:has(#tab-catalog.active) { max-width: 1920px; }
  .line-overview-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
}
@media (max-width: 600px) {
  .line-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.catalog-left-stack {
  display: flex;
  flex-direction: column;
}

.prod-line-card {
  background: #ffffff;
  border: 2px solid var(--border-highlight);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.prod-line-card.active-line {
  border-color: var(--accent-cyan);
}

.prod-line-card.unsold-loss {
  border-color: var(--accent-cyan);
  background: linear-gradient(180deg, #ffffff 0%, rgba(220, 38, 38, 0.04) 100%);
}

.prod-line-card.idle-line {
  border-style: dashed;
  background: #f8fafc;
}

.line-assign-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.line-assign-row .line-product-picker { flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.line-product-actions { display: flex; justify-content: flex-start; }
.line-shipping-mode { margin: 18px 0; }
.line-shipping-options { display: flex; flex-wrap: wrap; gap: 10px; }
.line-shipping-options .btn[aria-pressed="true"] { color: #9a3412; background: #fff1e6; border-color: #f97316; box-shadow: inset 0 0 0 1px #f97316; font-weight: 700; }
.line-shipping-options .btn[data-mode="ship"][aria-pressed="true"] { color: var(--accent-green); background: #ecfdf5; border-color: var(--accent-green); box-shadow: inset 0 0 0 1px var(--accent-green); }
.line-shipping-mode .helper-text { margin-top: 10px; }
@media (max-width: 640px) {
  .line-assign-row .line-product-picker { flex-basis: calc(100% - 80px); }
}

.line-assign-row label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.line-volume-box {
  background: #f8fafc;
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.unsold-alert-box {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: var(--accent-red);
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 5px;
}
.product-reviews {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  line-height: 1.6;
}

.product-reviews p { margin: 6px 0; }
.product-reviews summary { cursor: pointer; }

/* Shared finished-product warehouse */
.warehouse-panel { padding: 16px; margin: 16px 0; border: 1px solid var(--border-dim); border-radius: 8px; background: rgba(34, 211, 238, .04); }
.warehouse-panel h3 { margin: 0; font-size: 1rem; }
[data-warehouse-usage] { --warehouse-usage-color: var(--accent-cyan); color: var(--warehouse-usage-color); }
[data-warehouse-usage="warning"] { --warehouse-usage-color: var(--accent-orange); }
[data-warehouse-usage="danger"] { --warehouse-usage-color: var(--accent-red); }
.warehouse-meter { width: 100%; height: 12px; margin: 10px 0; accent-color: var(--warehouse-usage-color); }
.warehouse-stock-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--border-dim); }
.warehouse-stock-row span { flex: 1; min-width: 160px; overflow-wrap: anywhere; }
.warehouse-stock-row input { width: 80px; padding: 7px; color: var(--text-main); background: var(--bg-input); border: 1px solid var(--border-highlight); border-radius: 4px; }
#warehouse-stock-list { margin: 12px 0; }

/* Tutorial stays above the game and also works inside the catalog's top layer. */
#tutorial-root[hidden], #tutorial-root [hidden] { display: none !important; }
.tutorial-shade { position: fixed; inset: 0; z-index: 10000; pointer-events: none; }
.tutorial-shade svg { display: block; }
.tutorial-spotlight { position: fixed; border: 3px solid #67e8f9; border-radius: 8px; box-shadow: 0 0 20px #22d3ee88; z-index: 10001; pointer-events: none; }
.tutorial-await-action .tutorial-spotlight { animation: tutorial-action-pulse 1.2s ease-in-out infinite; }
@keyframes tutorial-action-pulse { 0%, 100% { border-color: #f97316; box-shadow: 0 0 8px #f9731666; } 50% { border-color: #fdba74; box-shadow: 0 0 24px 5px #f97316cc; } }
@media (prefers-reduced-motion: reduce) { .tutorial-await-action .tutorial-spotlight { animation: none; border-color: #f97316; box-shadow: 0 0 12px #f9731688; } }
.tutorial-card { position: fixed; width: min(400px, calc(100vw - 24px)); max-height: 45dvh; overflow: auto; padding: 20px; border: 1px solid #67e8f9; border-radius: 12px; background: #101c2b; color: #edf6ff; box-shadow: 0 12px 50px #000b; z-index: 10002; font-size: 14px; line-height: 1.7; }
.tutorial-card h2 { margin: 10px 0; font-size: 19px; }
.tutorial-card p { margin: 8px 0 16px; }
.tutorial-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #67e8f9; font-size: 12px; }
.tutorial-actions { display: flex; justify-content: space-between; gap: 12px; }
.tutorial-actions #tutorial-next { margin-left: auto; }
.tutorial-active { padding-bottom: 300px; }
@media (max-width: 600px) { .tutorial-card { padding: 14px; } }
#tutorial-root[data-step="prompt"] .tutorial-card { top: 50%; left: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); box-sizing: border-box; max-height: calc(100dvh - 32px); }
/* Customer specifications and manufacturing traceability. */
#factory-quality-modal { max-width: none; }
#factory-quality-content { min-width: 0; }
.lab-order-reference { margin-bottom: 24px; padding: 18px 22px; border: 1px solid var(--border-highlight); border-radius: 12px; background: var(--bg-card); }
.lab-order-reference summary { cursor: pointer; font-weight: 700; }
.lab-order-reference[hidden] { display: none; }
#lab-order-reference-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 20px; margin-top: 18px; }
.lab-order-spec { min-width: 0; overflow-wrap: anywhere; padding: 16px; border: 1px solid var(--border-dim); border-radius: 8px; }
.lab-order-spec p { margin: 10px 0; line-height: 1.7; }
.deliver-order { margin: 12px 0; white-space: normal; }
#factory-quality-content h3 { margin: 32px 0 18px; }
.quality-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 24px; }
.quality-card { border: 1px solid var(--border-dim); background: var(--bg-card); border-radius: 12px; padding: 24px; min-width: 0; overflow-wrap: anywhere; }
.quality-card h4 { margin: 0 0 14px; font-size: 15px; }
.order-card-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 14px; }
.order-overview { margin: 12px 0 0; padding-bottom: 2px; min-width: 0; border-bottom: 2px solid var(--border-highlight); }
.order-overview[hidden] { display: none; }
.order-overview h3 { margin: 0 0 6px; font-size: 13px; }
.order-overview + .line-overview-heading { margin-top: 8px; }
.order-thumbnail-list { display: flex; gap: 12px; overflow-x: auto; padding: 4px 3px 6px; scroll-snap-type: x proximity; }
.order-thumbnail { flex: 0 0 140px; display: grid; gap: 8px; min-width: 0; padding: 10px; border: 1px solid var(--border-highlight); border-top: 3px solid var(--accent-cyan); border-radius: 8px; background: var(--bg-card); color: var(--text-main); font: inherit; text-align: left; cursor: pointer; scroll-snap-align: start; }
.order-thumbnail[data-state="active"] { border-top-color: var(--accent-green); }
.order-thumbnail:hover { border-color: var(--accent-cyan); box-shadow: 0 0 0 1px var(--accent-cyan); }
.order-thumbnail:focus-visible { outline: 3px solid var(--accent-cyan); outline-offset: 2px; }
.order-thumbnail-status { justify-self: start; padding: 2px 7px; border-radius: 4px; background: #e0f2fe; color: #0369a1; font-size: 11px; font-weight: 700; }
.order-thumbnail[data-state="active"] .order-thumbnail-status { background: #dcfce7; color: #166534; }
.order-thumbnail-caliber { font-size: 14px; overflow-wrap: anywhere; }
.order-thumbnail-metrics { display: grid; gap: 6px; font-size: 11px; }
.order-thumbnail-metrics > span { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 6px; }
.order-thumbnail-metrics > span > span { color: var(--text-muted); }
.order-thumbnail-metrics strong { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.order-thumbnail-urgent, .order-thumbnail-urgent > span { color: #b91c1c !important; }
.quality-card .order-card-header h4 { flex: 1; min-width: 120px; margin: 0; }
.order-deadline { display: grid; gap: 3px; margin-left: auto; padding: 6px 9px; border: 1px solid var(--border-highlight); border-radius: 6px; background: #f1f5f9; text-align: right; font-size: 12px; }
.order-deadline span { font-weight: 700; }
.order-deadline-urgent { color: #b91c1c; background: #fff1f2; border-color: #ef4444; }
.quality-card p { margin: 12px 0; line-height: 1.8; }
.order-financials { margin: 12px 0; border: 1px solid #a7d9bd; border-radius: 8px; overflow: hidden; }
.order-reward { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 12px; background: #edf9f1; }
.order-reward > span { font-size: 13px; font-weight: 700; color: #166534; }
.order-reward > strong { font-family: var(--font-mono); font-size: clamp(18px, 2vw, 22px); line-height: 1.25; color: #166534; }
.order-reward small { grid-column: 1 / -1; }
.order-reward small, .order-penalties small { font-size: 11px; line-height: 1.5; }
.order-financials > p { padding: 0 12px; }
.order-penalties { padding: 10px 12px; background: #fff7ed; border-top: 1px solid #f3d2b0; }
.order-penalties > strong { font-size: 13px; color: #9a3412; }
.order-penalties dl { margin: 6px 0; display: grid; gap: 5px; }
.order-penalties dl > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; }
.order-penalties dt { font-size: 13px; }
.order-penalties dd { margin: 0; font-size: 13px; font-family: var(--font-mono); font-weight: 700; color: #b91c1c; }
.quality-card ul { padding-left: 20px; font-size: .85rem; line-height: 1.9; margin: 18px 0; }
.quality-card li + li { margin-top: 6px; }
.quality-card label { display: block; margin: 16px 0; }
.quality-card progress { width: 100%; }
.quality-card select { width: 100%; }
.quality-card .contract-product {
  display: block;
  width: fit-content;
  min-width: min(100%, 280px);
  max-width: 100%;
  margin: 6px 0 0;
  padding: 10px 14px;
  background: #e0f2fe;
  border-color: var(--accent-cyan);
  color: #0369a1;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
.quality-card .contract-product:hover:not(:disabled) { background: #bae6fd; }
.quality-card .contract-product:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }
.quality-card .contract-product:disabled { opacity: .5; cursor: not-allowed; }
.quality-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.quality-actions .btn { white-space: normal; }
.quality-history { margin-top: 32px; padding: 20px 0 4px; border-top: 1px solid var(--border-dim); }
#factory-quality-status { overflow-wrap: anywhere; }
.timeline-order-request { padding: 18px; margin-top: 14px; border: 1px solid var(--accent-cyan); border-radius: 10px; background: var(--bg-card); overflow-wrap: anywhere; }
.timeline-order-request p { margin-top: 10px; line-height: 1.7; }
.timeline-line-malfunction {
  padding: 14px;
  margin-top: 12px;
  border: 1px solid var(--accent-orange);
  border-radius: 8px;
  background: var(--bg-panel);
  overflow-wrap: anywhere;
}
.timeline-line-malfunction p { margin: 8px 0; line-height: 1.7; }
.timeline-line-malfunction button { max-width: 100%; white-space: normal; }
.request-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.request-highlight { border-color: var(--accent-cyan); box-shadow: 0 0 0 2px rgba(2, 132, 199, .12); scroll-margin-top: 24px; }

.order-thumbnail.is-new-unread, .timeline-order-request.is-new-unread { animation: new-order-card-pulse 1.6s ease-in-out infinite; }
@keyframes new-order-card-pulse {
  0%, 100% { border-color: var(--border-highlight); box-shadow: 0 0 0 0 transparent; }
  50% { border-color: #f97316; box-shadow: 0 0 0 2px #f9731655; }
}
@media (prefers-reduced-motion: reduce) {
  .order-thumbnail.is-new-unread, .timeline-order-request.is-new-unread { animation: none; border-color: #f97316; box-shadow: 0 0 0 2px #f9731655; }
}

.product-catalog-window > #warehouse-panel { margin: 0; border: 0; border-radius: 0; background: transparent; }
#warehouse-panel .prod-header { gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
#warehouse-panel .warehouse-meter { margin: 16px 0; height: 14px; }
#warehouse-panel #warehouse-stock-list { margin: 24px 0 0; }
#warehouse-panel .warehouse-stock-row { padding: 20px 0; gap: 16px; }
#warehouse-panel .warehouse-stock-row input { padding: 10px; width: 92px; }
#warehouse-panel .warehouse-shipping-control { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
#warehouse-panel .warehouse-shipping-control input { width: 18px; height: 18px; margin: 0; padding: 0; accent-color: #f97316; }
#warehouse-panel .warehouse-shipping-control span { flex: none; min-width: 0; }

@media (max-width: 720px) {
  .product-catalog-dialog { --dialog-edge: 12px; --dialog-inset: 20px; border-radius: 12px; }
  .product-catalog-window > .panel-header { padding-top: 20px; padding-bottom: 20px; gap: 16px; }
  .product-catalog-window > .panel-header h2 { font-size: 16px; }
  .product-catalog-window > :is(#factory-quality-content, #warehouse-panel, .product-catalog-items) { padding-top: 22px; padding-bottom: 28px; }
  .quality-card { padding: 20px; }
  .quality-card-grid { gap: 20px; }
}
