/* ── Sheetfed Calculator — VOOM Sidebar Pattern ─────── */
/* Scoped: only apply full-height lock when calculator page is active */
body.sheetfed-calc-page {
  height: 100vh; overflow: hidden; margin: 0;
  display: flex; flex-direction: column;
}
body.sheetfed-calc-page .voom-nav { flex-shrink: 0; }

:root {
  --forest:      #1c3010;
  --forest-mid:  #2a6a1a;
  --forest-light:#e8f0e4;
  --border:      #d0dcc8;
  --border-light:#e8eee4;
  --text:        #1a2a1a;
  --text-mid:    #4a6a4a;
  --text-muted:  #7a8a7a;
  --bg:          #f2f4f0;
  --white:       #ffffff;
  --machine-red: #8b1a1a;
  --error:       #dc2626;
  --error-bg:    #fef2f2;
  --success:     #16a34a;
  --highlight:   #fefce8;
  --teal:        #0d9488;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════════ */
/* Flex child under body — fills remaining height after VOOM nav */
.calc-page { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }

.calc-header {
  background: var(--forest);
  color: #fff;
  padding: .5rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.calc-header h1 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.calc-header a { color: #a0d090; text-decoration: none; font-size: .8rem; }
.calc-header a:hover { color: #fff; }

.calc-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
.calc-sidebar {
  width: 480px;
  flex-shrink: 0;
  min-height: 0;
  background: var(--white);
  border-right: 2px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) #f0f2f0;
}

.sidebar-scroll {
  padding: .75rem .85rem 6rem;
}

/* Product name/code section */
.product-header {
  background: var(--forest-light);
  border-radius: 8px;
  padding: .6rem .85rem;
  margin-bottom: .75rem;
  border: 1px solid var(--border);
}
.product-header .field-row {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
}
.product-header .field-row .field { flex: 1; margin-bottom: 0; }

/* ── Stage cards ── */
.process-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .5rem;
  background: var(--white);
  transition: border-color .15s;
}
.process-card:hover { border-color: var(--forest-mid); }
.process-card.sortable-ghost {
  opacity: .4;
  border: 2px dashed var(--forest-mid);
}
.process-card.sortable-drag {
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.process-summary {
  list-style: none;
  padding: .5rem .75rem;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: var(--text);
  user-select: none;
}
.process-summary::-webkit-details-marker { display: none; }
.process-summary::before {
  content: '\25B8';
  font-size: .7rem;
  color: var(--text-muted);
  transition: transform .15s;
  flex-shrink: 0;
}
details[open] > .process-summary::before { transform: rotate(90deg); }

.process-number {
  background: var(--forest);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* Stage has at least one error from the calc validation phase */
.process-card.has-error > .process-summary > .process-number {
  background: #dc2626;
}
.process-card.has-error > .process-summary {
  background: #fef2f2;
  border-color: #fca5a5;
}
/* Stage has only warnings — amber, not red */
.process-card.has-warning > .process-summary > .process-number {
  background: #d97706;
}
.process-summary-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.process-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: .9rem;
  padding: 0 .25rem;
  flex-shrink: 0;
}
.process-drag-handle:active { cursor: grabbing; }

.process-body {
  padding: .4rem .65rem .6rem;
  border-top: 1px solid var(--border-light);
}

/* ── Fields ── */
.field { margin-bottom: .35rem; }

.field-label {
  display: block;
  font-size: .68rem;
  font-weight: 600;
  color: #2a4a2a;
  margin-bottom: .1rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.field-row {
  display: flex;
  gap: .5rem;
}
.field-row .field { flex: 1; }

.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  padding: .25rem .4rem;
  font-size: .78rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  color: var(--text);
}
.field input[type="number"]:focus,
.field input[type="text"]:focus,
.field select:focus {
  outline: none;
  border-color: var(--forest-mid);
  box-shadow: 0 0 0 2px rgba(42,106,26,.15);
}
.field input[type="number"] { text-align: right; }

.field-sep {
  border: none;
  border-top: 1px dashed var(--border);
  margin: .35rem 0;
}

/* Paper section */
.paper-section {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: .5rem;
  margin-top: .25rem;
  background: #fafcf8;
}

/* Tasks section */
.task-panel {
  margin-top: .25rem;
}
.task-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .2rem .4rem;
  background: var(--forest-light);
  border-radius: 4px;
  margin-bottom: .25rem;
  font-size: .78rem;
}
.task-item a { color: var(--forest-mid); text-decoration: none; font-weight: 500; }
.task-item a:hover { text-decoration: underline; }
.task-item .task-code { color: var(--text-muted); font-size: .7rem; }
.task-item .remove-task-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: .7rem;
  padding: .1rem .3rem;
  border-radius: 3px;
}
.task-item .remove-task-btn:hover { background: var(--error-bg); }

/* Side selects inline */
.sides-row {
  display: flex;
  gap: .5rem;
}
.sides-row .field { flex: 1; }

/* Dimensions inline */
.dim-row {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
}
.dim-row .field { flex: 1; }

/* ── Imposition tabs ── */
.impo-tabs {
  margin-top: .25rem;
}
.impo-tab-bar {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}
.impo-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: .3rem .65rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.impo-tab:hover { color: var(--text); }
.impo-tab.active {
  color: var(--forest);
  border-bottom-color: var(--forest);
}
.impo-match-badge {
  margin-left: auto;
  background: #dcfce7;
  color: #166534;
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .1rem .4rem;
  border-radius: 3px;
}
.impo-tab-panel { display: none; }
.impo-tab-panel.active { display: block; }

/* Auto panel — fields | SVG | fields */
.impo-panel-auto {
  padding-top: .35rem;
}
.impo-auto-layout {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.impo-col-left,
.impo-col-right {
  display: none; /* hidden — fields moved to .impo-controls-row below SVG */
}
.impo-col-svg {
  flex: 1 1 auto;
  min-width: 100px;
}
/* Horizontal controls row below the SVG */
.impo-controls-row {
  display: flex;
  gap: .5rem;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
}
.impo-mini-field {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.impo-mini-field label {
  font-size: .55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1;
  margin-bottom: 2px;
}
.impo-mini-field input[type="number"] {
  width: 42px;
  padding: .2rem .15rem;
  font-size: .75rem;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  -moz-appearance: textfield;
}
.impo-mini-field.gutter label { color: #b45309; }
.impo-mini-field.gutter input { border-color: #fbbf24; background: #fffbeb; }
.impo-mini-field.margin-x label { color: #e11d48; }
.impo-mini-field.margin-x input { border-color: #fda4af; background: #fff1f2; }
.impo-mini-field.margin-y label { color: #2563eb; }
.impo-mini-field.margin-y input { border-color: #93c5fd; background: #eff6ff; }
.impo-mini-field input[type="number"]::-webkit-inner-spin-button,
.impo-mini-field input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.impo-mini-field input[type="number"]:focus {
  outline: none;
  border-color: var(--forest-mid);
}
.impo-mini-field input[readonly] {
  background: var(--forest-light);
  color: var(--text-mid);
  cursor: default;
  border-color: var(--border-light);
}
.impo-selected-layout {
  margin-top: .35rem;
}
.impo-apply-btn {
  display: block;
  width: 100%;
  margin-top: .3rem;
  padding: .25rem;
  background: var(--forest);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: .68rem;
  font-weight: 600;
  cursor: pointer;
}
.impo-apply-btn:hover { background: var(--forest-mid); }
.impo-apply-btn.applied {
  background: var(--success);
  cursor: default;
}

/* Auto name input (editable badge) */
.impo-auto-name {
  display: block;
  width: 100%;
  padding: .3rem .5rem;
  margin-bottom: .35rem;
  font-size: .78rem;
  font-weight: 600;
  color: #6b5a00;
  background: var(--highlight);
  border: 1px solid #e5d88a;
  border-radius: 5px;
  text-align: center;
}
.impo-auto-name:focus {
  outline: none;
  border-color: #c4a800;
  box-shadow: 0 0 0 2px rgba(196,168,0,.15);
}
.impo-auto-name::placeholder {
  color: #b8a860;
  font-weight: 400;
}

/* Selected header: select + edit link */
.impo-sel-header {
  display: flex;
  gap: .35rem;
  align-items: center;
  margin-top: .35rem;
}
.impo-sel-header .select2-container { flex: 1; }
.impo-edit-link {
  flex: 0 0 auto;
  font-size: .68rem;
  font-weight: 600;
  color: var(--forest-mid);
  text-decoration: none;
  padding: .2rem .4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
}
.impo-edit-link:hover {
  background: var(--forest-light);
  text-decoration: none;
}

/* Auto-imposition badge (legacy/fallback) */
.auto-imposition-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--highlight);
  border: 1px solid #e5d88a;
  border-radius: 4px;
  padding: .15rem .5rem;
  font-size: .72rem;
  font-weight: 600;
  color: #6b5a00;
}

/* Imposition SVG diagram */
.imposition-svg {
  margin-top: .35rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem;
}
.impo-svg {
  width: 100%;
  height: auto;
  max-height: 180px;
}

/* Process action buttons (duplicate + remove) */
.process-actions {
  display: flex;
  gap: .4rem;
  margin-top: .5rem;
}
.process-duplicate-btn,
.process-collapse-btn,
.process-remove-btn {
  flex: 1;
  padding: .3rem;
  border-radius: 4px;
  font-size: .72rem;
  cursor: pointer;
  text-align: center;
  background: none;
}
.process-duplicate-btn {
  border: 1px solid var(--forest-mid);
  color: var(--forest-mid);
}
.process-duplicate-btn:hover { background: var(--forest-light); }
.process-collapse-btn {
  border: 1px solid #94a3b8;
  color: #475569;
}
.process-collapse-btn:hover { background: #f1f5f9; }
.process-remove-btn {
  border: 1px solid var(--error);
  color: var(--error);
}
.process-remove-btn:hover { background: var(--error-bg); }

/* Add process button */
.add-process-btn {
  display: block;
  width: 100%;
  padding: .5rem;
  margin-top: .25rem;
  background: var(--forest-light);
  border: 1px dashed var(--forest-mid);
  border-radius: 8px;
  color: var(--forest-mid);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.add-process-btn:hover { background: #d8e8d0; }

/* Action buttons row */
.sidebar-actions {
  padding: .75rem 1rem;
  background: var(--white);
  border-top: 2px solid var(--border);
  display: flex;
  gap: .5rem;
  position: sticky;
  bottom: 0;
}
.sidebar-actions .btn {
  flex: 1;
  padding: .4rem .75rem;
  border: none;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-calculate {
  background: var(--forest);
  color: #fff;
}
.btn-calculate:hover { background: var(--forest-mid); }
.btn-save {
  background: var(--teal);
  color: #fff;
}
.btn-save:hover { opacity: .9; }
.btn-save-new {
  background: var(--forest-light);
  color: var(--forest);
  border: 1px solid var(--border) !important;
}
.btn-save-new:hover { background: #d8e8d0; }

/* ══════════════════════════════════════════════════════════
   RESULTS PANE
══════════════════════════════════════════════════════════ */
.calc-results-wrap {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
}
.product-code-bar {
  background: var(--forest);
  color: #fff;
  padding: .45rem 1rem;
  border-radius: 6px;
  margin-bottom: .75rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-align: center;
  flex-shrink: 0;
}
.product-name-code {
  display: flex;
  gap: .75rem;
  margin-bottom: .75rem;
  padding-bottom: .75rem;
  border-bottom: 1.5px solid var(--border-light);
  flex-shrink: 0;
}
.product-name-code .field-label {
  font-size: .62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .2rem;
}
.calc-results {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* ══════════════════════════════════════════════════════════
   SNAKE WORKFLOW LAYOUT
══════════════════════════════════════════════════════════ */
.wf-snake {
  margin-bottom: .75rem;
}

.snake-row {
  display: flex;
  align-items: stretch;
}
.snake-row--rtl { flex-direction: row-reverse; }

/* ── Nodes ── */
.snake-node {
  flex: 0 0 auto;
  padding: .5rem .65rem;
  border-radius: 8px;
  background: var(--white);
  border: 1.5px solid var(--border);
  max-width: 240px;
}
.snake-node--machine {
  border-color: var(--forest-mid);
  border-left: 4px solid var(--forest);
  min-width: 160px;
}
.snake-node--task {
  border-color: #d4b896;
  border-left: 4px solid #b8860b;
  background: #fefcf5;
}
.snake-node--finished {
  border-color: var(--success);
  border-left: 4px solid var(--success);
  background: #ecfdf5;
}
/* Flip accent border on RTL rows */
.snake-row--rtl .snake-node--machine { border-left-width: 1.5px; border-right: 4px solid var(--forest); }
.snake-row--rtl .snake-node--task    { border-left-width: 1.5px; border-right: 4px solid #b8860b; }
.snake-row--rtl .snake-node--finished { border-left-width: 1.5px; border-right: 4px solid var(--success); }

.snake-node-head {
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-bottom: .1rem;
}

/* ── Horizontal connectors ── */
.snake-conn {
  flex: 0 0 28px;
  display: flex;
  align-items: center;
}
.snake-conn-line {
  width: 100%;
  height: 2px;
  background: #b0bca8;
  position: relative;
}
.snake-conn-line::after {
  content: '';
  position: absolute;
  right: 0; top: -3px;
  border-left: 5px solid #b0bca8;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}
.snake-row--rtl .snake-conn-line::after {
  right: auto; left: 0;
  border-left: none;
  border-right: 5px solid #b0bca8;
}

/* ── Turn connector (between rows) ── */
.snake-turn {
  display: flex;
  padding: .25rem 0;
}
.snake-turn--right { justify-content: flex-end; padding-right: 30px; }
.snake-turn--left  { justify-content: flex-start; padding-left: 30px; }
.snake-turn-line {
  width: 2px;
  height: 24px;
  background: var(--forest-mid);
  position: relative;
}
.snake-turn-line::after {
  content: '';
  position: absolute;
  bottom: 0; left: -3px;
  border-top: 5px solid var(--forest-mid);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

/* ── Section titles (rollfed style) ── */
.result-section-title {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-mid);
  margin: 1rem 0 .6rem;
  padding-bottom: .3rem;
  border-bottom: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.result-qty-label {
  font-weight: 400; text-transform: none;
  letter-spacing: 0; font-size: .85em;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════
   DEPENDENCY FLOW
══════════════════════════════════════════════════════════ */
/* ── Workflow Pipeline (step columns — matches labels calc) ── */
.workflow-pipeline {
  display: flex;
  gap: 0;
  align-items: stretch;
  margin-bottom: .75rem;
  overflow-x: auto;
  padding-bottom: .25rem;
}

.wf-step {
  flex: 1;
  min-width: 120px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.wf-step + .wf-step::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: var(--border);
}

.wf-step-head {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .5rem .25rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-mid);
  border-bottom: 2px solid var(--border);
}

.wf-step-seq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  font-size: .65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.wf-step--active .wf-step-head {
  color: var(--forest-mid);
  border-bottom-color: var(--forest-mid);
}
.wf-step--active .wf-step-seq {
  background: var(--forest-mid);
  color: #fff;
}

/* Task steps — amber accent */
.wf-step--task .wf-step-head {
  color: #92400e;
  border-bottom-color: #d97706;
}
.wf-step--task .wf-step-seq {
  background: #d97706;
  color: #fff;
}

/* Bottleneck / warning steps */
.wf-step--bottleneck .wf-step-head {
  color: #b85c00;
  border-bottom-color: #e8a040;
}
.wf-step--bottleneck .wf-step-seq {
  background: #e8a040;
  color: #fff;
}

.wf-step-body {
  padding: .4rem .5rem .5rem;
  font-size: .75rem;
  line-height: 1.45;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.wf-time {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
}

.wf-meta {
  font-size: .68rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.wf-cost {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  margin-top: auto;
  padding-top: .3rem;
}

/* ── Validation alerts ── */
.wf-alerts {
  margin-bottom: .75rem;
}
.wf-alert {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .4rem .65rem;
  border-radius: 6px;
  font-size: .78rem;
  line-height: 1.4;
  margin-bottom: .35rem;
}
.wf-alert--error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}
.wf-alert--warning {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
}
.wf-alert--info {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e40af;
}
.wf-alert-badge {
  flex-shrink: 0;
  font-size: .55rem;
  font-weight: 700;
  padding: .1rem .35rem;
  border-radius: 3px;
  letter-spacing: .04em;
  margin-top: .1rem;
}
.wf-alert--error .wf-alert-badge { background: #dc2626; color: #fff; }
.wf-alert--warning .wf-alert-badge { background: #f59e0b; color: #fff; }
.wf-alert--info .wf-alert-badge { background: #3b82f6; color: #fff; }

.wf-alert-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: .6rem;
  font-weight: 800;
  margin-left: .2rem;
  vertical-align: middle;
}
.wf-alert-error { background: #dc2626; color: #fff; }
.wf-alert-warn { background: #f59e0b; color: #fff; }

/* Warning text inside nodes */
.wf-node-warn {
  font-size: .6rem;
  line-height: 1.3;
  margin-top: .2rem;
  padding: .15rem .3rem;
  border-radius: 3px;
}
.wf-node-warn--error { background: #fecaca; color: #991b1b; }
.wf-node-warn--warning { background: #fef3c7; color: #92400e; }
.wf-node-warn--info { background: #dbeafe; color: #1e40af; }

/* Fix buttons in alerts */
.wf-fix-btn {
  flex-shrink: 0;
  padding: .2rem .5rem;
  font-size: .68rem;
  font-weight: 600;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  background: rgba(255,255,255,.7);
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
}
.wf-fix-btn:hover { background: rgba(255,255,255,.95); }
.wf-alert-msg { flex: 1; }

/* ══════════════════════════════════════════════════════════
   QTY SELECTOR + TOTALS + COST TABLE + PRICING
══════════════════════════════════════════════════════════ */
.wf-section-label {
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--forest-mid);
  margin: .75rem 0 .4rem;
}

/* Qty selector tabs */
.wf-qty-selector {
  display: flex;
  gap: .2rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}
.wf-qty-btn {
  padding: .2rem .55rem;
  font-size: .72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  color: var(--text-mid);
  cursor: pointer;
}
.wf-qty-btn:hover { background: var(--forest-light); }
.wf-qty-btn.active {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}

/* ── Workflow totals (chip row) ── */
.workflow-totals { margin-bottom: .75rem; }
.wf-totals-row { display: none; flex-wrap: wrap; gap: .4rem; }
.wf-totals-row.active { display: flex; }
.wf-total-chip {
  display: flex; align-items: center; gap: .3rem;
  padding: .3rem .6rem; background: var(--forest-light);
  border: 1px solid var(--border); border-radius: 5px;
  font-size: .72rem; color: var(--text);
}
.wf-total-chip strong { font-size: .78rem; color: var(--forest-mid); }
.wf-chip-total { background: #f0fdf4; border-color: #a7f3d0; }
.wf-chip-total strong { color: #14532d; }
.wf-chip-top strong { color: #1e3a5f; }

/* ── Cost detail table (rollfed style) ── */
.cost-detail-table {
  display: none; width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: .83rem;
}
.cost-detail-table.active { display: table; }
.cost-detail-table thead th {
  background: #edf2ea;
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mid); padding: .45rem .7rem;
  border-bottom: 2px solid var(--border); text-align: left;
}
.cost-detail-table thead th.num { text-align: right; }
.cost-detail-table tbody td {
  padding: .4rem .7rem;
  border-bottom: 1px solid var(--border-light);
  font-variant-numeric: tabular-nums;
}
.cost-detail-table tbody tr:last-child td { border-bottom: none; }
.cost-detail-table tbody tr:nth-child(even) td { background: #fafbf8; }
.cost-detail-table .cd-calc {
  color: var(--text-muted); font-size: .75rem;
  font-family: 'SF Mono', 'Fira Mono', monospace;
}
.cost-detail-table td.num { text-align: right; }
.cost-detail-table tfoot .cd-total td {
  padding: .5rem .7rem; background: var(--forest-light);
  border-top: 2px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.cost-detail-table tfoot .cd-total td.num { text-align: right; }

/* Help tooltips */
.cd-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--border-light); color: var(--text-muted);
  font-size: .55rem; font-weight: 700; cursor: help;
  vertical-align: middle; margin-left: .25rem;
  position: relative;
}
.cd-help:hover { background: var(--forest-light); color: var(--forest); }
.cd-help[title]:hover::after {
  content: attr(title);
  position: absolute; left: 100%; top: -4px; margin-left: 6px;
  padding: .4rem .6rem; background: var(--forest);
  color: #fff; font-size: .68rem; font-weight: 400;
  border-radius: 6px; white-space: normal; width: 220px;
  line-height: 1.4; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* Task rows in cost table */
.rcb-task-row td { background: #fefcf5 !important; }
.rcb-task-row td:first-child { color: #92640a; font-weight: 500; }

/* ── Price table (rollfed style) ── */
.price-table {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: .84rem;
  border: 1.5px solid var(--border); border-radius: 10px;
  overflow: hidden; margin-bottom: 1rem;
}
.price-table thead { background: #edf2ea; }
.price-table th {
  font-size: .67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mid); padding: .55rem .7rem;
  text-align: left; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.price-table th.num, .price-table td.num { text-align: right; }
.price-table td {
  padding: .45rem .7rem;
  border-bottom: 1px solid var(--border-light);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.price-table tr:last-child td { border-bottom: none; }
.price-table tbody tr:nth-child(even) td { background: #fafbf8; }
.price-table tbody tr:hover td { background: #f0f5ee; }
.price-table th.total, .price-table td.total {
  color: #14532d; font-weight: 700; background: #f0fdf4;
}
.price-table tr:hover td.total { background: #dcfce7 !important; }
.price-table th.total-top, .price-table td.total-top { color: #1e3a5f; }
.price-table th.profit-top, .price-table td.profit-top { color: #1e3a5f; }

/* ── Copy rows (pricing strings) ── */
.copy-row {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: .55rem;
}
.copy-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-mid);
  min-width: 60px; flex-shrink: 0;
}
.copy-box { display: flex; gap: .4rem; flex: 1; }
.copy-box input {
  flex: 1; font-family: 'SF Mono','Fira Mono',monospace; font-size: .75rem;
  padding: .38rem .6rem;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: #f8fbf6; color: var(--text);
}
.copy-btn {
  flex-shrink: 0; padding: .38rem .7rem;
  background: var(--forest-light); border: 1.5px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: .77rem; font-weight: 600;
  color: var(--text-mid); transition: background .12s, color .12s;
}
.copy-btn:hover { background: #d0e8c0; color: var(--forest); }
.copy-btn.copied { background: #dcfce7; color: var(--success); border-color: #bbf7d0; }

/* ── Description boxes ── */
.desc-box { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .75rem; }
.desc-box textarea {
  flex: 1;
  font-family: 'SF Mono','Fira Mono',monospace;
  font-size: .8rem; line-height: 1.6;
  padding: .6rem .75rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: #f8fbf6; color: #1a3a1a;
  resize: vertical; min-height: 100px;
}

/* (old card styles removed) */
/* (old styles cleaned up) */

/* Results placeholder */
.results-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60%;
  color: var(--text-muted);
  text-align: center;
}
.results-placeholder .icon {
  font-size: 3rem;
  margin-bottom: .5rem;
  opacity: .3;
}
.results-placeholder p {
  font-size: .9rem;
  margin: 0;
}

/* Spinner */
.calc-spinner {
  display: flex;
  justify-content: center;
  padding: 3rem;
}
.calc-spinner .spinner-border { color: var(--forest-mid); }

/* Flash messages */
.calc-flash {
  padding: .4rem .75rem;
  border-radius: 6px;
  font-size: .82rem;
  margin-bottom: .75rem;
}
.calc-flash.success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}
.calc-flash.error {
  background: var(--error-bg);
  border: 1px solid #fca5a5;
  color: var(--error);
}

/* ══════════════════════════════════════════════════════════
   SELECT2 OVERRIDES
══════════════════════════════════════════════════════════ */
.calc-sidebar .select2-container { width: 100% !important; }
.calc-sidebar .select2-container--bootstrap-5 .select2-selection--single {
  min-height: 30px;
  padding: .15rem .35rem;
  font-size: .78rem;
  border-color: var(--border);
  border-radius: 4px;
}
/* Truncate long selected text — prevent overflow over clear/arrow buttons */
.calc-sidebar .select2-selection__rendered {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 40px !important;
  display: block;
  font-size: .78rem;
}
/* Ensure Select2 in flex containers doesn't overflow */
.calc-sidebar .select2-container { min-width: 0 !important; overflow: hidden; }
.select2-container--bootstrap-5 .select2-dropdown { z-index: 100000; }
.select2-results__option { padding: 3px 6px; font-size: .78rem; user-select: none; }

/* ══════════════════════════════════════════════════════════
   DEBUG MODAL + WORKINGS (plain English calc detail)
══════════════════════════════════════════════════════════ */
.debug-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--border, #c8ccbe); background: var(--white, #fff);
  color: var(--text-muted, #888); font-size: .65rem; font-weight: 700;
  cursor: pointer; transition: background .12s, border-color .12s, color .12s;
  line-height: 1; padding: 0; flex-shrink: 0; vertical-align: middle; margin-left: .35rem;
}
.debug-btn:hover { background: var(--forest-light, #eef3e8); border-color: var(--forest-mid, #6b7c5a); color: var(--forest, #4a5533); }
.debug-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.debug-modal {
  background: var(--white, #fff); border-radius: 14px; width: 100%; max-width: 720px; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.06);
}
.debug-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.25rem; border-bottom: 1.5px solid var(--border-light, #e4e8dc); flex-shrink: 0;
}
.debug-modal-header strong { font-size: .9rem; color: var(--forest, #4a5533); }
.debug-modal-close {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border: none; background: none; font-size: 1.1rem; color: var(--text-muted, #888);
  cursor: pointer; border-radius: 6px; transition: background .12s, color .12s;
}
.debug-modal-close:hover { background: #f0f2ee; color: var(--text, #333); }
.debug-modal-body {
  overflow-y: auto; padding: 1rem 1.25rem 1.5rem;
  scrollbar-width: thin; font-size: .84rem; line-height: 1.65; color: var(--text, #333);
}
.w-section {
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
  color: var(--forest-mid, #6b7c5a); margin: 1.3rem 0 .5rem; padding-bottom: .3rem;
  border-bottom: 2px solid var(--border-light, #e4e8dc);
}
.w-section:first-child { margin-top: 0; }
.w-step { font-size: .8rem; font-weight: 600; color: var(--text-mid, #555); margin: .7rem 0 .25rem; }
.w-calc {
  background: #f8faf6; border: 1px solid var(--border-light, #e4e8dc);
  border-radius: 8px; padding: .55rem .8rem; margin-bottom: .4rem;
}
.w-line { padding: .12rem 0; font-size: .82rem; color: #3a4a3a; }
.w-line b { color: var(--forest, #4a5533); font-weight: 700; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
/* ── Field shortcut links ─────────────────────────── */
.field-shortcut {
  font-size: .6rem; font-weight: 600; color: var(--forest); text-decoration: none;
  text-transform: none; letter-spacing: 0;
}
.field-shortcut:hover { text-decoration: underline; }

@media (max-width: 1000px) {
  .calc-body { flex-direction: column; }
  .calc-sidebar { width: 100%; border-right: none; border-bottom: 2px solid var(--border); max-height: 50vh; }
  .calc-results { max-height: 50vh; }
}
