/* ── VOOM Control Centre — Labels ─────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; margin: 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;
}

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
══════════════════════════════════════════════════════════ */
.calc-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Two-pane body — flex row so each column can scroll independently */
.calc-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

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

.sidebar-scroll {
  padding: 1rem 1rem 0;
}

/* Qty + dimensions top section */
.sidebar-top {
  background: var(--forest-light);
  border-radius: 8px;
  padding: .7rem .85rem .85rem;
  margin-bottom: .5rem;
  border: 1px solid var(--border);
}
.sidebar-top .field-row { gap: .5rem; }

/* Section eyebrow label (inside sidebar-top) */
.section-eyebrow {
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--forest-mid);
  margin-bottom: .55rem;
}

/* Machine section headers */
.sidebar-machine-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: #2a6a1a;
  margin: .9rem 0 .4rem;
  padding-bottom: .35rem;
  border-bottom: 2px solid #b0d4a0;
}
.sidebar-machine-title::before {
  content: '';
  display: block;
  width: 3px; height: 14px;
  background: #3a9a2a;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Section spacing */
.sidebar-section { margin-bottom: .25rem; }

/* Thin horizontal rule within a section to separate sub-groups */
.field-sep {
  border: none;
  border-top: 1px dashed var(--border);
  margin: .6rem 0;
}

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

.field-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: #2a4a2a;
  margin-bottom: .2rem;
  line-height: 1.3;
}
.field-cost > .field-label::before,
.field-cost > .checkbox-label::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #3a9a2a;
  margin-right: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.field-cost > .field-label { color: #1e5a14; }

.field-setting > .field-label::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #cc7a18;
  margin-right: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.field-setting > .field-label { color: #7a4a10; }

/* Inline variable name tag — subtle, after label text */
.var-tag {
  display: block;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: .58rem;
  font-weight: 400;
  color: #aab0a4;
  letter-spacing: .01em;
  margin-top: .04rem;
}

/* Small hint text below labels */
.field-hint {
  display: inline;
  font-weight: 400;
  font-size: .72rem;
  color: #8a9a8a;
  margin-left: .35rem;
}

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

.form-input {
  width: 100%;
  padding: .42rem .65rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .87rem;
  background: var(--white);
  color: var(--text);
  transition: border-color .12s, background .12s, box-shadow .12s;
  -moz-appearance: textfield;
}
.form-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.form-input:focus {
  outline: none;
  border-color: var(--forest-mid);
  box-shadow: 0 0 0 3px rgba(42,106,26,.12);
}
.form-input.has-error { border-color: var(--error) !important; background: var(--error-bg) !important; box-shadow: 0 0 0 3px rgba(220,38,38,.1); }

/* Inline error message */
.field-error {
  display: block;
  font-size: .7rem;
  color: var(--error);
  margin-top: .2rem;
  font-weight: 500;
}

/* Advanced collapsible sections — shared */
.sidebar-advanced {
  border-radius: 8px;
  padding: .5rem .75rem;
  margin: .5rem 0;
}
.sidebar-advanced summary {
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.sidebar-advanced summary::before {
  content: '▶';
  font-size: .6rem;
  transition: transform .2s;
}
.sidebar-advanced[open] summary::before { transform: rotate(90deg); }
.sidebar-advanced summary::-webkit-details-marker { display: none; }

/* ── Green: Advanced Cost Options ── */
.sidebar-advanced-cost {
  border: 1.5px solid #b0d4a0;
  background: #f2f8ef;
}
.sidebar-advanced-cost summary {
  color: #2a6a1a;
}
.sidebar-advanced-cost summary::before {
  color: #4a9a3a;
}
.sidebar-advanced-cost .field-sep {
  border-top-color: #c0dab0;
}

/* ── Orange: Job Settings ── */
.sidebar-advanced-setting {
  border: 1.5px solid #e0c89a;
  background: #fdf6ec;
}
.sidebar-advanced-setting summary {
  color: #8a5a1a;
}
.sidebar-advanced-setting summary::before {
  color: #c08030;
}
.sidebar-advanced-setting .field-sep {
  border-top-color: #e0d0b0;
}

/* Sticky button footer */
.sidebar-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: .75rem 1rem;
  border-top: 2px solid var(--border-light);
  background: var(--white);
}
.sidebar-footer .field { margin-bottom: .5rem; }
.sidebar-footer .field-label { font-size: .75rem; }

.calc-btn {
  width: 100%;
  padding: .72rem;
  background: var(--forest-mid);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
  letter-spacing: .02em;
}
.calc-btn:hover  { background: var(--forest); }
.calc-btn:active { transform: translateY(1px); }
.calc-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════
   RESULTS PANEL
══════════════════════════════════════════════════════════ */
.calc-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* States */
.results-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 300px; color: var(--text-muted);
  text-align: center;
}
.results-placeholder p { font-size: .95rem; margin: 0; }
.results-placeholder-icon {
  font-size: 3rem; margin-bottom: .75rem; opacity: .3;
}

.results-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 200px; gap: .75rem;
  color: var(--text-muted); font-size: .9rem;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--forest-mid);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results-error {
  background: var(--error-bg);
  border: 2px solid #fca5a5;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  color: #991b1b;
  font-size: .88rem;
  line-height: 1.6;
  display: none;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Measurement boxes (small data chips in a row) ───── */
.result-measurements {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .5rem;
}
.meas-box {
  background: var(--white);
  border: 1.5px solid var(--border-light);
  border-radius: 7px;
  padding: .4rem .65rem;
  min-width: 90px;
}
.meas-label {
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: .1rem;
}
.meas-val {
  font-size: .9rem;
  font-weight: 700;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
}
.meas-warn {
  border-color: #e8a040;
  background: #fef6e8;
}
.meas-warn .meas-val {
  color: #b85c00;
}
.meas-hint {
  font-size: .6rem;
  color: #c06000;
  font-weight: 600;
  margin-top: .1rem;
}

/* ── Cost detail table ────────────────────────────────── */
.cost-detail-wrap { margin-bottom: .5rem; }
.cost-detail-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .83rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.cost-detail-table thead th {
  background: #edf2ea;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-mid);
  padding: .5rem .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: .78rem;
  font-family: 'SF Mono', 'Fira Mono', monospace;
}
.cost-detail-table td.num { text-align: right; }
.cost-detail-table tfoot .cd-total td {
  padding: .55rem .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; }

/* ── Cost-only table (compact, raw costs per tier) ────── */
.cost-only-table { margin-bottom: 1rem; }

/* ── Generate Final Prices button ─────────────────────── */
.generate-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;
  margin: 1.25rem 0 .5rem;
  padding: 1rem 1.1rem;
  background: var(--forest-light);
  border: 1.5px solid var(--border);
  border-radius: 10px;
}
.generate-note {
  margin: 0;
  font-size: .82rem;
  color: var(--text-mid);
}
.generate-btn {
  padding: .6rem 1.4rem;
  background: var(--forest-mid);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
  letter-spacing: .02em;
}
.generate-btn:hover  { background: var(--forest); }
.generate-btn:active { transform: translateY(1px); }

/* ── Populate button ──────────────────────────────────── */
.populate-btn {
  display: block;
  width: 100%;
  margin: .45rem 0 .15rem;
  padding: .38rem .65rem;
  background: var(--forest-light);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--forest-mid);
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s, border-color .12s;
}
.populate-btn:hover {
  background: #cde8b8;
  border-color: var(--forest-mid);
  color: var(--forest);
}

/* ── Populate result display ──────────────────────────── */
.populate-result {
  margin: .4rem 0 .5rem;
  border-radius: 6px;
  font-size: .72rem;
  line-height: 1.4;
  overflow: hidden;
}
.populate-placeholder {
  padding: .45rem .6rem;
  color: var(--muted);
  font-style: italic;
}
.populate-result.populate-ok {
  background: #edf7e4;
  border: 1px solid #b5d9a0;
}
.populate-result.populate-stale {
  background: #fff8e1;
  border: 1px solid #f0c040;
}
.populate-result.populate-stale .populate-placeholder,
.populate-result.populate-error .populate-placeholder {
  font-style: normal;
  font-weight: 500;
}
.populate-result.populate-error {
  background: #fff0f0;
  border: 1px solid #f0a0a0;
}
.populate-result.populate-error .populate-placeholder { color: #c00; }
.populate-result.populate-stale  .populate-placeholder { color: #7a5800; }

/* grid of 4 chips inside the ok result */
.pop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid #b5d9a0;
}
.pop-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .4rem .3rem;
  text-align: center;
  line-height: 1.25;
}
.pop-item + .pop-item { border-left: 1px solid #b5d9a0; }
.pop-item strong { font-size: .8rem; color: var(--forest); }
.pop-item small  { font-size: .62rem; color: var(--muted); margin-top: .1rem; }
.pop-detail {
  padding: .3rem .6rem;
  color: #3a6020;
  font-size: .67rem;
  font-family: 'SF Mono', 'Fira Mono', monospace;
}

/* Width pills — multi-width selector */
.pop-widths {
  display: flex; gap: .3rem; padding: .3rem .6rem; flex-wrap: wrap;
}
.width-pill {
  font-size: .62rem; padding: .15rem .45rem; border-radius: 6px;
  background: #e8eee4; color: #4a6a4a; border: 1px solid #c0d0b8;
}
.width-pill-active {
  background: var(--forest); color: #fff; border-color: var(--forest);
  font-weight: 600;
}

/* Job summary strip — calc code as main identifier */
.result-summary {
  background: var(--forest);
  color: #fff;
  border-radius: 10px;
  padding: .7rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.calc-code-badge {
  font-family: 'SF Mono', 'Fira Mono', 'Consolas', monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
  padding: .3rem .7rem;
  background: rgba(255,255,255,.12);
  border-radius: 6px;
}
.calc-code-status {
  font-size: .75rem;
  padding: .2rem .55rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.calc-code-status.saved {
  background: rgba(22,163,74,.25);
  color: #bbf7d0;
}
.calc-code-status.exists {
  background: rgba(234,179,8,.2);
  color: #fef08a;
}

/* Save toast notification */
.save-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  padding: .6rem 1rem;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  transform: translateX(120%);
  transition: transform .3s ease;
  max-width: 360px;
}
.save-toast.show { transform: translateX(0); }
.save-toast.toast-saved {
  background: #16a34a;
  color: #fff;
}
.save-toast.toast-exists {
  background: #ca8a04;
  color: #fff;
}
.save-toast.toast-updated {
  background: #2563eb;
  color: #fff;
}

.calc-code-meta {
  font-size: .7rem;
  opacity: .65;
}
.calc-overwrite-btn,
.calc-skip-btn {
  border: none;
  border-radius: 4px;
  padding: .2rem .55rem;
  font-size: .72rem;
  cursor: pointer;
  font-weight: 600;
}
.calc-overwrite-btn {
  background: rgba(255,255,255,.2);
  color: #fff;
}
.calc-overwrite-btn:hover { background: rgba(255,255,255,.35); }
.calc-skip-btn {
  background: transparent;
  color: rgba(255,255,255,.5);
  text-decoration: underline;
}
.calc-skip-btn:hover { color: rgba(255,255,255,.8); }

/* Section titles in results */
.result-section-title {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-mid);
  margin: 1.1rem 0 .65rem;
  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);
}

/* Cost breakdown tiles */
.result-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .5rem;
  margin-bottom: .25rem;
}
.breakdown-item {
  background: var(--white);
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  padding: .55rem .7rem;
  transition: border-color .12s;
}
.breakdown-item:hover { border-color: var(--border); }
.breakdown-item-label {
  font-size: .67rem;
  color: var(--text-muted);
  margin-bottom: .15rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.breakdown-item-val {
  font-size: .97rem;
  font-weight: 700;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
}

/* Price table */
.price-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .84rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.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; }

/* Highlighted row (ref qty) */
.price-table tr.highlighted td {
  background: var(--highlight) !important;
}
.price-table tr.highlighted td:first-child {
  border-left: 3px solid #ca8a04;
  padding-left: calc(.7rem - 3px);
}

/* Column colours */
.price-table th.total, .price-table td.total {
  color: #14532d;
  font-weight: 700;
  background: #f0fdf4;
}
.price-table tr:hover td.total,
.price-table tr.highlighted 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; }

.price-table th.total-ip,
.price-table td.total-ip { color: #5b21b6; }
.price-table th.profit-ip,
.price-table td.profit-ip { color: #5b21b6; }

/* Copy rows */
.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 */
.desc-box { display: flex; gap: .5rem; align-items: flex-start; }
.desc-box textarea {
  flex: 1;
  font-family: 'SF Mono','Fira Mono',monospace;
  font-size: .8rem; line-height: 1.6;
  padding: .65rem .8rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: #f8fbf6; color: #1a3a1a;
  resize: vertical;
  min-height: 140px;
}

/* ── Breakdown total tile ─────────────────────────────── */
.breakdown-total {
  background: var(--forest-light) !important;
  border-color: var(--border) !important;
}
.breakdown-total .breakdown-item-val { color: var(--forest); }

/* ── Breakdown % indicator ────────────────────────────── */
.breakdown-item-pct {
  font-size: .63rem; color: var(--text-muted);
  margin-top: .1rem;
}

/* ── Reference row tag ────────────────────────────────── */
.ref-tag {
  display: inline-block; margin-left: .35rem;
  font-size: .62rem; font-weight: 700;
  background: #ca8a04; color: #fff;
  padding: .05rem .3rem; border-radius: 3px;
  text-transform: uppercase; letter-spacing: .05em;
  vertical-align: middle;
}

/* ── Muted column ─────────────────────────────────────── */
.price-table td.muted { color: var(--text-muted); font-size: .8rem; }

/* ── KC / DC cut method badges ────────────────────────── */
.cut-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .06em;
  padding: .15rem .35rem;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.cut-badge-kc { background: #dbeafe; color: #1e40af; }   /* blue  — kiss cut */
.cut-badge-dc { background: #dcfce7; color: #14532d; }   /* green — die cut  */

/* ── Checkbox field ───────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  cursor: pointer;
}
.form-checkbox {
  width: 15px; height: 15px;
  accent-color: var(--forest-mid);
  flex-shrink: 0;
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════════
   DEBUG / ? BUTTON & MODAL
══════════════════════════════════════════════════════════ */
.debug-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-muted);
  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);
  border-color: var(--forest-mid);
  color: var(--forest);
}

/* Overlay */
.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;
}

/* Modal box */
.debug-modal {
  background: var(--white);
  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);
  flex-shrink: 0;
}
.debug-modal-header strong {
  font-size: .9rem;
  color: var(--forest);
}
.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);
  cursor: pointer; border-radius: 6px;
  transition: background .12s, color .12s;
}
.debug-modal-close:hover {
  background: #f0f2ee; color: var(--text);
}

/* Scrollable body */
.debug-modal-body {
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  font-size: .84rem;
  line-height: 1.65;
  color: var(--text);
}

/* Workings sections */
.w-section {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--forest-mid);
  margin: 1.3rem 0 .5rem;
  padding-bottom: .3rem;
  border-bottom: 2px solid var(--border-light);
}
.w-section:first-child { margin-top: 0; }

.w-step {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-mid);
  margin: .7rem 0 .25rem;
}

.w-calc {
  background: #f8faf6;
  border: 1px solid var(--border-light);
  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);
  font-weight: 700;
}

/* ── Batch Generate button ────────────────────────────── */
.batch-btn {
  width: 100%;
  padding: .6rem 1rem;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text-mid);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  margin-top: .4rem;
}
.batch-btn:hover {
  background: var(--forest-light);
  border-color: var(--forest-mid);
  color: var(--forest);
}
.batch-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.batch-btn--push {
  border-color: #9b7ad8;
  color: #6b4daa;
}
.batch-btn--push:hover {
  background: #f3eeff;
  border-color: #7b5cc0;
  color: #5a3d99;
}

/* ── Batch modal results ─────────────────────────────── */
.batch-summary {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: .5rem 0;
  font-size: .82rem;
}
.batch-stat {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 5px;
  font-weight: 600;
  font-size: .75rem;
}
.batch-stat:nth-child(1) { background: #dcfce7; color: #14532d; }
.batch-stat:nth-child(2) { background: #fef9c3; color: #854d0e; }
.batch-stat:nth-child(3) { background: #fee2e2; color: #991b1b; }

.batch-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 700;
  padding: .1rem .35rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.batch-new { background: #dcfce7; color: #14532d; }
.batch-upd { background: #dbeafe; color: #1e40af; }

.batch-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-mid);
  margin: .75rem 0 .3rem;
}
.batch-section-title.batch-error { color: #dc2626; }
.batch-skip-list {
  margin: 0; padding-left: 1.2rem;
  font-size: .78rem; color: var(--text-muted);
}
.batch-skip-list li { margin: .15rem 0; }
.batch-error { color: #dc2626; }

/* ── Island Print push ───────────────────────────────── */
.island-push-box {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.island-push-btn {
  padding: .55rem 1.2rem;
  border: 1.5px solid #5b21b6;
  border-radius: 8px;
  background: #5b21b6;
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, opacity .12s;
}
.island-push-btn:hover { background: #4c1d95; }
.island-push-btn:disabled { opacity: .6; cursor: not-allowed; }

.island-push-status {
  font-size: .78rem;
  font-weight: 500;
}
.push-ok    { color: var(--success); }
.push-error { color: var(--error); }

/* ── Workflow Map link ── */
.wf-map-link {
  float: right;
  font-size: .7rem;
  font-weight: 600;
  color: var(--forest-mid);
  text-decoration: none;
  padding: .15rem .45rem;
  border: 1px solid var(--forest-mid);
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
  transition: background .15s, color .15s;
}

.wf-map-link:hover {
  background: var(--forest-mid);
  color: #fff;
}

/* ── Workflow Pipeline ──────────────────────────────────── */
.workflow-pipeline {
  display: flex;
  gap: 0;
  align-items: stretch;
  margin-bottom: .75rem;
  overflow-x: auto;
  padding-bottom: .25rem;
}

.wf-step {
  flex: 1;
  min-width: 110px;
  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;
}

.wf-step--bottleneck .wf-step-head {
  color: #b85c00;
  border-bottom-color: #e8a040;
}

.wf-step--bottleneck .wf-step-seq {
  background: #e8a040;
  color: #fff;
}

.wf-step--inactive .wf-step-head {
  color: var(--text-muted);
  border-bottom-color: var(--border-light);
  opacity: .55;
}

.wf-step--inactive .wf-step-body {
  opacity: .4;
}

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

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

.wf-bar-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border-light);
  overflow: hidden;
  margin: .15rem 0;
}

.wf-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--forest-mid);
  transition: width .4s ease;
}

.wf-step--bottleneck .wf-bar-fill {
  background: #e8a040;
}

.wf-bar-split {
  display: flex;
  height: 100%;
}

.wf-bar-attentive {
  height: 100%;
  background: var(--forest-mid);
}

.wf-bar-background {
  height: 100%;
  background: #a0c890;
}

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

.wf-cost {
  margin-top: auto;
  font-weight: 600;
  color: var(--forest-mid);
  font-size: .72rem;
}

.wf-complexity {
  display: inline-block;
  font-size: .62rem;
  font-weight: 600;
  padding: .05rem .3rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.wf-comp-Low      { background: #e0f0d8; color: #3a7a2a; }
.wf-comp-Standard { background: #e8eee4; color: #4a6a4a; }
.wf-comp-High     { background: #fff0d8; color: #8a5a00; }
.wf-comp-Extreme  { background: #ffe0e0; color: #991b1b; }

/* Workflow totals */
.workflow-totals {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

.wf-total-chip {
  display: flex;
  align-items: center;
  gap: .35rem;
  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);
}

/* Workflow alerts */
.wf-alert {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .65rem;
  border-radius: 5px;
  font-size: .75rem;
  font-weight: 500;
  margin-bottom: .5rem;
}

.wf-alert--warning {
  background: #fff8e1;
  border: 1px solid #e8a040;
  color: #7a4a00;
}

.wf-alert--info {
  background: #e8f4fd;
  border: 1px solid #90c4e8;
  color: #1a5a8a;
}

.wf-alert-icon {
  font-size: .9rem;
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .calc-page    { height: auto; overflow: visible; }
  .calc-body    { flex-direction: column; overflow: visible; }
  .calc-sidebar { width: 100%; overflow-y: visible; border-right: none; border-bottom: 2px solid var(--border); }
  .sidebar-footer { position: static; }
  .calc-results { overflow: visible; min-height: unset; }
}
