:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #697386;
  --line: #dce1e8;
  --accent: #265cff;
  --accent-soft: #eaf0ff;
  --danger: #c92c3a;
  --shadow: 0 14px 36px rgba(26, 37, 62, .09);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding: 32px clamp(20px, 5vw, 72px) 24px; background: #111a2b; color: #fff; }
h1 { margin: 2px 0 6px; font-size: clamp(25px, 3vw, 40px); line-height: 1.13; }
h2, h3, h4 { margin: 0; }
.subhead { margin: 0; color: #c8d1e0; }
.eyebrow { margin: 0 0 3px; text-transform: uppercase; letter-spacing: .11em; font-size: 11px; font-weight: 800; color: #7e8aa1; }
.topbar .eyebrow { color: #8fa9ff; }
.status { border: 1px solid rgba(255,255,255,.24); border-radius: 999px; padding: 7px 12px; font-weight: 700; }

main { padding: 24px clamp(16px, 4vw, 56px) 56px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.upload-card { padding: 20px; max-width: 850px; margin: 0 auto 22px; }
#upload-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: stretch; }
.dropzone { min-height: 82px; border: 1.5px dashed #aab4c5; border-radius: 13px; padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; gap: 2px; background: #fafbfc; }
.dropzone input { margin-top: 8px; }
.primary, .secondary, .tool { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 750; }
.primary { background: var(--accent); color: #fff; }
.primary:hover { filter: brightness(.95); }
.secondary { background: var(--accent-soft); color: #1742bf; }
.message { margin: 10px 0 0; min-height: 22px; color: var(--muted); }
.message.error { color: var(--danger); }
.hidden { display: none !important; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary-card { padding: 14px 16px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.summary-card strong { display: block; font-size: 24px; }
.summary-card span { color: var(--muted); }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(380px, .75fr); gap: 16px; align-items: start; }
.preview-panel, .settings-panel { padding: 18px; }
.panel-heading { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 9px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.tool { background: #eef1f5; color: #3c4659; padding: 7px 10px; }
.tool.active { background: var(--accent); color: #fff; }
.hint, .selection-summary { color: var(--muted); margin: 8px 0 12px; }
.preview { min-height: 560px; background: #d9dee6; border-radius: 12px; overflow: hidden; border: 1px solid #c8cfd9; display: grid; place-items: center; }
.preview svg { display: block; width: 100%; height: 100%; max-height: 72vh; touch-action: none; user-select: none; }
.preview .page-background { fill: #fff; }
.preview .pdf-object { cursor: pointer; }
.preview .pdf-object.ignored { opacity: .12 !important; stroke: #ff00b8 !important; fill: #ff00b8 !important; }
.preview .frame-overlay rect { fill: none; stroke: #265cff; stroke-width: 1.4; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.preview .frame-overlay text { fill: #1742bf; font: 800 8px/1 sans-serif; paint-order: stroke; stroke: #fff; stroke-width: 2px; }
#selection-box { display: none; fill: rgba(38,92,255,.12); stroke: #265cff; stroke-width: 1.2; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }

.settings-panel { max-height: calc(100vh - 34px); overflow: auto; position: sticky; top: 16px; }
.frame-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 14px 0; background: #fcfdff; }
.frame-title-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.frame-size { font-size: 17px; }
.switch-label { display: flex; gap: 8px; align-items: center; color: #394358; font-weight: 650; }
.form-grid { display: grid; grid-template-columns: 1fr 130px; gap: 10px; margin: 13px 0; }
.form-grid .wide { grid-column: 1 / -1; }
.four-columns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.frame-geometry-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.tool.danger { color: var(--danger); background: #fff1f2; }
label { color: #4a5569; font-weight: 650; }
input[type="text"], input[type="number"], select { width: 100%; margin-top: 4px; border: 1px solid #cfd6e0; border-radius: 9px; padding: 9px 10px; background: #fff; color: var(--ink); }
fieldset { display: grid; gap: 7px; margin: 12px 0; border: 1px solid #dfe4eb; border-radius: 10px; }
fieldset legend { padding: 0 6px; font-weight: 800; color: #3d485c; }
fieldset label { font-weight: 550; }
.label-settings { display: grid; gap: 7px; margin: 12px 0; }
.mapping-block h4 { margin: 14px 0 8px; }
.color-row { display: grid; grid-template-columns: 24px minmax(90px, 1fr) minmax(170px, 1.8fr); gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid #eef0f3; }
.swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(0,0,0,.18); }
.color-meta { font-size: 12px; color: var(--muted); }
.new-material { border: 1px dashed #b8c4d6; border-radius: 10px; padding: 10px; }
.actions { position: sticky; bottom: -18px; background: linear-gradient(transparent, #fff 25%); padding: 30px 0 4px; }
.actions .primary { width: 100%; }

@media (max-width: 1050px) {
  .editor-grid { grid-template-columns: 1fr; }
  .settings-panel { position: static; max-height: none; }
}
@media (max-width: 700px) {
  #upload-form { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-heading, .frame-title-row { flex-direction: column; }
  .preview { min-height: 420px; }
  .four-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.palette-card { margin: 10px 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8faff; }
.palette-card p { margin: 5px 0 10px; color: var(--muted); }
.palette-grid { display: grid; gap: 6px; }
.palette-grid span { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; }
.palette-grid i { width: 17px; height: 17px; border-radius: 4px; border: 1px solid rgba(0,0,0,.25); flex: 0 0 auto; }
.actions { display: grid; gap: 9px; }
.actions .primary, .actions .secondary { width: 100%; }
.export-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.app-nav { display: flex; gap: 8px; padding: 12px clamp(16px, 4vw, 56px); background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.nav-button { border: 0; border-radius: 10px; padding: 9px 14px; background: transparent; color: #4c586e; font-weight: 800; }
.nav-button.active { background: var(--accent-soft); color: #1742bf; }
.app-view { min-height: 300px; }
.product-meta-panel { max-width: 980px; margin: 0 auto 16px; padding: 18px; display: grid; grid-template-columns: 190px 1fr; gap: 18px; align-items: start; }
.product-meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.product-meta-grid .wide { grid-column: 1 / -1; }
.editing-version { grid-column: 1 / -1; margin: 0; padding: 9px 11px; border-radius: 9px; background: #edf8ef; color: #276237; font-weight: 700; }
.wide-button { width: 100%; }
.inline-material-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.library-panel { padding: 22px; max-width: 1180px; margin: 0 auto; }
.library-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.library-tools { display: flex; gap: 8px; align-items: center; }
.library-tools input { min-width: 260px; margin: 0; }
.products-list { display: grid; gap: 12px; margin-top: 12px; }
.product-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #fcfdff; }
.product-card-head { display: flex; justify-content: space-between; gap: 18px; }
.product-card-head h3 { font-size: 22px; }
.product-card-head p { margin: 3px 0; color: var(--muted); }
.product-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; align-items: flex-start; }
.button-link { display: inline-block; border-radius: 10px; padding: 10px 14px; font-weight: 750; text-decoration: none; background: var(--accent); color: #fff; }
.product-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 12px 0; color: var(--muted); }
.product-stats span { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.product-stats em { font-style: normal; background: #eef1f5; border-radius: 999px; padding: 4px 8px; color: #465166; font-size: 12px; }
.sheet-list { display: grid; gap: 5px; }
.sheet-list a { color: #234fb9; text-decoration: none; padding: 6px 8px; border-radius: 7px; background: #f2f6ff; }
.materials-grid { display: grid; grid-template-columns: minmax(330px, .7fr) minmax(0, 1.3fr); gap: 16px; max-width: 1180px; margin: 0 auto; }
.material-form-panel, .material-list-panel { padding: 20px; }
.material-form { display: grid; gap: 10px; margin-top: 14px; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.materials-list { display: grid; gap: 9px; margin-top: 14px; }
.material-card { display: flex; justify-content: space-between; gap: 16px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fcfdff; }
.material-card p { margin: 3px 0 0; color: var(--muted); }
.material-size { text-align: right; font-weight: 800; white-space: nowrap; }
.material-size small { color: var(--muted); font-weight: 550; }

@media (max-width: 850px) {
  .product-meta-panel { grid-template-columns: 1fr; }
  .materials-grid { grid-template-columns: 1fr; }
  .library-heading, .product-card-head { flex-direction: column; }
  .library-tools { width: 100%; }
  .library-tools input { min-width: 0; flex: 1; }
}
@media (max-width: 600px) {
  .app-nav { overflow-x: auto; }
  .nav-button { white-space: nowrap; }
  .product-meta-grid, .inline-material-grid, .two-columns { grid-template-columns: 1fr; }
  .product-meta-grid .wide { grid-column: auto; }
}

.palette-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.palette-heading p { margin-bottom: 0; }
.quick-operation-form { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 9px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.quick-operation-form .wide { grid-column: 1 / -1; }
input[type="color"] { width: 100%; min-height: 42px; margin-top: 4px; padding: 3px; border: 1px solid #cfd6e0; border-radius: 9px; background: #fff; cursor: pointer; }
.checkbox-line { display: flex; gap: 8px; align-items: center; font-weight: 650; }
.operation-card-main { display: flex; gap: 11px; align-items: center; min-width: 0; }
.operation-swatch { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 8px; border: 1px solid rgba(0,0,0,.25); }
.operation-meta { text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 800; white-space: nowrap; }
.operation-meta small { font-family: ui-sans-serif, system-ui, sans-serif; color: var(--muted); font-weight: 600; }

@media (max-width: 600px) {
  .palette-heading { flex-direction: column; }
  .quick-operation-form { grid-template-columns: 1fr; }
  .quick-operation-form .wide { grid-column: auto; }
}

textarea {
  width: 100%;
  margin-top: 4px;
  border: 1px solid #cfd6e0;
  border-radius: 9px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.order-layout {
  display: grid;
  grid-template-columns: minmax(320px, .62fr) minmax(0, 1.38fr);
  gap: 16px;
  max-width: 1500px;
  margin: 0 auto;
}
.order-input-panel, .order-plan-panel { padding: 20px; }
.order-input-panel { display: flex; flex-direction: column; gap: 11px; align-self: start; position: sticky; top: 70px; }
.order-input-panel > label { display: block; }
.section-heading-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.order-material-settings { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.order-material-settings-list { display: grid; gap: 10px; }
.order-material-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fafcff; }
.order-material-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.order-material-card-head p { margin: 3px 0 0; color: var(--muted); }
.order-setting-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.order-setting-grid label:last-child { grid-column: 1 / -1; }
.order-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.order-plan.empty-state { min-height: 320px; display: grid; place-items: center; color: var(--muted); border: 1px dashed #cbd3df; border-radius: 14px; }
.order-plan { display: grid; gap: 18px; }
.order-error-card { border: 1px solid #f2c6c6; border-radius: 12px; padding: 14px; background: #fff6f6; color: #812c2c; }
.order-error-card p { margin: 5px 0 0; }
.production-material { border-top: 1px solid var(--line); padding-top: 16px; }
.production-material:first-child { border-top: 0; padding-top: 0; }
.production-material-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.production-stats { color: var(--muted); text-align: right; }
.production-pages { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.production-page-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fafbfd; min-width: 0; }
.production-page-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: #435068; }
.production-page-svg { display: block; width: 100%; max-height: 520px; background: #eef1f5; border: 1px solid #cfd6e0; touch-action: none; user-select: none; }
.production-page-background { fill: #fff; }
.production-usable-area { fill: none; stroke: #8a96a8; stroke-width: 1; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.production-placement { cursor: grab; }
.production-placement.dragging { cursor: grabbing; opacity: .72; }
.production-placement polygon { fill: rgba(38, 92, 255, .16); stroke: #265cff; stroke-width: 1.3; vector-effect: non-scaling-stroke; }
.production-placement:nth-of-type(3n+1) polygon { fill: rgba(22, 145, 92, .16); stroke: #168a59; }
.production-placement:nth-of-type(3n+2) polygon { fill: rgba(205, 116, 19, .16); stroke: #bd6b18; }
.production-placement text { fill: #17233a; font: 800 10px/1 sans-serif; text-anchor: middle; dominant-baseline: middle; pointer-events: none; paint-order: stroke; stroke: #fff; stroke-width: 2.5px; vector-effect: non-scaling-stroke; }
.placement-list { display: grid; gap: 5px; margin-top: 9px; max-height: 250px; overflow: auto; }
.placement-row { display: grid; grid-template-columns: minmax(125px, 1fr) 74px 74px 82px; gap: 6px; align-items: end; border-top: 1px solid #e7eaf0; padding-top: 6px; }
.placement-row:first-child { border-top: 0; }
.placement-row > div { min-width: 0; }
.placement-row strong, .placement-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.placement-row span { color: var(--muted); font-size: 12px; }
.placement-row label { font-size: 11px; }
.placement-row input { padding: 6px; font-size: 12px; }
code { background: #eef1f5; padding: 2px 5px; border-radius: 5px; }

@media (max-width: 1080px) {
  .order-layout { grid-template-columns: 1fr; }
  .order-input-panel { position: static; }
}
@media (max-width: 700px) {
  .order-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .production-pages { grid-template-columns: 1fr; }
  .placement-row { grid-template-columns: 1fr 62px 62px 70px; }
}
@media (max-width: 520px) {
  .order-setting-grid { grid-template-columns: 1fr; }
  .order-setting-grid label:last-child { grid-column: auto; }
  .placement-row { grid-template-columns: 1fr 1fr 1fr; }
  .placement-row > div { grid-column: 1 / -1; }
}

.order-action-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.production-usable-fill { fill: rgba(255,255,255,.72); }
.stock-layout { display: grid; grid-template-columns: minmax(310px, .55fr) minmax(0, 1.45fr); gap: 16px; max-width: 1420px; margin: 0 auto; }
.stock-form-panel, .stock-list-panel { padding: 20px; }
.stock-form-panel { align-self: start; position: sticky; top: 70px; }
.stock-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.stock-filters select { min-width: 220px; margin: 0; }
.stock-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; margin-top: 14px; }
.stock-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fcfdff; min-width: 0; }
.stock-card.consumed { opacity: .62; background: #f2f3f5; }
.stock-card-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.stock-card-head p { margin: 3px 0 0; color: var(--muted); }
.stock-balance { text-align: right; white-space: nowrap; }
.stock-balance strong, .stock-balance span { display: block; }
.stock-balance strong { font-size: 24px; }
.stock-balance span { color: var(--muted); font-size: 12px; }
.stock-preview { width: 100%; max-height: 250px; margin: 12px 0; display: block; background: #e6e8ec; border: 1px solid #cbd2dc; }
.stock-base { fill: #f3f4f6; stroke: #8b95a6; stroke-width: 1; vector-effect: non-scaling-stroke; }
.stock-usable { fill: #fff; stroke: #2a65d8; stroke-width: 1; vector-effect: non-scaling-stroke; }
.stock-removed { fill: #d8dde5; stroke: #9aa4b4; stroke-width: 1; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.stock-note { color: var(--muted); }
.stock-action { margin-top: 8px; border-top: 1px solid #e4e8ef; padding-top: 8px; }
.stock-action summary { cursor: pointer; font-weight: 750; color: #34435e; }
.stock-inline-form { display: grid; grid-template-columns: repeat(4, minmax(62px, 1fr)); gap: 7px; margin-top: 9px; align-items: end; }
.stock-inline-form button { grid-column: 1 / -1; }
.stock-split-form { display: grid; gap: 7px; margin-top: 8px; }
.stock-consume { width: 100%; margin-top: 10px; }
.stock-consumed-label { padding: 8px 10px; text-align: center; background: #e1e4e8; border-radius: 8px; font-weight: 800; }
.empty-state.compact { min-height: 180px; display: grid; place-items: center; color: var(--muted); border: 1px dashed #cbd3df; border-radius: 14px; }
.stock-choice-list { margin-top: 10px; padding: 10px; border-radius: 10px; background: #f5f7fb; }
.stock-choice-list h5 { margin: 0 0 7px; }
.stock-choice { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; font-weight: 600; }
.stock-choice input { margin-top: 3px; }

.stock-card.highlighted { outline: 4px solid rgba(42, 101, 216, .28); border-color: #2a65d8; box-shadow: 0 8px 30px rgba(42, 101, 216, .18); }
.stock-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.stock-polygon-editor { margin-top: 10px; padding: 10px; border-radius: 10px; background: #f5f7fb; }
.stock-draw-svg { width: 100%; max-height: 330px; display: block; background: #e6e8ec; border: 2px solid #8ca4cd; cursor: crosshair; touch-action: none; }
.stock-draft-line { fill: none; stroke: #e23a3a; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.stock-draft-fill { fill: rgba(226, 58, 58, .18); stroke: none; }
.stock-draft-points circle { fill: #fff; stroke: #c92727; stroke-width: 2; vector-effect: non-scaling-stroke; }
.stock-draft-status { margin: 7px 0; color: var(--muted); font-size: 12px; }
.stock-draw-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.stock-draw-actions button { flex: 1 1 130px; }
.remainder-settings { margin-top: 10px; display: grid; gap: 7px; }
.three-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

@media (max-width: 1050px) {
  .stock-layout { grid-template-columns: 1fr; }
  .stock-form-panel { position: static; }
}
@media (max-width: 650px) {
  .stock-list { grid-template-columns: 1fr; }
  .stock-inline-form, .three-columns { grid-template-columns: 1fr 1fr; }
  .stock-filters { justify-content: stretch; }
  .stock-filters select { min-width: 0; flex: 1; }
}
.production-blocked-area { fill: #cfd5df; stroke: #9aa4b4; stroke-width: 1; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }

.internal-layout-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto;
  gap: .75rem;
  align-items: end;
  margin-top: .8rem;
}
.internal-layout-controls.disabled-controls { opacity: .55; }
.internal-layout-result {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line, #d9dde4);
  border-radius: 14px;
  background: rgba(255,255,255,.72);
}
.layout-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.layout-comparison figure { margin: 0; }
.layout-comparison figcaption { font-weight: 700; margin-bottom: .45rem; }
.layout-comparison svg {
  width: 100%;
  height: 260px;
  border: 1px solid var(--line, #d9dde4);
  border-radius: 10px;
  background: white;
}
.layout-actions, .accepted-layout {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}
.accepted-layout { justify-content: space-between; }
.accepted-layout span { color: var(--muted, #626b7a); }
@media (max-width: 900px) {
  .internal-layout-controls, .layout-comparison { grid-template-columns: 1fr; }
}

.manual-group-details {
  margin-top: .9rem;
  border: 1px solid var(--line, #d9dde4);
  border-radius: 12px;
  background: #f7f9fc;
  padding: .75rem .85rem;
}
.manual-group-details summary { cursor: pointer; font-weight: 800; }
.manual-group-editor { margin-top: .8rem; }
.manual-group-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  align-items: center;
  margin-bottom: .7rem;
}
.manual-selection-info { margin-right: auto; }
.manual-group-svg {
  display: block;
  width: 100%;
  height: min(360px, 48vh);
  min-height: 220px;
  border: 1px solid var(--line, #d9dde4);
  border-radius: 10px;
  background: #fff;
  touch-action: none;
  user-select: none;
}
.manual-group-background { fill: #fff; stroke: #ff0000; stroke-width: .5; }
.manual-group-object { pointer-events: none; }
.manual-group-object.manual-grouped {
  stroke: #087f8c !important;
  stroke-width: 1.15 !important;
  opacity: .9;
}
.manual-group-object.manual-group-locked {
  stroke: #e47d00 !important;
  stroke-width: 1.4 !important;
  opacity: .95;
}
.manual-group-object.manual-group-selected {
  stroke: #7a2cff !important;
  fill: rgba(122, 44, 255, .16) !important;
  stroke-width: 1.8 !important;
  opacity: 1 !important;
}
.manual-group-object.manual-group-ignored { opacity: .12 !important; }
.manual-group-hit {
  fill: transparent;
  stroke: transparent;
  stroke-width: 8;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
  cursor: pointer;
}
.manual-group-selection-box {
  display: none;
  fill: rgba(38, 92, 255, .12);
  stroke: #265cff;
  stroke-width: 1;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.manual-group-list { display: grid; gap: .55rem; margin-top: .8rem; }
.manual-group-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  gap: .5rem;
  align-items: center;
  border: 1px solid var(--line, #d9dde4);
  border-radius: 10px;
  background: #fff;
  padding: .6rem .7rem;
}
.manual-group-row div { display: grid; gap: .15rem; }
.manual-group-row span { color: var(--muted, #626b7a); font-size: .88rem; }
.manual-group-empty { margin: 0; }
@media (max-width: 800px) {
  .manual-group-row { grid-template-columns: 1fr 1fr; }
  .manual-group-row div { grid-column: 1 / -1; }
}

/* v0.11 - správa materiálů a porovnání verzí */
.material-form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.material-form-actions button { flex: 1 1 150px; }
.material-card.inactive { opacity: .7; background: #f3f4f6; border-style: dashed; }
.material-title-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.material-title-row h3 { margin: 0; }
.material-state { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.material-state.active { color: #10603e; background: #dff5e9; }
.material-state.inactive { color: #6d4e00; background: #f3e8c2; }
.material-card-side { display: grid; justify-items: end; gap: 8px; }
.material-card-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.danger-outline { border: 1px solid #c93b3b; color: #a12424; background: #fff; }
.danger-outline:hover { background: #fff1f1; }

.version-panel { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.version-panel-head, .comparison-sheet-head, .compare-side-title, .comparison-version-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.version-panel-head h4 { margin: 0; }
.version-history-list { display: grid; gap: 7px; margin-top: 10px; }
.version-history-row { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; }
.version-history-row.current { border-color: #2a65d8; background: #f4f7ff; }
.version-history-row strong, .version-history-row span { display: block; }
.version-history-row span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.version-row-actions { display: flex; gap: 5px; align-items: center; }
.button-link.compact { min-height: 34px; padding: 7px 10px; }
.version-compare-controls { display: grid; grid-template-columns: 1fr 1fr auto; gap: 9px; align-items: end; margin-top: 14px; padding: 12px; background: #f5f7fb; border-radius: 12px; }
.version-comparison-result { margin-top: 14px; }
.comparison-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.comparison-version-head { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.comparison-version-head > div { display: grid; gap: 2px; }
.comparison-version-head > div:last-child { text-align: right; }
.comparison-version-head span { color: var(--muted); font-size: 12px; }
.version-meta-differences { margin-top: 10px; border: 1px solid #e1c77f; border-radius: 10px; background: #fffaf0; padding: 10px 12px; }
.version-meta-differences h5 { margin: 0 0 6px; }
.version-meta-differences p { margin: 4px 0; font-size: 13px; }
.comparison-sheets { display: grid; gap: 12px; margin-top: 12px; }
.comparison-sheet { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.comparison-sheet.modified { border-color: #d89c26; }
.comparison-sheet.added { border-color: #279861; }
.comparison-sheet.removed { border-color: #c84a4a; }
.comparison-sheet.unchanged { opacity: .82; }
.comparison-sheet-head span { font-weight: 800; font-size: 12px; border-radius: 999px; padding: 4px 8px; background: #eef1f5; }
.compare-pdf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.compare-side { min-width: 0; border: 1px solid #e1e5eb; border-radius: 10px; padding: 9px; background: #fafbfc; }
.compare-side.empty { min-height: 120px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.compare-side-title a { font-size: 12px; }
.compare-side p { margin: 4px 0; font-size: 12px; color: var(--muted); }
.compare-side iframe { width: 100%; height: 320px; border: 1px solid #cfd5df; background: #fff; margin-top: 7px; }
.difference-list { display: grid; gap: 5px; margin-top: 10px; }
.difference-list > div { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(0, 1fr) auto minmax(0, 1fr); gap: 7px; align-items: center; border-top: 1px solid #edf0f4; padding-top: 5px; font-size: 12px; }
.difference-list span { overflow-wrap: anywhere; }
.difference-list b { color: var(--muted); }
.unchanged-note { margin: 9px 0 0; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .version-compare-controls, .compare-pdf-grid { grid-template-columns: 1fr; }
  .version-compare-controls button { width: 100%; }
  .comparison-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .difference-list > div { grid-template-columns: 1fr; }
  .difference-list b { display: none; }
}
@media (max-width: 650px) {
  .version-history-row { grid-template-columns: 1fr; }
  .material-card-side { justify-items: start; }
  .material-card-actions { justify-content: flex-start; }
  .comparison-version-head { display: grid; }
  .comparison-version-head > div:last-child { text-align: left; }
}

/* Verze 0.12: přihlášení, správa a audit */
.user-status { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; justify-content: flex-end; }
.login-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 1rem; background: rgba(15, 23, 42, .76); backdrop-filter: blur(8px); }
.login-overlay.hidden { display: none; }
.login-card { width: min(420px, 100%); padding: 1.6rem; border-radius: 22px; background: #fff; box-shadow: 0 24px 70px rgba(15, 23, 42, .35); display: grid; gap: 1rem; }
.login-card h2 { margin: 0; }
.login-card label { display: grid; gap: .35rem; font-weight: 700; }
.admin-grid { display: grid; grid-template-columns: minmax(360px, .85fr) minmax(360px, 1.15fr); gap: 1rem; }
.admin-audit-panel { grid-column: 1 / -1; }
.admin-list { display: grid; gap: .7rem; margin-top: 1rem; }
.admin-card { display: grid; grid-template-columns: minmax(160px, 1.4fr) minmax(130px, .8fr) minmax(140px, .9fr) auto auto; align-items: end; gap: .65rem; padding: .85rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.admin-card.compact { grid-template-columns: 1fr auto; align-items: center; }
.admin-card > div { display: grid; gap: .15rem; }
.admin-card span { color: var(--muted); font-size: .88rem; }
.admin-card label { display: grid; gap: .25rem; font-size: .82rem; font-weight: 700; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.audit-list { overflow-x: auto; margin-top: 1rem; }
.audit-list table { width: 100%; border-collapse: collapse; min-width: 760px; }
.audit-list th, .audit-list td { padding: .7rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.audit-list th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.audit-list small { display: block; color: var(--muted); margin-top: .15rem; }
.audit-status { display: inline-flex; min-width: 3.2rem; justify-content: center; padding: .2rem .45rem; border-radius: 999px; font-weight: 800; }
.audit-status.ok { background: #dcfce7; color: #166534; }
.audit-status.error { background: #fee2e2; color: #991b1b; }

@media (max-width: 980px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-audit-panel { grid-column: auto; }
  .admin-card { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .admin-card { grid-template-columns: 1fr; }
  .user-status { justify-content: flex-start; }
}

/* v0.13 – chráněná kompletace */
.packing-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.4fr);
  gap: 1rem;
  align-items: start;
}

.packing-form {
  display: grid;
  gap: 0.8rem;
}

.packing-camera-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.packing-camera-wrap {
  position: relative;
  overflow: hidden;
  margin-top: 0.8rem;
  border-radius: 14px;
  background: #111;
  aspect-ratio: 4 / 3;
}

.packing-camera-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.packing-camera-guide {
  position: absolute;
  inset: 18%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.packing-empty {
  min-height: 320px;
  display: grid;
  place-items: center;
  color: var(--muted, #667085);
  text-align: center;
}

.packing-product-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border, #dfe3e8);
}

.packing-product-head label {
  max-width: 210px;
}

.packing-checklist {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0;
}

.packing-item {
  display: grid;
  grid-template-columns: auto 58px 1fr;
  gap: 0.8rem;
  align-items: center;
  padding: 0.9rem;
  border: 1px solid var(--border, #dfe3e8);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
}

.packing-item:has(input:checked) {
  opacity: 0.65;
}

.packing-item input {
  width: 24px;
  height: 24px;
}

.packing-item-count {
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
}

.packing-item strong,
.packing-item small {
  display: block;
}

.packing-item small {
  margin-top: 0.2rem;
  color: var(--muted, #667085);
}

.packing-progress {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.9rem;
}

@media (max-width: 840px) {
  .packing-layout {
    grid-template-columns: 1fr;
  }
  .packing-product-head {
    align-items: stretch;
    flex-direction: column;
  }
}

/* 0.14 – device-bound QR access */
.login-card-wide { width: min(760px, 100%); max-height: calc(100vh - 3rem); overflow: auto; }
.login-method { display: grid; gap: .75rem; padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.login-method h3, .admin-login-details h3 { margin: 0; }
.admin-login-details { border-top: 1px solid var(--line); padding-top: .75rem; }
.admin-login-details summary { cursor: pointer; font-weight: 800; }
.admin-login-details form { margin-top: .8rem; }
.admin-access-panel { grid-column: 1 / -1; }
.admin-create-form { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.admin-card-actions { display: flex !important; flex-wrap: wrap; gap: .45rem; align-items: center; }
.access-badge { display: inline-flex; align-items: center; width: fit-content; padding: .3rem .55rem; border-radius: 999px; background: #e8f1ff; color: #1d4ed8 !important; font-weight: 800; font-size: .78rem !important; }
.enrollment-result { margin-top: 1rem; }
.enrollment-qr-card { display: grid; grid-template-columns: minmax(170px, 240px) 1fr; gap: 1rem; align-items: center; padding: 1rem; border: 2px solid #111827; border-radius: 18px; background: white; }
.enrollment-qr-card img { width: 100%; aspect-ratio: 1; }
.enrollment-qr-card > div { display: grid; gap: .5rem; }
.enrollment-qr-card span, .enrollment-qr-card small { color: var(--muted); }
.enrollment-qr-card code { padding: .55rem; border-radius: 9px; background: #f3f4f6; word-break: break-all; }
.admin-card.compact small { color: var(--muted); }
@media (max-width: 700px) {
  .enrollment-qr-card { grid-template-columns: 1fr; }
  .enrollment-qr-card img { max-width: 280px; margin: auto; }
}

/* Verze 0.15 – výrobní série a kompletace */
.batch-progress {
  height: 10px;
  border-radius: 999px;
  background: var(--line, #d9d9d9);
  overflow: hidden;
  margin: 10px 0 14px;
}

.batch-progress span {
  display: block;
  height: 100%;
  background: #2f7d4a;
}

.batch-item-row,
.shortage-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1.6fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line, #ddd);
  border-radius: 10px;
  margin-top: 8px;
}

.batch-item-row small,
.shortage-row small {
  grid-column: 1 / -1;
  opacity: 0.78;
}

.shortage-row.status-open { border-left: 5px solid #b34b3c; }
.shortage-row.status-ready { border-left: 5px solid #c28a1f; }
.shortage-row.status-resolved { border-left: 5px solid #2f7d4a; }

.packing-counter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.packing-counter strong { font-size: 1.6rem; }
.packing-counter span { font-size: 0.85rem; opacity: 0.72; }

.packing-item-with-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.packing-item-with-action > label {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: center;
  cursor: pointer;
}

.packing-shortages {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line, #ddd);
  border-radius: 12px;
}

.packing-shortages h3 { margin-top: 0; }

.order-error-card.ok {
  border-color: #2f7d4a;
  background: rgba(47, 125, 74, 0.08);
}

@media (max-width: 700px) {
  .batch-item-row,
  .shortage-row {
    grid-template-columns: 1fr;
  }

  .packing-item-with-action {
    grid-template-columns: 1fr;
  }
}

/* ========================================================================== 
   v0.18 — moderní lehké uživatelské rozhraní
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #f1f5f9;
  --ink: #172033;
  --ink-strong: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #c2414b;
  --danger-soft: #fff1f2;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .035);
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, .055);
  --shadow: 0 18px 48px rgba(15, 23, 42, .07);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --topbar-height: 88px;
  --sidebar-width: 248px;
}

html { background: var(--bg); scroll-behavior: smooth; }
body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  grid-template-areas:
    "header header"
    "nav main";
  margin: 0;
  background:
    radial-gradient(circle at 92% 4%, rgba(37, 99, 235, .055), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #dbeafe; color: #172554; }

.skip-link {
  position: fixed;
  z-index: 3000;
  left: 16px;
  top: -80px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink-strong);
  color: #fff;
  text-decoration: none;
  font-weight: 750;
  transition: top .18s ease;
}
.skip-link:focus { top: 12px; }

.topbar {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 26px;
  color: var(--ink);
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid rgba(226, 232, 240, .92);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .025);
  backdrop-filter: blur(18px) saturate(1.2);
}

.brand-block { display: flex; align-items: center; min-width: 0; gap: 13px; }
.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, #2563eb, #1e40af);
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .24), inset 0 1px 0 rgba(255, 255, 255, .22);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -.04em;
}
.brand-copy { min-width: 0; }
.brand-copy h1 {
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(20px, 2vw, 27px);
  line-height: 1.12;
  letter-spacing: -.035em;
}
.brand-copy .eyebrow { margin-bottom: 2px; color: var(--accent); }
.subhead { margin: 3px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eyebrow { color: var(--muted); letter-spacing: .12em; font-size: 10.5px; font-weight: 850; }
.topbar .eyebrow { color: var(--accent); }

.user-status { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.status {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  color: #475569;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 750;
}
.status-user::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .12);
}
.status-version { color: var(--muted); background: transparent; }

.app-nav {
  grid-area: nav;
  position: sticky;
  top: var(--topbar-height);
  z-index: 50;
  align-self: start;
  height: calc(100vh - var(--topbar-height));
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px 14px;
  background: rgba(255, 255, 255, .78);
  border-right: 1px solid var(--line);
  border-bottom: 0;
  overflow-y: auto;
  backdrop-filter: blur(16px);
}
.nav-section-label {
  margin: 10px 10px 5px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.nav-section-label:first-child { margin-top: 0; }
.nav-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 11px;
  background: transparent;
  color: #526075;
  font-weight: 720;
  text-align: left;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}
.nav-button svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-button:hover { color: var(--ink-strong); background: #f8fafc; border-color: #edf2f7; transform: translateX(1px); }
.nav-button.active {
  color: #1d4ed8;
  background: linear-gradient(90deg, #eff6ff, #f8fbff);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-xs);
}
.nav-button.active svg { stroke-width: 2.1; }
.nav-spacer { flex: 1; min-height: 14px; }
.nav-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 8px 0;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 650;
}
.nav-footer-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }

main {
  grid-area: main;
  min-width: 0;
  width: 100%;
  padding: 26px clamp(18px, 3.1vw, 48px) 72px;
}
.app-view { max-width: 1580px; min-height: 340px; margin: 0 auto; animation: view-in .18s ease-out; }
@keyframes view-in { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }

h1, h2, h3, h4 { color: var(--ink-strong); }
h2 { font-size: clamp(20px, 2vw, 27px); line-height: 1.2; letter-spacing: -.025em; }
h3 { letter-spacing: -.015em; }

.panel {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel:hover { border-color: #d8e0ea; }
.upload-card, .preview-panel, .settings-panel, .material-form-panel, .material-list-panel, .library-panel { padding: clamp(18px, 2vw, 24px); }

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.primary, .secondary, .tool, .button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 11px;
  padding: 9px 14px;
  font-weight: 760;
  line-height: 1.15;
  text-decoration: none;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease, color .14s ease;
}
.primary {
  border: 1px solid #1d4ed8;
  background: linear-gradient(180deg, #2f6ff0, #2563eb);
  color: #fff;
  box-shadow: 0 7px 16px rgba(37, 99, 235, .16), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.primary:hover { filter: none; background: linear-gradient(180deg, #2563eb, #1d4ed8); box-shadow: 0 9px 20px rgba(37, 99, 235, .22); transform: translateY(-1px); }
.secondary {
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: #1d4ed8;
}
.secondary:hover { background: #dbeafe; border-color: #93c5fd; transform: translateY(-1px); }
.tool {
  border: 1px solid var(--line);
  background: #fff;
  color: #526075;
}
.tool:hover { color: var(--ink-strong); border-color: var(--line-strong); background: var(--surface-soft); }
.tool.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.tool.danger, .danger-outline { color: var(--danger); border-color: #fecdd3; background: var(--danger-soft); }
.tool.danger:hover, .danger-outline:hover { background: #ffe4e6; border-color: #fda4af; }
.primary:active, .secondary:active, .tool:active, .button-link:active { transform: translateY(0) scale(.985); }
button:disabled, .primary:disabled, .secondary:disabled, .tool:disabled { cursor: not-allowed; opacity: .52; transform: none; box-shadow: none; }

label { color: #475569; font-weight: 690; font-size: 13px; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], select, textarea {
  width: 100%;
  min-height: 42px;
  margin-top: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink-strong);
  outline: none;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, .018);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { min-height: 112px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .11);
  background: #fff;
}
input::placeholder, textarea::placeholder { color: #a0aec0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input[type="color"] { border-radius: 10px; border-color: var(--line); }

.hint, .selection-summary, .export-note { color: var(--muted); }
.hint { font-size: 13px; }
.message {
  min-height: 0;
  margin-top: 10px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
}
.message:not(:empty) { padding: 9px 11px; border-radius: 10px; background: var(--surface-muted); }
.message.error:not(:empty) { color: #9f1239; background: var(--danger-soft); border: 1px solid #fecdd3; }

.dropzone {
  min-height: 104px;
  border: 1.5px dashed #93c5fd;
  border-radius: 17px;
  padding: 18px;
  background: linear-gradient(145deg, #f8fbff, #eff6ff);
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.dropzone:hover { border-color: var(--accent); background: #eff6ff; transform: translateY(-1px); }
.dropzone strong { color: #1e3a8a; font-size: 15px; }
.dropzone span { color: #64748b; font-weight: 500; }

.summary-grid { gap: 13px; }
.summary-card {
  min-height: 96px;
  padding: 17px 18px;
  border-radius: 17px;
  background: linear-gradient(160deg, #fff, #fbfdff);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
}
.summary-card strong { color: var(--ink-strong); font-size: 28px; letter-spacing: -.035em; }
.summary-card span { font-size: 12px; }

.panel-heading, .section-heading-row, .library-heading { align-items: center; }
.toolbar { gap: 6px; }
.preview {
  background: #e9eef5;
  border: 1px solid #d5dde8;
  border-radius: 16px;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, .06);
}
.settings-panel { top: calc(var(--topbar-height) + 18px); max-height: calc(100vh - var(--topbar-height) - 36px); }

.frame-card, .palette-card, .product-card, .material-card, .stock-card, .order-material-card, .production-page-card, .admin-card, .comparison-sheet {
  background: #fff;
  border-color: var(--line);
  box-shadow: var(--shadow-xs);
}
.frame-card { border-radius: 17px; padding: 16px; }
.palette-card { border-radius: 16px; background: #f8fbff; border-color: #dbeafe; }
.product-card, .material-card, .stock-card, .admin-card { transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.product-card:hover, .material-card:hover, .stock-card:hover, .admin-card:hover { border-color: #cbd5e1; box-shadow: 0 10px 28px rgba(15, 23, 42, .065); transform: translateY(-1px); }

.color-row { border-top-color: #edf2f7; }
.swatch, .operation-swatch { border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28); }
.product-stats em, .material-state, .access-badge, .audit-status, .comparison-sheet-head span {
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.sheet-list a { background: var(--accent-soft); color: #1d4ed8; border: 1px solid #dbeafe; }
.button-link { border: 1px solid #1d4ed8; background: var(--accent); color: #fff; }
.button-link:hover { background: var(--accent-hover); transform: translateY(-1px); }

fieldset {
  border-color: var(--line);
  border-radius: 13px;
  background: #fbfcfe;
  padding: 12px;
}
fieldset legend { color: #334155; }
details > summary { color: #334155; }

.stock-preview, .production-page-svg, .layout-comparison svg, .manual-group-svg, .stock-draw-svg {
  border-radius: 14px;
  border-color: var(--line);
  background: #fff;
}

.production-page-card { border-radius: 18px; overflow: hidden; }
.production-page-title { background: #f8fafc; border-bottom: 1px solid var(--line); }
.batch-progress { height: 8px; background: #e2e8f0; }
.batch-progress span { background: linear-gradient(90deg, #2563eb, #06b6d4); }

.packing-layout { max-width: 1240px; margin: 0 auto; gap: 18px; }
.packing-scan-panel, .packing-result-panel { padding: clamp(20px, 3vw, 30px); }
.packing-camera-wrap { border-radius: 20px; box-shadow: 0 16px 36px rgba(15, 23, 42, .16); }
.packing-camera-guide { inset: 19%; border-width: 2px; border-radius: 18px; }
.packing-empty { min-height: 380px; border: 1px dashed var(--line-strong); border-radius: 16px; background: #fafcff; }
.packing-item-with-action {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.packing-item-with-action:hover { border-color: #bfdbfe; background: #fbfdff; }
.packing-shortages { border-color: #fde68a; background: var(--warning-soft); }

.login-overlay {
  background:
    radial-gradient(circle at 20% 10%, rgba(59, 130, 246, .26), transparent 28rem),
    rgba(15, 23, 42, .76);
  backdrop-filter: blur(14px) saturate(1.1);
}
.login-card {
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 26px;
  padding: clamp(22px, 4vw, 34px);
  box-shadow: 0 30px 90px rgba(15, 23, 42, .36);
}
.login-card-wide { width: min(620px, 100%); }
.login-card > .eyebrow { color: var(--accent); }
.login-method, .admin-login-details {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fbfdff;
  padding: 16px;
}
.admin-login-details summary { padding: 2px 0; }

.audit-list table { border-collapse: separate; border-spacing: 0; overflow: hidden; }
.audit-list th { background: #f8fafc; color: #475569; }
.audit-list th, .audit-list td { border-bottom: 1px solid var(--line); padding: 10px 11px; }
.audit-list tr:hover td { background: #fbfdff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border: 3px solid transparent; background-clip: padding-box; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; border: 3px solid transparent; background-clip: padding-box; }

@media (max-width: 1180px) {
  :root { --sidebar-width: 218px; }
  main { padding-inline: 22px; }
  .subhead { max-width: 440px; }
}

@media (max-width: 900px) {
  :root { --topbar-height: auto; }
  body {
    display: block;
    min-width: 0;
  }
  .topbar {
    position: sticky;
    min-height: 72px;
    padding: 11px 14px;
  }
  .brand-mark { width: 42px; height: 42px; flex-basis: 42px; border-radius: 13px; }
  .brand-copy .eyebrow, .subhead, .status-version { display: none; }
  .brand-copy h1 { font-size: 19px; }
  .user-status { gap: 5px; }
  .user-status .tool, .user-status .status { min-height: 34px; padding: 6px 9px; font-size: 11px; }
  .app-nav {
    position: sticky;
    top: 64px;
    height: auto;
    display: flex;
    flex-direction: row;
    gap: 7px;
    padding: 9px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 5px 16px rgba(15, 23, 42, .035);
  }
  .nav-section-label, .nav-spacer, .nav-footer { display: none; }
  .nav-button { width: auto; min-width: max-content; min-height: 40px; padding: 8px 11px; }
  .nav-button:hover { transform: none; }
  main { padding: 18px 14px 54px; }
  .settings-panel { top: auto; }
}

@media (max-width: 620px) {
  .topbar { align-items: center; gap: 8px; }
  .brand-copy h1 { font-size: 17px; }
  .status-user { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-status .tool { padding-inline: 8px; }
  .app-nav { top: 64px; }
  .nav-button span { font-size: 12px; }
  .nav-button svg { width: 17px; height: 17px; }
  main { padding-inline: 10px; }
  .panel { border-radius: 18px; }
  .upload-card, .preview-panel, .settings-panel, .material-form-panel, .material-list-panel, .library-panel, .packing-scan-panel, .packing-result-panel { padding: 16px; }
  .summary-card { min-height: 82px; padding: 14px; }
  .summary-card strong { font-size: 23px; }
  .primary, .secondary, .tool, .button-link { min-height: 42px; }
  .packing-camera-actions { display: grid; grid-template-columns: 1fr; }
  .packing-camera-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Drobné dolaďování hlavních pracovních obrazovek */
#upload-form { align-items: center; }
#upload-form > .primary { min-height: 50px; align-self: stretch; }
.product-meta-panel { border-radius: var(--radius-lg); }
.product-meta-panel > div:first-child { padding-top: 2px; }
.library-panel, .materials-grid, .order-layout, .stock-layout, .admin-grid { width: 100%; }
.empty-state { color: var(--muted); }
#upload-form > .primary { align-self: center; min-height: 50px; }
@media (max-width: 700px) {
  #upload-form > .primary { width: 100%; }
}


/* ==========================================================================
   v0.19 — uhlazení administrativního rozhraní
   ========================================================================== */
#view-admin { max-width: 1520px; margin: 0 auto; }
#view-admin .admin-grid { gap: 20px; align-items: start; }
#view-admin .panel {
  padding: clamp(22px, 2.4vw, 30px);
  border-radius: 24px;
  border-color: #e6ebf2;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(251,253,255,0.98));
  box-shadow: 0 10px 30px rgba(15, 23, 42, .045);
}
#view-admin .panel > .eyebrow:first-child { margin-bottom: 8px; }
#view-admin .panel > h2,
#view-admin .section-heading-row h2 {
  margin: 0;
  letter-spacing: -0.03em;
  font-size: clamp(28px, 2.2vw, 36px);
  line-height: 1.1;
}
#view-admin .panel > .hint,
#view-admin .section-heading-row + .hint {
  margin: 12px 0 22px;
  max-width: 72ch;
  color: #66758a;
}
#view-admin .section-heading-row { margin-bottom: 8px; }
#view-admin .material-form,
#view-admin .admin-create-form {
  display: grid;
  gap: 14px;
}
#view-admin .material-form label,
#view-admin .admin-card label {
  gap: 6px;
  color: #415064;
}
#view-admin input[type="text"],
#view-admin input[type="number"],
#view-admin input[type="password"],
#view-admin select {
  margin-top: 6px;
  min-height: 50px;
  border-radius: 14px;
  border-color: #d9e2ee;
  padding: 11px 14px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .025);
}
#view-admin input[type="text"]:focus,
#view-admin input[type="number"]:focus,
#view-admin input[type="password"]:focus,
#view-admin select:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37,99,235,.10);
}
#view-admin .primary,
#view-admin .secondary { min-height: 48px; border-radius: 14px; }
#view-admin .admin-create-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #edf2f7;
}
#view-admin .message:not(:empty) { margin-top: 6px; }
#view-admin .admin-list { gap: 12px; margin-top: 16px; }
#view-admin .admin-card {
  grid-template-columns: minmax(180px, 1.35fr) minmax(140px, .9fr) minmax(150px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f9fbff);
  border-color: #e6ebf2;
}
#view-admin .admin-card.compact {
  grid-template-columns: minmax(0,1fr) auto auto;
  gap: 14px;
  align-items: center;
}
#view-admin .admin-card > div { gap: 4px; }
#view-admin .admin-card strong { line-height: 1.35; }
#view-admin .admin-card span,
#view-admin .admin-card small { color: #66758a; }
#view-admin .admin-card-actions { justify-content: flex-end; }
#view-admin .audit-list { margin-top: 16px; border: 1px solid #e6ebf2; border-radius: 18px; background: #fff; }
#view-admin .audit-list table { margin: 0; }
#view-admin .audit-list th:first-child,
#view-admin .audit-list td:first-child { padding-left: 16px; }
#view-admin .audit-list th:last-child,
#view-admin .audit-list td:last-child { padding-right: 16px; }
#view-admin .enrollment-qr-card {
  padding: 18px;
  border-color: #dbe7ff;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  box-shadow: 0 8px 26px rgba(37, 99, 235, .08);
}
#view-admin .enrollment-qr-card code { padding: 10px 12px; border-radius: 12px; }
#view-admin h3 { margin: 20px 0 10px; }
#view-admin .tool { border-radius: 12px; }
@media (max-width: 980px) {
  #view-admin .panel { padding: 20px; }
  #view-admin .admin-card { grid-template-columns: 1fr 1fr; align-items: end; }
  #view-admin .admin-card.compact { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  #view-admin .panel > h2,
  #view-admin .section-heading-row h2 { font-size: 30px; }
  #view-admin .panel { border-radius: 20px; padding: 18px; }
  #view-admin .admin-card { grid-template-columns: 1fr; }
}

/* ========================================================================== 
   v0.20 — kompletace jako finální kontrola celé výrobní série
   ========================================================================== */
.packing-final-layout {
  grid-template-columns: minmax(300px, .56fr) minmax(0, 1.44fr);
  max-width: 1540px;
  gap: 20px;
}
.packing-final-layout .packing-scan-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 18px);
  align-self: start;
  padding: 26px;
}
.packing-final-layout .packing-result-panel {
  padding: clamp(20px, 2.5vw, 30px);
  min-width: 0;
}
.packing-scan-help {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}
.packing-scan-help span { display: flex; align-items: center; gap: 8px; }
.packing-help-dot { width: 10px; height: 10px; border-radius: 999px; flex: 0 0 auto; background: #cbd5e1; }
.packing-help-dot.simple { background: #22c55e; }
.packing-help-dot.multipart { background: #f59e0b; }

.packing-session-workspace { display: grid; gap: 24px; }
.packing-session-overview { min-width: 0; }
.packing-session-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
}
.packing-session-head h2 { margin: 0; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.04em; }
.packing-session-head p { margin: 4px 0 0; color: var(--muted); }
.packing-session-counter { text-align: right; white-space: nowrap; }
.packing-session-counter strong { display: block; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.packing-session-counter span { color: var(--muted); font-size: 12px; }
.packing-session-progress {
  height: 9px;
  margin: 16px 0 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}
.packing-session-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
  transition: width .22s ease;
}
.packing-session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 12px;
}
.packing-product-card {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 15px 16px;
  text-align: left;
  color: var(--ink);
  border: 1.5px solid #dfe6ef;
  border-radius: 17px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  box-shadow: var(--shadow-xs);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.packing-product-card:hover { transform: translateY(-1px); border-color: #bfdbfe; box-shadow: 0 10px 24px rgba(15,23,42,.065); }
.packing-product-card.multipart { border-color: #f6b84e; box-shadow: inset 3px 0 0 #f59e0b, var(--shadow-xs); }
.packing-product-card.complete { border-color: #86d5a3; background: linear-gradient(180deg, #f7fff9, #f0fdf4); box-shadow: inset 3px 0 0 #22c55e, var(--shadow-xs); }
.packing-product-card.active { outline: 3px solid rgba(37,99,235,.12); border-color: #60a5fa; }
.packing-product-card.scan-hit { animation: packing-scan-flash .7s ease both; }
@keyframes packing-scan-flash {
  0% { transform: scale(1); }
  35% { transform: scale(1.025); box-shadow: 0 0 0 6px rgba(37,99,235,.12); }
  100% { transform: scale(1); }
}
.packing-card-top, .packing-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.packing-card-top strong { font-size: 20px; line-height: 1.15; letter-spacing: -.025em; }
.packing-card-top em { font-style: normal; font-weight: 850; color: #334155; }
.packing-card-name { min-height: 22px; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.packing-card-meta { color: var(--muted); font-size: 12px; }
.packing-card-bottom { align-items: flex-end; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.packing-type-badge, .packing-shortage-badge, .packing-done-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .02em;
}
.packing-type-badge.simple { color: #166534; background: #dcfce7; }
.packing-type-badge.multipart { color: #92400e; background: #fef3c7; }
.packing-shortage-badge { color: #9f1239; background: #ffe4e6; }
.packing-done-badge { color: #166534; background: #dcfce7; }

.packing-detail-panel {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}
.packing-detail-empty {
  min-height: 130px;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #cbd5e1;
  border-radius: 17px;
  background: #fafcff;
}
.packing-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.packing-detail-head h3 { margin: 0; font-size: 26px; letter-spacing: -.03em; }
.packing-detail-head p { margin: 3px 0 0; color: var(--muted); }
.packing-scan-state {
  display: flex;
  gap: 9px;
  align-items: baseline;
  flex-wrap: wrap;
  margin: 12px 0 15px;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid var(--line);
}
.packing-scan-state span { color: var(--muted); }
.packing-scan-state.ready { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.packing-scan-state.waiting { border-color: #f6c768; background: #fffbeb; color: #92400e; }
.packing-scan-state.simple { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.packing-detail-panel .packing-checklist { grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)); }
.packing-detail-panel .packing-item-with-action { min-width: 0; }
.packing-complete-state { min-height: 360px; display: grid; place-items: center; text-align: center; }
.packing-complete-state strong { display: block; font-size: 28px; color: var(--success); }
.packing-complete-state p { color: var(--muted); max-width: 56ch; }

@media (max-width: 1080px) {
  .packing-final-layout { grid-template-columns: 1fr; }
  .packing-final-layout .packing-scan-panel { position: static; }
}
@media (max-width: 700px) {
  .packing-session-head, .packing-detail-head { flex-direction: column; align-items: stretch; }
  .packing-session-counter { text-align: left; }
  .packing-session-grid { grid-template-columns: 1fr; }
  .packing-final-layout .packing-scan-panel, .packing-final-layout .packing-result-panel { padding: 17px; }
}


/* v0.20.1 — stabilní velikost a kreslení v náhledu importu */
.preview {
  width: 100%;
  min-height: 420px;
  aspect-ratio: var(--preview-ratio, 1.414 / 1);
}
.preview svg {
  width: 100%;
  height: 100%;
  min-height: 420px;
  max-height: none;
  cursor: default;
}
.preview svg.mode-click .pdf-object:not(.source-frame) { cursor: pointer; }
.preview svg.mode-area,
.preview svg.mode-frame { cursor: crosshair; }
.preview svg.is-drawing { cursor: crosshair; }
#selection-box.visible { display: block; }
@media (max-width: 700px) {
  .preview, .preview svg { min-height: 320px; }
}

/* ========================================================================== 
   v0.21 — zoom náhledu, zvýraznění barev a individuální mapování cest
   ========================================================================== */
.editor-grid {
  grid-template-columns: minmax(0, 1.08fr) minmax(500px, .92fr);
  gap: 20px;
}
.preview-panel { min-width: 0; }
.preview {
  min-height: 360px;
  max-height: 64vh;
  aspect-ratio: auto;
  overflow: hidden;
  background: #e9eef5;
}
.preview svg {
  min-height: 360px;
  max-height: 64vh;
  width: 100%;
  height: 64vh;
}
.preview-toolbar { align-items: center; }
.toolbar-group { display: flex; flex-wrap: wrap; gap: 7px; }
.zoom-toolbar { margin-left: auto; flex-wrap: nowrap; }
.zoom-toolbar .tool { min-width: 42px; }
.zoom-toolbar .zoom-value { min-width: 74px; font-variant-numeric: tabular-nums; }
.settings-panel {
  min-width: 0;
  padding: 20px;
}
.settings-panel .actions {
  position: static;
  bottom: auto;
  margin-top: 22px;
  padding: 18px 0 4px;
  border-top: 1px solid var(--line);
  background: transparent;
}
.frame-card { scroll-margin-top: calc(var(--topbar-height) + 20px); }
.mapping-block {
  margin-top: 16px;
  padding-top: 4px;
}
.mapping-hint { margin: 5px 0 11px; }
.color-mappings {
  display: grid;
  gap: 7px;
}
.color-row {
  grid-template-columns: 26px 24px minmax(110px, .75fr) auto minmax(190px, 1.25fr);
  gap: 9px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid #edf1f6;
  border-radius: 12px;
  background: #fff;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.color-row:hover { border-color: #d8e2ef; background: #fbfdff; }
.color-row.highlight-active {
  border-color: #60a5fa;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}
.color-row-select { display: grid; place-items: center; }
.color-row-select input { width: 17px; height: 17px; margin: 0; }
.color-row-meta { min-width: 0; }
.color-row .show-color-paths { padding: 7px 10px; white-space: nowrap; }
.color-row .operation-select { margin: 0; min-height: 42px; }
.bulk-color-mapping {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 11px;
  padding: 11px;
  border: 1px dashed #cbd5e1;
  border-radius: 13px;
  background: #fafcff;
}
.bulk-color-mapping select { margin: 0; }
.object-remap-details {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #dbe4ef;
  border-radius: 14px;
  background: #fbfdff;
}
.object-remap-details summary { cursor: pointer; font-weight: 800; }
.object-remap-toolbar,
.object-remap-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.object-remap-count { color: var(--muted); font-weight: 750; }
.object-remap-actions select { flex: 1 1 240px; margin: 0; }
.object-override-summary { margin: 10px 0 0; }
.preview .pdf-object {
  transition: opacity .14s ease, filter .14s ease;
}
.preview .pdf-object.color-dimmed:not(.source-frame) { opacity: .09 !important; }
.preview .pdf-object.color-highlighted:not(.source-frame) {
  opacity: 1 !important;
  filter: drop-shadow(0 0 1px #f59e0b) drop-shadow(0 0 2px #f59e0b);
}
.preview .pdf-object.object-remap-selected:not(.source-frame) {
  opacity: 1 !important;
  filter: drop-shadow(0 0 1px #a855f7) drop-shadow(0 0 3px #a855f7);
}
.preview .pdf-object.object-operation-overridden:not(.source-frame) {
  filter: drop-shadow(0 0 1.4px var(--override-color, #7c3aed));
}
.preview .pdf-object.object-remap-selected.object-operation-overridden:not(.source-frame) {
  filter: drop-shadow(0 0 1px #a855f7) drop-shadow(0 0 3px #a855f7);
}
.preview svg.mode-remap .pdf-object:not(.source-frame) { cursor: crosshair; }
.preview svg.mode-remap .source-frame { pointer-events: none; }

@media (max-width: 1180px) {
  .editor-grid { grid-template-columns: 1fr; }
  .preview, .preview svg { max-height: 58vh; height: 58vh; }
  .settings-panel { position: static; max-height: none; }
}
@media (max-width: 760px) {
  .preview, .preview svg { min-height: 300px; height: 50vh; max-height: 50vh; }
  .panel-heading { align-items: stretch; }
  .preview-toolbar { width: 100%; }
  .zoom-toolbar { margin-left: 0; }
  .color-row { grid-template-columns: 25px 24px minmax(0,1fr) auto; }
  .color-row .operation-select { grid-column: 1 / -1; }
  .bulk-color-mapping { grid-template-columns: 1fr; }
  .bulk-color-mapping button { width: 100%; }
}


/* v0.21.1 — posouvání přiblíženého náhledu */
.preview svg.mode-pan,
.preview svg.space-pan-ready { cursor: grab; }
.preview svg.is-panning,
.preview svg.is-panning .pdf-object { cursor: grabbing !important; }
.preview svg.is-panning { user-select: none; }


/* ========================================================================== 
   v0.22 — přímé přebarvování cest a spolehlivý výběrový rám
   ========================================================================== */
.color-row {
  grid-template-columns: 24px 22px minmax(105px, .9fr) 22px 22px auto minmax(220px, 1.4fr);
  column-gap: 9px;
}
.color-map-arrow { color: #94a3b8; font-weight: 900; text-align: center; }
.operation-output-swatch {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, .22);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.34);
}
.operation-output-label {
  grid-column: 3 / -1;
  color: #64748b;
  font-size: 12px;
  padding-left: 1px;
  margin-top: -3px;
}
.direct-path-editor {
  display: block;
  border: 1px solid #cfe0f6;
  background: linear-gradient(180deg, #fbfdff, #f5f9ff);
  box-shadow: 0 5px 18px rgba(37, 99, 235, .055);
}
.direct-path-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}
.direct-path-heading h4 { margin: 0 0 4px; }
.direct-path-heading .hint { margin: 0; }
.direct-recolor-actions {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: end;
}
.direct-recolor-actions label { display: grid; gap: 4px; }
.direct-recolor-actions select { margin-top: 0; }
.preview .pdf-object.object-operation-overridden:not(.source-frame) { opacity: 1 !important; }
.preview .pdf-object.object-remap-selected:not(.source-frame) {
  filter: drop-shadow(0 0 1px #7c3aed) drop-shadow(0 0 4px #7c3aed) !important;
  stroke-width: 1.8 !important;
}
.preview .pdf-object.ignored:not(.source-frame) {
  opacity: 1 !important;
  stroke: #ff00b8 !important;
  fill: rgba(255, 0, 184, .24) !important;
  filter: drop-shadow(0 0 2px #ff00b8);
}
#selection-box.visible {
  display: block !important;
  fill: rgba(37, 99, 235, .18) !important;
  stroke: #2563eb !important;
  stroke-width: 2 !important;
  stroke-dasharray: 7 4 !important;
  vector-effect: non-scaling-stroke;
}
@media (max-width: 900px) {
  .color-row { grid-template-columns: 24px 22px minmax(100px, 1fr) 22px 22px auto; }
  .color-row .operation-select { grid-column: 2 / -1; }
  .operation-output-label { grid-column: 2 / -1; }
  .direct-recolor-actions { grid-template-columns: 1fr; }
}

/* ========================================================================== 
   v0.23 — přímá paleta cest, živý optimalizovaný náhled a stabilní výběr
   ========================================================================== */
.preview { position: relative; }
.preview-drag-overlay {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  border: 2px dashed #2563eb;
  background: rgba(37, 99, 235, .20);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.75), 0 5px 16px rgba(37,99,235,.18);
}
.preview-drag-overlay.hidden { display: none; }
.preview .layout-source-frame-hidden { opacity: 0 !important; }
.preview .frame-overlay.optimized-frame-overlay rect {
  stroke: #7c3aed;
  stroke-width: 1.7;
  stroke-dasharray: 7 3;
}
.preview .frame-overlay.optimized-frame-overlay text { fill: #6d28d9; }
.preview .frame-label-overlay {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 2.4px;
  vector-effect: non-scaling-stroke;
}

.manual-output-palette {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid #d8e4f2;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #f7fbff);
}
.manual-output-palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.manual-output-palette-head > div { display: grid; gap: 2px; }
.manual-output-palette-head span { color: var(--muted); font-size: 12px; }
.manual-palette-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.manual-palette-swatch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 9px 6px 7px;
  border: 1px solid #dce4ee;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.manual-palette-swatch:hover {
  border-color: #93c5fd;
  box-shadow: 0 5px 14px rgba(37,99,235,.09);
  transform: translateY(-1px);
}
.manual-palette-swatch.active { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.manual-palette-swatch i {
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  border-radius: 7px;
  border: 1px solid rgba(15,23,42,.24);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.manual-group-toolbar { margin-top: 2px; }
.manual-group-svg { background: #fff; }

@media (max-width: 700px) {
  .manual-output-palette-head { align-items: stretch; flex-direction: column; }
  .manual-palette-add { width: 100%; }
  .manual-palette-swatch span { display: none; }
  .manual-palette-swatch { padding: 6px; }
}
.direct-path-editor > summary {
  cursor: pointer;
  font-weight: 800;
  color: #334155;
  padding: 2px 0;
}
.direct-path-editor[open] > summary { margin-bottom: 12px; }
.direct-path-editor-body { display: grid; gap: 10px; }
