/* Miz-Pack — Pallet Pattern Studio */
:root {
  color-scheme: light;
  --charcoal: #1c1f1c;
  --charcoal-2: #2a2e2a;
  --bg: #eef0ea;
  --panel: #ffffff;
  --panel-2: #f7f8f4;
  --ink: #16241c;
  --muted: #5d6c62;
  --faint: #8a968d;
  --line: #dde2d8;
  --line-strong: #c3ccc0;
  --forest: #1f5a3a;
  --forest-deep: #123b28;
  --forest-tint: #e7f0e6;
  --lime: #a9e83f;
  --lime-hover: #bdf05f;
  --amber: #a7600a;
  --amber-bg: #fff4dc;
  --red: #b3261e;
  --red-bg: #fde9e7;
  --blue: #2456a6;
  --ok: #1b7a43;
  --radius: 9px;
  --shadow: 0 1px 2px rgb(16 32 22 / .06), 0 4px 14px rgb(16 32 22 / .06);
  --top-h: 52px;
  --status-h: 30px;
  font: 13.5px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); display: flex; flex-direction: column; overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--forest); outline-offset: 1px; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.ico { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
[data-icon] { display: inline-flex; }

/* ---------- top bar ---------- */
.topbar { height: var(--top-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: #1d5a21 url(../img/header.jpg) repeat-x left center / auto 100%; color: #f2f4ee; box-shadow: inset 0 -1px 0 rgb(0 0 0 / .25); }
.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark { width: 32px; height: 32px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 15px; letter-spacing: -.01em; }
.brand-text span { font-size: 10.5px; color: #cfe2cc; letter-spacing: .04em; text-transform: uppercase; }
.topbar .project-name { height: auto; min-width: 0; width: clamp(9rem, 24vw, 24rem); margin-left: 8px; padding: 6px 9px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #fff; font-size: 14px; font-weight: 600; }
.topbar .project-name::placeholder { color: #b7cfb3; font-weight: 500; }
.topbar .project-name:hover { border-color: rgb(255 255 255 / .28); }
.topbar .project-name:focus { background: rgb(0 0 0 / .32); border-color: rgb(255 255 255 / .4); outline: none; }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); flex: none; margin-left: -4px; }
.topbar-spacer { flex: 1; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: rgb(0 0 0 / .3); border: 1px solid rgb(255 255 255 / .16); flex: none; }
.seg button { border: 0; background: transparent; color: #d6e4d3; padding: 5px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.seg button.active { background: #f2f4ee; color: var(--charcoal); }
.topbar-actions { display: flex; gap: 6px; flex: none; }
.tb { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid rgb(255 255 255 / .2); border-radius: 7px; background: rgb(0 0 0 / .24); color: #f2f6ee; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.tb:hover { background: rgb(0 0 0 / .38); border-color: rgb(255 255 255 / .34); }
.tb.primary { background: var(--lime); border-color: var(--lime); color: var(--forest-deep); }
.tb.primary:hover { background: var(--lime-hover); }

/* ---------- layout ---------- */
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 332px minmax(0, 1fr) 356px; }
.panel { min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* ---------- accordion ---------- */
.acc { border-bottom: 1px solid var(--line); }
.acc > summary { list-style: none; display: flex; align-items: center; gap: 9px; padding: 11px 14px; font-weight: 700; font-size: 13.5px; cursor: pointer; user-select: none; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: ''; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(-45deg); transition: transform .15s; }
.acc[open] > summary::after { transform: rotate(45deg); }
.acc > summary:hover { background: var(--panel-2); }
.acc-num { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--forest-tint); color: var(--forest); font-size: 11px; font-weight: 800; flex: none; }
.acc-tag { font-size: 10.5px; font-weight: 600; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; text-transform: uppercase; letter-spacing: .04em; }
.acc-hint { font-weight: 500; font-size: 12px; color: var(--muted); }
.acc-body { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.acc-body h4 { margin-top: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field.inline { flex-direction: row; align-items: center; gap: 6px; }
.field.inline > span { overflow: visible; flex: none; }
.inp { position: relative; display: flex; }
.inp i { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 11px; color: var(--faint); pointer-events: none; }
input[type=number], input[type=text], input[type=date], select, textarea {
  width: 100%; min-width: 0; height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink);
}
.inp input { padding-right: 26px; font-variant-numeric: tabular-nums; }
.inp input:not(:placeholder-shown) + i, .inp i { }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
textarea { height: auto; padding: 7px 8px; resize: vertical; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: #9fac9f; }
input:focus, select:focus, textarea:focus { border-color: var(--forest); outline: 2px solid rgb(31 90 58 / .18); outline-offset: 0; }
input.invalid { border-color: var(--red); background: var(--red-bg); }
input.unsure { border-color: var(--amber); background: var(--amber-bg); box-shadow: 0 0 0 1px var(--amber); }
input[type=color] { height: 32px; width: 100%; padding: 2px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; }
input[type=checkbox] { accent-color: var(--forest); width: 15px; height: 15px; margin: 0; flex: none; }
input[type=range] { accent-color: var(--forest); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.wide-gap { gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.help { font-size: 12px; color: var(--muted); line-height: 1.45; }
.help.center { text-align: center; }
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.chips.wrap { display: flex; flex-wrap: wrap; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font-weight: 650; font-size: 12.5px; line-height: 1.2; }
.chip small { font-weight: 500; font-size: 10.5px; color: var(--muted); }
.chip:hover { border-color: var(--forest); }
.chip.active { background: var(--forest); border-color: var(--forest); color: #fff; }
.chip.active small { color: #cfe3d4; }
.chip.has-art::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--lime); margin-top: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--forest-tint); border-color: var(--forest); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--forest); border-color: var(--forest); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--forest-deep); }
.btn.danger:hover:not(:disabled) { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn.small { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn.active { background: var(--forest); border-color: var(--forest); color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.btn-col { display: flex; flex-direction: column; gap: 6px; }
.btn-col .btn { width: 100%; }
.icon-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--ink); }
.icon-btn:hover:not(:disabled) { background: var(--forest-tint); border-color: var(--line-strong); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.on { background: var(--forest); color: #fff; }

.generate-box { padding: 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; gap: 8px; position: sticky; bottom: 0; z-index: 2; }
.cta { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border: 1px solid #8fc232; border-radius: 9px; background: var(--lime); color: var(--forest-deep); font-weight: 800; font-size: 14px; box-shadow: 0 1px 0 #7fae2b; }
.cta:hover:not(:disabled) { background: var(--lime-hover); }
.cta:disabled { background: #e3e7de; border-color: #cfd6ca; color: #7b877d; box-shadow: none; cursor: not-allowed; }
.cta.pulse { animation: pulse 1.6s ease-in-out 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgb(169 232 63 / .35); } }

.drop { width: 100%; padding: 14px 10px; border: 1.5px dashed #92a493; border-radius: 9px; background: var(--forest-tint); color: var(--forest-deep); font-weight: 600; font-size: 12.5px; }
.drop.over { background: #d4e8d4; border-color: var(--forest); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs:empty { display: none; }
.thumb { width: 76px; font-size: 11px; }
.thumb img { display: block; width: 76px; height: 56px; object-fit: contain; background: #eeece6; border-radius: 5px; border: 1px solid var(--line); }
.thumb div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.thumb button { width: 100%; height: 22px; margin-top: 2px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; font-size: 11px; }
.thumb button:hover { border-color: var(--red); color: var(--red); }
.strength-out { font-size: 12.5px; display: flex; flex-direction: column; gap: 8px; }
.strength-out .kv { margin-top: 2px; }
.strength-out .grp { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); grid-column: 1 / -1; margin-top: 6px; }
.strength-out .grp:first-child { margin-top: 0; }
.strength-out .big { font-size: 13.5px; color: var(--ink); }
.strength-verdict { padding: 9px 11px; border-radius: 9px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.strength-verdict.ok { background: var(--forest-tint); color: var(--forest-deep); }
.strength-verdict.error { background: #fdecea; color: var(--red); }
.strength-verdict small { display: block; font-weight: 500; }
.factor-list { display: flex; flex-direction: column; gap: 6px; }
.factor { display: grid; grid-template-columns: minmax(0, 1fr) 62px; gap: 6px; align-items: end; }
.factor .field > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.factor input { width: 100%; text-align: right; }
.factor-total { display: flex; justify-content: space-between; font-size: 12.5px; padding: 6px 2px 2px; border-top: 1px solid var(--line); }
.factor-total b { font-variant-numeric: tabular-nums; }
.inp input.auto::placeholder { color: var(--forest); opacity: .75; font-style: italic; }
.pop-cols { display: flex; flex-direction: column; gap: 10px; }
.pop-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pop-btn { margin-left: auto; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); padding: 0; }
.pop-btn:hover { border-color: var(--line-strong); background: #fff; color: var(--forest); }
.acc > summary .pop-btn + * { margin-left: 0; }
.acc:has(.pop-btn) > summary::after { margin-left: 6px; }
/* pop-out window */
.dlg.pop { width: calc(100vw - 3rem); height: calc(100dvh - 3rem); max-width: 1500px; padding: 0; display: none; flex-direction: column; overflow: hidden; }
.dlg.pop[open] { display: flex; }
.pop-body { flex: 1; min-height: 0; overflow: auto; padding: 14px 18px 18px; }
.pop-body > .acc-body { padding: 0; }
.pop-body.strength .pop-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; align-items: start; }
.pop-body.strength .pop-col > h4:first-child, .pop-body.strength .pop-col > p:first-child + h4 { margin-top: 0; border-top: 0; padding-top: 0; }
.pop-body.art { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; overflow: hidden; }
.pop-scroll { min-height: 0; overflow-y: auto; padding-right: 4px; }
.pop-scroll > .acc-body { display: block; columns: 2 300px; column-gap: 22px; padding: 0; }
.pop-scroll > .acc-body > * { break-inside: avoid; margin-bottom: 10px; }
.pop-scroll > .acc-body > h4 { break-after: avoid; }
.pop-stage { position: relative; min-height: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
@media (max-width: 1020px) {
  .pop-body.strength .pop-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pop-body.art { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .dlg.pop { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .pop-body.strength .pop-cols { grid-template-columns: minmax(0, 1fr); }
  .pop-scroll > .acc-body { columns: 1; }
}

/* ---------- stage ---------- */
.stage-tabs { flex: none; display: flex; align-items: center; gap: 2px; padding: 6px 10px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; background: var(--bg); border-bottom: 1px solid var(--line); }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; white-space: nowrap; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); font-weight: 650; position: relative; top: 1px; }
.tab:hover { color: var(--ink); background: rgb(255 255 255 / .55); }
.tab.active { background: #fbfcf9; border-color: var(--line); color: var(--forest-deep); }
.stage-tabs-spacer { flex: 1; }
.stale-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: var(--amber-bg); color: #6b3d00; border-bottom: 1px solid #ecd49b; font-size: 12.5px; font-weight: 600; }
.stale-bar .btn { margin-left: auto; }
.stage-body { flex: 1; min-height: 0; position: relative; background: #fbfcf9; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.view3d { container-type: inline-size; background: radial-gradient(120% 90% at 50% 20%, #ffffff 0%, #f4f6f0 55%, #e6eae0 100%); }
#gl { flex: 1; min-height: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#gl:active { cursor: grabbing; }
.gl-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.view-tools { position: absolute; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; z-index: 2; }
.view-tools.top-left { top: 10px; left: 10px; }
.view-tools.top-right { top: 10px; right: 10px; justify-content: flex-end; }
.view-tools.bottom-left { bottom: 10px; left: 10px; padding: 6px 10px; border-radius: 99px; background: rgb(255 255 255 / .92); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12px; font-weight: 600; color: var(--muted); }
.view-tools.bottom-left input { width: 130px; }
.view-tools.bottom-left output { min-width: 3.2em; color: var(--ink); font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 99px; background: rgb(255 255 255 / .92); font-size: 12px; font-weight: 600; color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .05); }
.pill:hover { border-color: var(--forest); }
.pill.active { background: var(--forest); border-color: var(--forest); color: #fff; }
.view-tools select { height: 28px; width: auto; border-radius: 99px; font-size: 12px; font-weight: 600; padding: 0 8px; background: rgb(255 255 255 / .92); border-color: var(--line); }
@container (max-width: 640px) {
  .view-tools.top-right { top: 44px; left: 10px; right: auto; justify-content: flex-start; }
}
.view-hint { position: absolute; right: 12px; bottom: 10px; font-size: 11.5px; color: var(--faint); pointer-events: none; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; background: inherit; z-index: 3; }
.empty h2 { font-size: 19px; letter-spacing: -.01em; }
.empty p { max-width: 30rem; color: var(--muted); font-size: 13.5px; }
.empty-art { color: #b9c4b6; margin-bottom: 6px; }
.empty-art svg { width: 120px; height: 96px; }

/* ---------- right panel ---------- */
.rtabs { flex: none; display: flex; border-bottom: 1px solid var(--line); }
.rtab { flex: 1; height: 40px; border: 0; border-bottom: 2px solid transparent; background: transparent; font-weight: 700; color: var(--muted); }
.rtab:hover { color: var(--ink); }
.rtab.active { color: var(--forest-deep); border-bottom-color: var(--forest); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; background: var(--forest-tint); color: var(--forest); font-size: 11px; line-height: 18px; }
.count:empty { display: none; }
.side-empty { padding: 26px 22px; color: var(--muted); text-align: center; display: flex; flex-direction: column; gap: 6px; }
.pat-filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 12px 2px; }
.fchip { height: 24px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 99px; background: #fff; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.fchip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pat-list { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 14px; }
.pat-divider { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); padding: 6px 2px 0; }
.pat { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: left; width: 100%; }
.pat:hover { border-color: var(--forest); box-shadow: var(--shadow); }
.pat.sel { border-color: var(--forest); background: var(--forest-tint); box-shadow: inset 0 0 0 1px var(--forest); }
.pat svg { width: 92px; height: 78px; display: block; }
.pat-title { display: flex; align-items: baseline; gap: 6px; font-weight: 700; font-size: 13px; }
.pat-title small { font-weight: 500; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pat-big { font-size: 20px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.pat-big span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.pat-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.good { background: #e3f4e6; border-color: #b9e0c2; color: var(--ok); }
.badge.warn { background: var(--amber-bg); border-color: #ecd49b; color: var(--amber); }
.badge.bad { background: var(--red-bg); border-color: #f3c1bc; color: var(--red); }
.badge.info { background: #e8effb; border-color: #c5d6f2; color: var(--blue); }
.show-more { height: 30px; border: 1px dashed var(--line-strong); border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; font-size: 12px; }
.show-more:hover { border-color: var(--forest); color: var(--forest); }

.sum { padding: 12px 14px 4px; }
.sum-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; }
.sum-hero { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 4px; }
.hero { padding: 8px 6px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); text-align: center; }
.hero b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.sec { padding: 10px 14px; border-top: 1px solid var(--line); }
.sec > h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.sec > h3 .grow { flex: 1; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: 12.5px; }
.kv dt, .kv .k { color: var(--muted); }
.kv dd, .kv .v { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv .v small { font-weight: 500; color: var(--faint); }
.checklist { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.chk { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 6px; align-items: start; }
.chk .v { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.chk.ok .ico { color: var(--ok); } .chk.warn .ico { color: var(--amber); } .chk.error .ico { color: var(--red); } .chk.info .ico { color: var(--blue); }
.chk.error { color: var(--red); font-weight: 600; } .chk.warn { color: #6b3d00; }
.chk .fix { border: 0; background: none; padding: 0; color: var(--forest); font-weight: 700; text-decoration: underline; font-size: 12px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; }
.stepper button { width: 26px; height: 26px; border: 0; background: #fff; font-weight: 800; }
.stepper button:hover:not(:disabled) { background: var(--forest-tint); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper b { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.mini-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; }
.mini-seg button { height: 26px; padding: 0 9px; border: 0; background: #fff; font-size: 12px; font-weight: 600; color: var(--muted); }
.mini-seg button + button { border-left: 1px solid var(--line-strong); }
.mini-seg button.active { background: var(--forest); color: #fff; }
.mini-seg button:disabled { opacity: .45; cursor: not-allowed; }
.layers { display: flex; flex-direction: column; gap: 3px; }
.layer { display: grid; grid-template-columns: 26px 26px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 3px 4px 3px 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 12.5px; }
.layer:hover { border-color: var(--line-strong); background: var(--panel-2); }
.layer.cur { border-color: var(--forest); box-shadow: inset 3px 0 0 var(--forest); }
.layer .n { font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); }
.layer .arr { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-weight: 800; font-size: 11.5px; color: #fff; background: var(--forest); }
.layer .meta { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.layer .meta b { color: var(--ink); }
.layer .acts { display: flex; gap: 1px; }
.layer .icon-btn { width: 26px; height: 26px; }
.sheet-row { height: 7px; margin: 0 26px; border-radius: 3px; background: repeating-linear-gradient(90deg, #c9a36b 0 8px, #b98f55 8px 16px); position: relative; }
.sheet-row::after { content: 'tier sheet'; position: absolute; right: -2px; top: -5px; font-size: 9.5px; color: var(--amber); background: #fff; padding: 0 4px; }
.arr-A { background: #1f5a3a !important; } .arr-B { background: #2456a6 !important; } .arr-C { background: #a7600a !important; } .arr-D { background: #7a3fa0 !important; } .arr-E { background: #b3261e !important; } .arr-F { background: #0e7c86 !important; }
.pallet-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; background: #f3ead6; border: 1px solid #e3d3ae; color: #6b5223; font-size: 12px; font-weight: 600; margin-top: 3px; }

/* ---------- layer editor ---------- */
.ed-toolbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #fff; }
.ed-group { display: inline-flex; align-items: center; gap: 4px; }
.ed-group + .ed-group { padding-left: 10px; border-left: 1px solid var(--line); }
.ed-group > label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.ed-toolbar select { width: auto; height: 28px; font-size: 12.5px; font-weight: 600; }
.ed-toolbar .btn { height: 28px; padding: 0 9px; }
.ed-canvas-wrap { flex: 1; min-height: 0; position: relative; background: #f1f3ed; background-image: linear-gradient(#e6e9e0 1px, transparent 1px), linear-gradient(90deg, #e6e9e0 1px, transparent 1px); background-size: 24px 24px; }
.ed-canvas { position: absolute; inset: 0; outline: none; }
.ed-canvas svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
.ed-status { flex: none; display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 6px 12px; border-top: 1px solid var(--line); background: #fff; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ed-status b { color: var(--ink); }
.ed-status .bad { color: var(--red); font-weight: 700; }
.ed-status .hint { margin-left: auto; color: var(--faint); }
.case-rect { cursor: move; }
.case-num { font: 700 10px system-ui, sans-serif; fill: #3d2f14; pointer-events: none; text-anchor: middle; dominant-baseline: central; }

/* ---------- report tab ---------- */
.report-view { overflow-y: auto; }
.report-form { width: min(60rem, 100%); margin: 0 auto; padding: 22px 26px 40px; display: flex; flex-direction: column; gap: 14px; }
.report-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.report-head h2 { font-size: 19px; letter-spacing: -.01em; }
.rev-head { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.rev-head h3 { font-size: 14px; }
.table-wrap { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.rev-table { width: 100%; border-collapse: collapse; }
.rev-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--panel-2); padding: 7px 8px; border-bottom: 1px solid var(--line); }
.rev-table td { padding: 4px; border-bottom: 1px solid var(--line); }
.rev-table tr:last-child td { border-bottom: 0; }
.rev-table input { border-color: transparent; height: 30px; }
.rev-table input:hover { border-color: var(--line-strong); }

/* ---------- status bar ---------- */
.statusbar { height: var(--status-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: #fff; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.status-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; white-space: nowrap; overflow: hidden; }
.status-main .s { display: inline-flex; align-items: center; gap: 5px; }
.status-main .s.ok { color: var(--ok); font-weight: 600; } .status-main .s.warn { color: var(--amber); font-weight: 600; } .status-main .s.error { color: var(--red); font-weight: 700; }
.status-right { display: flex; gap: 12px; flex: none; }
.ver { color: var(--faint); }

/* ---------- dialogs, menu, toasts, busy ---------- */
.dlg { width: min(46rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); box-shadow: 0 18px 50px rgb(0 0 0 / .35); }
.dlg::backdrop { background: rgb(14 20 16 / .6); }
.dlg h2 { font-size: 17px; margin-bottom: 6px; }
.dlg.small { width: min(26rem, calc(100% - 2rem)); }
.dlg.wide { width: min(66rem, calc(100% - 2rem)); }
.dlg.full { width: min(72rem, calc(100% - 2rem)); height: calc(100dvh - 2rem); padding: 0; display: none; flex-direction: column; overflow: hidden; }
.dlg.full[open] { display: flex; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; }
.dlg.full iframe { flex: 1; border: 0; width: 100%; background: #525659; }
.dlg-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.crop-image { margin: 10px 0 6px; max-height: 56vh; overflow: auto; background: #eeece6; border-radius: 8px; }
#cropCanvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.import-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; margin-top: 8px; }
.import-preview { border: 1px solid var(--line); border-radius: 9px; background: #f1f1ee; max-height: 62vh; overflow: auto; }
.import-preview img, .import-preview canvas { display: block; width: 100%; height: auto; }
.import-fields { display: flex; flex-direction: column; gap: 9px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.pick-list .arr-opt { width: auto; }
.pick-list .arr-opt svg { width: 100%; height: 78px; }
.limits3 .inp input { padding-right: 22px; }
.arr-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.arr-opt { width: 92px; padding: 4px 4px 3px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.arr-opt svg { width: 80px; height: 62px; display: block; }
.arr-opt small { font-size: 10.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.arr-opt:hover { border-color: var(--forest); }
.arr-opt.active { border-color: var(--forest); background: var(--forest-tint); box-shadow: inset 0 0 0 1px var(--forest); }
.arr-opt.active small { color: var(--forest-deep); }
.import-note { padding: 8px 10px; border-radius: 8px; background: var(--forest-tint); font-size: 12.5px; color: var(--forest-deep); }
.import-note.warn { background: var(--amber-bg); color: #6b3d00; }
.import-raw { font: 11px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 9rem; overflow: auto; color: var(--muted); }
.menu { position: fixed; z-index: 50; min-width: 220px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 12px 34px rgb(0 0 0 / .2); display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-weight: 550; }
.menu button:hover { background: var(--forest-tint); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.menu .menu-label { padding: 5px 9px 2px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 44px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 9px 14px; border-radius: 9px; background: var(--charcoal); color: #fff; font-weight: 600; box-shadow: 0 8px 26px rgb(0 0 0 / .28); max-width: min(34rem, 90vw); transition: opacity .3s, transform .3s; }
.toast.error { background: var(--red); } .toast.ok { background: var(--forest); }
.toast.out { opacity: 0; transform: translateY(8px); }
.busy { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgb(14 20 16 / .45); }
.busy-card { min-width: 250px; padding: 18px 22px; border-radius: 12px; background: #fff; display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 600; box-shadow: 0 18px 50px rgb(0 0 0 / .3); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--forest-tint); border-top-color: var(--forest); border-radius: 50%; animation: spin .8s linear infinite; }
.busy-bar { width: 100%; height: 4px; border-radius: 99px; background: var(--forest-tint); overflow: hidden; }
.busy-bar i { display: block; height: 100%; width: 0; background: var(--forest); transition: width .2s; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .workspace { grid-template-columns: 308px minmax(0, 1fr) 320px; }
  .tb-label { display: none; }
  .tb.primary .tb-label { display: inline; }
}
@media (max-width: 1020px) {
  body { overflow: auto; }
  .workspace { grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(34rem, 72vh) auto; flex: none; }
  .panel.left { grid-row: 1 / 3; }
  .panel.right { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); }
  .panel.right .panel-scroll { overflow: visible; }
  .brand-text span { display: none; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 8px; }
  .project-name { order: 5; width: 100%; margin: 0; }
  .workspace { display: flex; flex-direction: column; }
  .panel.left { border-right: 0; }
  .panel.left .panel-scroll, .panel.right .panel-scroll { overflow: visible; }
  .stage { height: 78vh; flex: none; border-top: 1px solid var(--line); }
  .generate-box { position: static; }
  .import-grid { grid-template-columns: minmax(0, 1fr); }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-hint { display: none; }
}
@media print { body { display: none; } }
