/* Layout: a rules band across the top, then three columns: the product library, the load plan (options, 3D stage, containers) and the order table. Narrower, the library becomes a strip above the other two; on a phone everything is one column. */
:root {
  --bg: #edf0f4;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --ink: #15202b;
  --ink-2: #536171;
  --line: #d3dae2;
  --accent: #2c5f93;          /* the app's container steel */
  --accent-ink: #ffffff;
  --accent-soft: #e2ebf5;
  --good: #23764a;
  --good-soft: #dff1e6;
  --warn: #9a5b00;
  --warn-soft: #fbeed5;
  --bad: #b23a2e;
  --bad-soft: #f9e2df;
  --stage-top: #d9e2ec;
  --stage-bottom: #f3f5f8;
  --shadow: 0 1px 2px rgba(21, 32, 43, 0.06), 0 6px 20px rgba(21, 32, 43, 0.06);
  --display: "Barlow Semi Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: Inter, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d131a; --surface: #151d27; --surface-2: #1b2531; --ink: #e7ecf1; --ink-2: #98a6b5; --line: #2a3644;
    --accent: #72a9dd; --accent-ink: #0d131a; --accent-soft: #1d2d40;
    --good: #5fc28d; --good-soft: #173225; --warn: #e2a445; --warn-soft: #35280f; --bad: #f08273; --bad-soft: #3b1c18;
    --stage-top: #121a23; --stage-bottom: #1c2733;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d131a; --surface: #151d27; --surface-2: #1b2531; --ink: #e7ecf1; --ink-2: #98a6b5; --line: #2a3644;
  --accent: #72a9dd; --accent-ink: #0d131a; --accent-soft: #1d2d40;
  --good: #5fc28d; --good-soft: #173225; --warn: #e2a445; --warn-soft: #35280f; --bad: #f08273; --bad-soft: #3b1c18;
  --stage-top: #121a23; --stage-bottom: #1c2733;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
}
h2 { font: 600 19px/1.2 var(--display); letter-spacing: 0.01em; margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner {
  max-width: 1480px; margin: 0 auto;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font: 700 19px/1.05 var(--display); letter-spacing: 0.01em; }
.brand-sub { font: 500 12px/1.2 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.solid:hover { filter: brightness(1.08); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.wrap {
  max-width: 1480px; margin: 0 auto;
  padding-block: 16px 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 14px;
}

/* Rules band */
.rules {
  display: grid; grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(170px, 1fr));
  gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.rule { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; border-left: 1px solid var(--line); }
.rule:first-child { border-left: 0; }
.rule-label { font: 600 12px/1.2 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.rule-control { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.rule-control input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.rule-value { font: 600 22px/1 var(--display); font-variant-numeric: tabular-nums; min-width: 3.2ch; text-align: right; }
.rule-types { gap: 8px; }
.rule-types .link { align-self: flex-start; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-weight: 500; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.chip[aria-pressed="true"]::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.unit-field {
  display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.unit-field:focus-within { border-color: var(--accent); }
.unit-field input { width: 4.5ch; border: 0; background: none; text-align: right; font: 600 18px/1 var(--display); font-variant-numeric: tabular-nums; padding: 0; outline: none; -moz-appearance: textfield; }
.unit-field input::-webkit-outer-spin-button, .unit-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.unit-field .pre, .unit-field .post { color: var(--ink-2); font-weight: 500; }

/* Panels and grid */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.grid { display: grid; grid-template-columns: 252px minmax(0, 7fr) minmax(0, 5fr); gap: 14px; align-items: start; }

/* Product library */
.library { padding: 14px 0 10px; }
.lib-hint { padding: 0 14px 10px; }
.lib-list { display: flex; flex-direction: column; gap: 6px; padding: 0 8px; max-height: 780px; overflow-y: auto; }
.lib-item {
  display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 7px 6px 7px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
  cursor: grab; user-select: none; -webkit-user-select: none;
}
.lib-item:hover { border-color: var(--accent); }
.lib-item:active { cursor: grabbing; }
.lib-item.dragging { opacity: 0.45; }
.lib-box { display: block; width: 54px; height: 44px; }
.lib-box svg { display: block; width: 100%; height: 100%; }
.lib-box .edge { stroke: var(--ink); stroke-opacity: 0.4; stroke-width: 1; stroke-linejoin: round; }
.lib-name { display: block; font-weight: 600; font-size: 13.5px; line-height: 1.25; overflow-wrap: anywhere; }
.lib-size { display: block; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lib-in { display: block; font-size: 11.5px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.lib-actions { display: flex; flex-direction: column; gap: 3px; }
.lib-btn {
  width: 28px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 16px; line-height: 1; cursor: pointer; padding: 0;
}
.lib-btn:hover { border-color: var(--accent); }
.lib-btn.remove { height: 20px; font-size: 13px; color: var(--ink-2); border-color: transparent; background: none; }
.lib-btn.remove:hover { color: var(--bad); border-color: var(--bad); }
.lib-empty { padding: 6px 8px 10px; color: var(--ink-2); font-size: 13px; }

/* Where a dragged product can be dropped */
.stage-drop {
  display: none; position: absolute; inset: 6px; z-index: 4; pointer-events: none;
  border: 2px dashed var(--accent); border-radius: 8px; align-items: flex-end; justify-content: center; padding-bottom: 64px;
}
.stage-drop span { padding: 6px 12px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px; }
body.dragging-product .stage-drop { display: flex; }
body.dragging-product .stage.drop-over .stage-drop { background: var(--accent-soft); opacity: 0.9; }
body.dragging-product .order { outline: 2px dashed var(--accent); outline-offset: -2px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sheet-card .field.wide-field { max-width: none; }
.sheet-card .field input[type="email"], .sheet-card .field input[type="text"], .sheet-card .field select {
  width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; color: inherit;
}
.pay-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.sheet-note { font-size: 13.5px; padding: 9px 11px; border-radius: 8px; background: var(--accent-soft); }
.sheet-note.bad { background: var(--bad-soft); color: var(--bad); }
.account { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.account .who { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }
.team-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.team-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 11px; border-top: 1px solid var(--line); font-size: 13.5px; }
.team-row:first-child { border-top: 0; }
.team-row .email { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.team-row .role { color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.team-row .side { display: flex; align-items: center; gap: 10px; flex: none; }
.invite { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; align-items: end; }
.invite .btn { min-height: 38px; }
@media (max-width: 520px) { .invite { grid-template-columns: minmax(0, 1fr); } }
.sheet-card .field { grid-column: auto; max-width: 180px; }
.sheet-card .field input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: 600 18px/1 var(--display); font-variant-numeric: tabular-nums; }
.plan { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.order { padding: 14px 0 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px 10px; }
.hint { color: var(--ink-2); font-size: 13px; }
.order-hint { padding: 10px 14px 0; }
.scroll-x { overflow-x: auto; }

/* Options: one row of switches */
.options { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface-2); }
.option {
  flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 9px;
  padding: 7px 12px; border: 0; border-left: 1px solid var(--line); border-radius: 0;
  background: none; color: var(--ink); text-align: left; cursor: pointer;
}
.option:first-child { border-left: 0; }
.option:hover { background: var(--surface); }
.option[aria-pressed="true"] { background: var(--surface); box-shadow: inset 0 -3px 0 var(--accent); }
.option[disabled] { cursor: default; opacity: 0.55; }
.option[disabled]:hover { background: none; }
.option-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.option-name { font: 600 11.5px/1.2 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.option-count { font: 700 17px/1.1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.option-count small { font: 500 13px/1 var(--display); color: var(--ink-2); }
.state { flex: none; width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; line-height: 1; }
.state.good { background: var(--good-soft); color: var(--good); }
.state.bad { background: var(--bad-soft); color: var(--bad); }
.state.none { background: var(--line); color: var(--ink-2); }
.option-summary { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.option-summary:empty { display: none; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 999px; font: 600 11px/1.4 var(--display); letter-spacing: 0.08em; text-transform: uppercase; }
.tag.pick { background: var(--accent); color: var(--accent-ink); }
.pill { display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; margin-top: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.none { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); }
.advice { font-size: 14px; color: var(--ink); max-width: 75ch; }
.advice .link { margin-left: 6px; }
.advice.warn { color: var(--warn); }

/* Stage */
.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 320px; max-height: 620px;
  border-radius: 9px; overflow: hidden; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom));
}
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; }
.stage-canvas:active { cursor: grabbing; }
.stage-head { position: absolute; z-index: 2; inset: 10px 10px auto 12px; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; }
.stage-title { font: 600 16px/1.2 var(--display); letter-spacing: 0.02em; }
.stage-title small { display: block; font: 500 13px/1.3 var(--body); color: var(--ink-2); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.stage-tools { display: flex; gap: 6px; pointer-events: auto; }
.tool {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer;
}
.tool.wide { font-size: 12.5px; font-weight: 500; padding: 0 10px; }
.tool:hover { border-color: var(--accent); }
.tool[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.stage-foot {
  position: absolute; z-index: 2; inset: auto 10px 10px 10px;
  display: flex; align-items: center; gap: 10px; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  font-size: 13px; color: var(--ink-2);
}
.stage-foot label { white-space: nowrap; font-weight: 500; }
.stage-foot input { flex: 1; min-width: 0; accent-color: var(--accent); }
.stage-foot output { min-width: 13ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.stage-tip {
  position: absolute; z-index: 3; pointer-events: none; transform: translate(12px, 12px);
  padding: 6px 9px; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.35; white-space: nowrap;
}
.stage-tip b { font-weight: 600; }
.stage-empty { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; padding: 60px 24px; text-align: center; color: var(--ink-2); font-size: 15px; }
.stage-fallback { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--ink-2); }
.stage.no-webgl .stage-fallback { display: flex; }
.stage.no-webgl .stage-foot, .stage.no-webgl .stage-tools { display: none; }

/* Containers: a picture of each, then its figures in two lines */
.containers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.cont {
  text-align: left; cursor: pointer; min-width: 0;
  padding: 8px 11px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  display: flex; flex-direction: column; gap: 5px;
}
.cont:hover { border-color: var(--accent); }
.cont[aria-pressed="true"] { background: var(--surface); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cont-pic { display: block; aspect-ratio: 64 / 25; border-radius: 6px; overflow: hidden; background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom)); }
.cont-pic img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cont-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cont-name { font: 700 14px/1.2 var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
.cont-fill { font: 700 19px/1 var(--display); font-variant-numeric: tabular-nums; }
.cont-fill.bad { color: var(--bad); }
.cont-fill.good { color: var(--good); }
.bar { position: relative; height: 3px; border-radius: 2px; background: var(--line); }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: var(--good); }
.bar-fill.bad { background: var(--bad); }
.bar-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); border-radius: 1px; }
.cont-facts { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mix { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.mix span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { font: 600 11.5px/1.2 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.left { text-align: left; }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 14px; }
.table th:last-child, .table td:last-child { padding-right: 14px; }
.order-table { min-width: 0; }
.order-table th, .order-table td { padding-left: 6px; padding-right: 6px; }
.order-table tbody tr.row { cursor: pointer; }
.order-table tbody tr.row:hover td { background: var(--surface-2); }
.order-table tbody tr.row.open td { background: var(--accent-soft); border-bottom-color: transparent; }
.order-table tbody tr.row.lit td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.prod { display: flex; align-items: center; gap: 9px; text-align: left; min-width: 0; border: 0; background: none; padding: 0; cursor: pointer; width: 100%; }
.prod .dot { width: 14px; height: 14px; border-radius: 4px; }
.prod-name { font-weight: 600; display: block; overflow-wrap: anywhere; }
.prod-size { display: block; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.cell-input {
  width: 6ch; height: 32px; padding: 0 7px; text-align: right;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.cell-input::-webkit-outer-spin-button, .cell-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cell-input.narrow { width: 4.2ch; }
.cell-input:disabled { opacity: 0.45; }
.cell-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.lock {
  width: 34px; height: 32px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2);
}
.lock svg { width: 16px; height: 16px; }
.lock[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.planned { font-weight: 600; white-space: nowrap; }
.planned small.change { display: block; font-size: 11.5px; font-weight: 600; }
.change { white-space: nowrap; }
.change.up { color: var(--good); font-weight: 600; }
.change.down { color: var(--bad); font-weight: 600; }
.change small { display: block; font-size: 11.5px; font-weight: 500; }
.order-table tfoot td { border-bottom: 0; font-weight: 600; padding-top: 10px; }
.order-table tfoot td:first-child { text-align: left; color: var(--ink-2); font-weight: 500; }

/* The opened product */
.detail td { background: var(--accent-soft); padding: 4px 14px 14px; text-align: left; }
.detail-inner { display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.carton-stage { position: relative; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom)); min-width: 0; }
.carton-stage.no-webgl::after { content: "No 3D view in this browser"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; color: var(--ink-2); font-size: 12.5px; }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px 10px; align-content: start; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 3px; grid-column: span 2; min-width: 0; }
.field.wide { grid-column: span 4; }
.field.full { grid-column: 1 / -1; }
.field label { font: 600 11px/1.2 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.field input[type="text"], .field input[type="number"] {
  width: 100%; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-variant-numeric: tabular-nums;
}
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.detail-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }

/* Container types editor */
.types-editor { padding: 12px 0; }
.types-table { min-width: 720px; }
.types-table td { padding: 5px 8px; }
.types-table td.left { text-align: left; }
.types-table input[type="text"] { width: 100%; min-width: 150px; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.types-table input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.types-table .cell-input { width: 9ch; }
.types-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 14px 0; }

.foot { color: var(--ink-2); font-size: 12.5px; max-width: 95ch; }

.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  max-width: min(92vw, 560px); padding: 10px 16px; border-radius: 9px;
  background: var(--ink); color: var(--bg); font-weight: 500; box-shadow: var(--shadow); text-align: center;
}
.sheet { position: fixed; z-index: 40; inset: 0; background: rgba(8, 12, 18, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet-card { width: min(100%, 560px); background: var(--surface); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.sheet-card textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 10px; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.sheet-card .btn { align-self: flex-end; }

@media (max-width: 1439px) {
  .grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
  .library { grid-column: 1 / -1; }
  .lib-list { flex-direction: row; max-height: none; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; }
  .lib-item { flex: none; width: 236px; }
}
@media (max-width: 1080px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .library { grid-column: auto; }
  .rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-types { grid-column: 1 / -1; border-bottom: 1px solid var(--line); }
  .rule:nth-child(2) { border-left: 0; }
  .rule:nth-child(4) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); flex-direction: row; align-items: center; justify-content: space-between; }
}
@media (max-width: 640px) {
  .option { padding: 7px 8px; column-gap: 6px; }
  .option .tag { display: none; }
  .stage { aspect-ratio: 4 / 3.4; min-height: 300px; }
  .stage-tools .wide { display: none; }
  .stage-foot output { min-width: 0; }
  .detail-inner { grid-template-columns: minmax(0, 1fr); }
  .carton-stage { aspect-ratio: 16 / 10; }
  .fields { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .top-actions .btn { min-height: 34px; padding: 0 11px; font-size: 13px; }
  .plan { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
