:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --panel: #ffffff;
  --ink: #17201d;
  --muted: #66736f;
  --line: #dfe5df;
  --accent: #0d7a64;
  --accent-2: #d97842;
  --warn: #c23b22;
  --good: #16724e;
  --risk-bg: #fff2ed;
  --risk-line: #d89987;
  --watch-bg: #fff8e6;
  --watch-line: #d9b56f;
  --good-bg: #ecf8f2;
  --good-line: #a9d8c1;
  --shadow: 0 18px 40px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.brand small,
.panel-heading span,
.topbar p,
.canvas-header p,
.panel p {
  color: var(--muted);
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 16px;
}

.panel.compact p {
  margin-bottom: 0;
}

.panel h2,
.canvas-header h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  font-size: 14px;
}

output {
  color: var(--accent);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

button,
.primary,
select {
  border: 1px solid var(--line);
  background: white;
  border-radius: 7px;
  min-height: 38px;
  padding: 0 13px;
  cursor: pointer;
}

button:hover,
select:hover,
.primary:hover,
.secondary:hover {
  border-color: rgba(13, 122, 100, 0.42);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(13, 122, 100, 0.2);
  outline-offset: 2px;
}

.primary {
  width: 100%;
  margin-top: 18px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.secondary {
  width: 100%;
  margin-top: 10px;
  color: var(--accent);
  font-weight: 700;
}

.compact-button {
  width: auto;
  margin-top: 0;
  white-space: nowrap;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.preset-button {
  min-height: 34px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.preset-button.is-active {
  border-color: var(--accent);
  background: #e7f4ef;
  color: var(--accent);
}

.journey-stage-strip,
.planning-layer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.journey-stage-strip span,
.planning-layer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.journey-stage-strip span.is-done {
  border-color: var(--good-line);
  background: var(--good-bg);
  color: var(--good);
}

.planning-layer-toggle {
  margin-top: 0;
  cursor: pointer;
}

.planning-layer-toggle input {
  margin: 0;
  accent-color: var(--accent);
}

.decision-workbench {
  margin-top: 16px;
}

.production-workbench {
  margin-top: 16px;
}

.decision-trace-grid,
.mine-planning-grid,
.production-readiness-grid,
.assurance-gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.decision-trace-grid article,
.mine-planning-grid article,
.production-gate,
.assurance-gate {
  min-height: 86px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.decision-trace-grid span,
.mine-planning-grid span,
.production-gate span,
.assurance-gate span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.decision-trace-grid strong,
.mine-planning-grid strong,
.production-gate strong,
.assurance-gate strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.decision-trace-grid small,
.mine-planning-grid small,
.production-gate small,
.assurance-gate small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.production-gate.is-pass,
.assurance-gate.is-pass,
.export-pack-item.is-ready {
  border-color: var(--good-line);
  background: var(--good-bg);
}

.production-gate.is-partial,
.assurance-gate.is-partial {
  border-color: var(--watch-line);
  background: var(--watch-bg);
}

.production-gate.is-block,
.assurance-gate.is-block {
  border-color: var(--risk-line);
  background: var(--risk-bg);
}

.decision-log-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.decision-log-list li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.decision-log-list strong,
.decision-log-list span,
.decision-log-list small {
  display: block;
}

.decision-log-list span {
  margin: 4px 0;
}

.decision-log-list small {
  color: var(--muted);
}

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

.production-shell-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.export-pack-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.export-pack-item span,
.export-pack-item strong {
  display: block;
}

.export-pack-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.experiment-row td {
  vertical-align: top;
}

.experiment-output {
  display: block;
  font-weight: 800;
}

.experiment-bar {
  display: block;
  width: 72px;
  height: 5px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.experiment-row-capacity .experiment-bar {
  width: 92px;
  background: #dff2e9;
}

.experiment-row-stress .experiment-bar {
  width: 108px;
  background: #f6d6cf;
}

.experiment-table-wrap {
  overflow-x: auto;
}

#spatialImportInput {
  width: 100%;
  resize: vertical;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 0;
}

.run-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.run-status[data-state="running"],
.run-status[data-state="drafting"] {
  border-color: var(--watch-line);
  background: var(--watch-bg);
  color: #71510f;
}

.run-status[data-state="complete"],
.run-status[data-state="saved"] {
  border-color: var(--good-line);
  background: var(--good-bg);
  color: var(--good);
}

.run-status[data-state="fallback"],
.run-status[data-state="blocked"] {
  border-color: var(--risk-line);
  background: var(--risk-bg);
  color: #7b2f24;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.environment-builder {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.demo-journey-panel {
  margin-bottom: 16px;
}

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

.demo-journey-card {
  display: grid;
  gap: 8px;
  min-height: 176px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
  text-align: left;
}

.demo-journey-card:hover,
.demo-journey-card.is-active {
  border-color: rgba(13, 122, 100, 0.5);
  background: linear-gradient(180deg, #ffffff 0%, #eef7f3 100%);
}

.demo-journey-card strong {
  font-size: 15px;
}

.demo-journey-card span,
.demo-journey-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.demo-journey-card em {
  align-self: end;
  color: var(--accent);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.builder-panel textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fbfcfa;
  line-height: 1.45;
}

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

.object-detail-form label {
  margin-top: 0;
}

.object-detail-form input,
.object-detail-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fbfcfa;
}

.object-detail-form .compact-button {
  grid-column: 1 / -1;
}

.object-detail-form .danger-button {
  border-color: #c98577;
  color: #7b2f24;
}

.object-detail-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.layout-validation-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.layout-validation-list li {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.layout-validation-list li[data-severity="fail"] {
  border-color: #c98577;
  color: #7b2f24;
}

.layout-validation-list li[data-severity="warn"] {
  border-color: #d9b56f;
  color: #71510f;
}

.builder-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.builder-actions .primary,
.builder-actions .secondary {
  margin-top: 12px;
}

.photo-intake {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.photo-intake label {
  margin-top: 0;
}

.photo-intake input[type="file"] {
  width: 100%;
  min-height: 42px;
  padding: 9px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.photo-intake textarea {
  width: 100%;
  margin-top: 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  line-height: 1.45;
  background: #fbfcfa;
}

.photo-intake p {
  margin: 8px 0 0;
  font-size: 13px;
}

.photo-preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.photo-preview-row img {
  width: 88px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef2ed;
}

.photo-evidence-tile {
  display: grid;
  align-content: center;
  width: 118px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #eef2ed;
}

.photo-evidence-tile strong,
.photo-evidence-tile small {
  display: block;
}

.photo-evidence-tile strong {
  color: var(--accent);
  font-size: 14px;
}

.photo-evidence-tile small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.scene-panel {
  grid-row: span 2;
}

.scene-preview {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(30deg, rgba(13, 122, 100, 0.08) 12%, transparent 12.5%, transparent 87%, rgba(13, 122, 100, 0.08) 87.5%, rgba(13, 122, 100, 0.08)),
    linear-gradient(150deg, rgba(13, 122, 100, 0.08) 12%, transparent 12.5%, transparent 87%, rgba(13, 122, 100, 0.08) 87.5%, rgba(13, 122, 100, 0.08)),
    #f8faf7;
  background-size: 32px 56px;
}

.scene-preview::after,
.planning-view-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72), inset 0 -26px 46px rgba(23, 32, 29, 0.04);
}

.scene-zone,
.scene-object {
  position: absolute;
  border-radius: 8px;
}

.scene-scale-note {
  position: absolute;
  z-index: 4;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border: 1px solid rgba(22, 79, 131, 0.24);
  border-radius: 7px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.9);
  color: #164f83;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  box-shadow: 0 8px 18px rgba(23, 32, 29, 0.08);
  pointer-events: none;
}

.scene-zone {
  border: 1px dashed rgba(23, 32, 29, 0.18);
  background: rgba(255, 255, 255, 0.55);
}

.scene-object {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  border: 1px solid rgba(23, 32, 29, 0.16);
  background: #ffffff;
  box-shadow: 0 10px 18px rgba(23, 32, 29, 0.08);
  padding: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.scene-object:active {
  cursor: grabbing;
}

.scene-object.is-corrected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 122, 100, 0.16), 0 10px 18px rgba(23, 32, 29, 0.08);
}

.scene-object.is-selected {
  border-color: var(--warn);
  box-shadow: 0 0 0 3px rgba(194, 59, 34, 0.18), 0 10px 18px rgba(23, 32, 29, 0.08);
}

.scene-object[data-mobility="fixed"]::after {
  content: "fixed";
  position: absolute;
  right: 5px;
  bottom: 4px;
  border-radius: 999px;
  padding: 2px 5px;
  background: rgba(23, 32, 29, 0.82);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
}

.scene-object::before {
  content: attr(data-icon);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-size: 13px;
}

.scene-object[data-type*="dryer"]::before,
.scene-object[data-type*="dock"]::before {
  background: var(--accent-2);
}

.scene-object[data-type*="rack"]::before,
.scene-object[data-type*="packing"]::before {
  background: #164f83;
}

.scene-preview.is-dense .scene-object {
  min-width: 9px;
  min-height: 9px;
  padding: 0;
  border-radius: 4px;
  border-color: rgba(23, 32, 29, 0.12);
  box-shadow: 0 3px 6px rgba(23, 32, 29, 0.08);
  overflow: hidden;
}

.scene-preview.is-dense .scene-object span,
.scene-preview.is-dense .scene-object small,
.scene-preview.is-dense .scene-object[data-mobility="fixed"]::after {
  display: none;
}

.scene-preview.is-dense .scene-object::before {
  width: 100%;
  height: 100%;
  min-width: 9px;
  min-height: 9px;
  border-radius: 4px;
  font-size: 0;
}

.confidence-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #fff1e8;
  color: #9a4a1f;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.draft-list {
  display: grid;
  gap: 9px;
  padding: 0;
  list-style: none;
}

.draft-list li {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.draft-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.draft-list strong,
.draft-list small {
  display: block;
}

.draft-list small {
  color: var(--muted);
  font-size: 12px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.kpi-card[data-tone="good"] {
  border-color: var(--good-line);
  background: linear-gradient(180deg, #ffffff 0%, var(--good-bg) 100%);
}

.kpi-card[data-tone="watch"] {
  border-color: var(--watch-line);
  background: linear-gradient(180deg, #ffffff 0%, var(--watch-bg) 100%);
}

.kpi-card[data-tone="risk"] {
  border-color: var(--risk-line);
  background: linear-gradient(180deg, #ffffff 0%, var(--risk-bg) 100%);
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.kpi-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.kpi-card em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.kpi-card[data-tone="good"] em {
  color: var(--good);
}

.kpi-card[data-tone="watch"] em {
  color: #71510f;
}

.kpi-card[data-tone="risk"] em {
  color: #7b2f24;
}

.simulation-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.saved-files-grid {
  margin-top: 16px;
}

.saved-list {
  display: grid;
  gap: 10px;
}

.saved-card {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfa;
  color: var(--ink);
  text-align: left;
}

.saved-card strong,
.saved-card span,
.saved-card small {
  display: block;
}

.saved-card span {
  color: var(--muted);
  font-size: 12px;
}

.saved-card small {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.control-group {
  display: inline-flex;
  gap: 0;
  min-height: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.control-group .compact-button {
  border: 0;
  border-radius: 0;
  min-width: 54px;
  background: transparent;
}

.compact-button.is-active {
  border-color: var(--accent);
  background: #e7f4ef;
  color: var(--accent);
}

.control-group .compact-button.is-active {
  background: var(--accent);
  color: white;
}

.play-button {
  min-width: 72px;
  border-color: var(--ink);
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.camera-bookmark-bar .compact-button {
  min-width: 86px;
}

.planning-view-shell {
  position: relative;
  min-height: 0;
  border-radius: 8px;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.38), transparent 26%),
    linear-gradient(145deg, #dfe6e1 0%, #ccd8d0 58%, #b8c8c1 100%);
}

#simCanvas {
  width: 100%;
  aspect-ratio: 1060 / 580;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ed;
}

.three-planning-view {
  display: none;
  width: 100%;
  aspect-ratio: 1060 / 580;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe6e1;
}

.three-planning-view.is-active {
  display: block;
}

.three-planning-view canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.three-planning-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(520px, calc(100% - 24px));
  border: 1px solid rgba(23, 32, 29, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(23, 32, 29, 0.08);
}

.production-story-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  display: none;
  width: min(420px, calc(100% - 24px));
  border: 1px solid rgba(23, 32, 29, 0.14);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 30px rgba(23, 32, 29, 0.1);
  pointer-events: none;
}

.three-planning-view.is-active + .production-story-overlay {
  display: grid;
  gap: 4px;
}

.production-story-overlay strong,
.production-story-overlay span,
.production-story-overlay small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.production-story-overlay strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.production-story-overlay span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.production-story-overlay small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

#timeline {
  width: 100%;
  margin-top: 12px;
}

.insight-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.9fr;
  gap: 12px;
  margin-top: 16px;
}

ul {
  margin: 0;
  padding-left: 18px;
}

li + li {
  margin-top: 8px;
}

.template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #f8faf7;
  color: var(--muted);
  font-size: 13px;
}

.product-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.product-grid > *,
.environment-builder > *,
.insight-grid > *,
.kpi-grid > * {
  min-width: 0;
}

.catalogue-panel {
  grid-column: 1 / -1;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin-bottom: 4px;
}

.section-heading p,
.panel-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.template-filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.template-filter {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.template-filter.is-active {
  border-color: var(--accent);
  background: #e7f4ef;
  color: var(--accent);
}

.ops-chat-panel {
  display: grid;
  gap: 12px;
}

.ops-chat-log {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.ops-chat-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f8faf7;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.ops-chat-message[data-role="user"] {
  background: #fff7f0;
  border-color: rgba(217, 120, 66, 0.32);
}

.ops-chat-message strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.ops-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.ops-chat-form input {
  min-width: 0;
}

.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.catalogue-card {
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.catalogue-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.catalogue-card-head strong {
  line-height: 1.2;
}

.catalogue-card-head span,
.signal-pill,
.readiness-list span {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef5ff;
  color: #164f83;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.catalogue-card p {
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.catalogue-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.catalogue-card dl div {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
}

.catalogue-card dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.catalogue-card dd {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

.comparison-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

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

.comparison-table th,
.comparison-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
}

.comparison-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.readiness-list {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.readiness-list li {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.readiness-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.readiness-list .is-ready span {
  background: #e7f4ef;
  color: var(--good);
}

.readiness-list strong,
.readiness-list small {
  display: block;
}

.readiness-list small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.calibration-panel textarea {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  background: #fbfcfa;
}

.calibration-file-label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.calibration-file-label input {
  width: 100%;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font: inherit;
}

.calibration-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.calibration-actions span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.inspector-stats {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.inspector-stats span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  color: var(--muted);
}

.inspector-stats strong {
  color: var(--ink);
}

.assumption-list {
  display: grid;
  gap: 9px;
  margin: 0;
}

.assumption-list div {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) 1fr;
  gap: 10px;
  align-items: baseline;
}

.assumption-list dt {
  color: var(--muted);
  font-size: 12px;
}

.assumption-list dd {
  margin: 0;
  font-weight: 700;
}

@media (max-width: 1000px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .kpi-grid,
  .insight-grid,
  .product-grid,
  .demo-journey-grid,
  .environment-builder {
    grid-template-columns: 1fr 1fr;
  }

  .catalogue-panel {
    grid-column: 1 / -1;
  }

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

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .topbar,
  .canvas-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls,
  .control-group {
    width: 100%;
  }

  .camera-bookmark-bar .compact-button {
    min-width: 0;
    flex: 1 1 0;
  }

  .production-story-overlay {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    margin-top: 8px;
  }

  .three-planning-view.is-active + .production-story-overlay {
    display: grid;
  }

  .kpi-grid,
  .insight-grid,
  .product-grid,
  .demo-journey-grid,
  .environment-builder,
  .catalogue-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .comparison-table {
    min-width: 520px;
  }

  .decision-trace-grid,
  .mine-planning-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-heading {
    flex-direction: column;
  }

  .template-filter-row {
    justify-content: flex-start;
  }
}
