/* Kompaktný podnikový motív inšpirovaný usporiadaním TPV2000Plus.
   Ide o vlastnú podobu SysGAM, nie o kópiu grafiky alebo značky TPV Group. */
:root {
  --ink: #203247;
  --muted: #5b6d7f;
  --line: #bdcbd8;
  --paper: #e8eef3;
  --brand: #28587e;
  --accent: #d88931;
  --ok: #2b754d;
  --bad: #a93632;
  --erp-dark: #183b5c;
  --erp-blue: #346994;
  --erp-pale: #eef4f9;
  --erp-head: #dbe7f0;
}

body { background: var(--paper); color: var(--ink); font: 13px/1.45 "Segoe UI", Tahoma, sans-serif; }
.skip-link { position: absolute; top: -48px; left: 12px; z-index: 100; background: #fff; padding: 8px 12px; }
.skip-link:focus { top: 8px; }

header.app-header { display: block; padding: 0; min-height: 0; background: var(--erp-head); border-bottom: 1px solid #9fb5c9; }
.app-topbar { min-height: 49px; display: flex; align-items: center; gap: 20px; padding: 0 24px; background: linear-gradient(180deg, #e4f0f9, #bad3e7); color: #214a6a; border-bottom: 1px solid #91aec5; }
.app-topbar .brand { color: #1e4c70; font-size: 20px; letter-spacing: .015em; white-space: nowrap; }
.app-topbar .brand small { color: #577c99; font-size: 11px; letter-spacing: .1em; }
.app-suite-label { color: #5b7892; font-size: 11px; font-weight: 600; letter-spacing: .12em; }
.app-topbar .account { display: flex; gap: 13px; align-items: center; margin-left: auto; color: #214a6a; white-space: nowrap; }
.app-topbar .account span::before { content: "●"; color: #298254; margin-right: 8px; font-size: 9px; }
.app-topbar .account a { color: #214a6a; text-decoration: underline; text-underline-offset: 2px; }
header.app-header nav.module-nav { display: flex; gap: 0; align-items: stretch; min-height: 39px; padding: 0 20px; overflow-x: auto; background: linear-gradient(180deg, #f7fafc, #dfe9f1); }
.module-nav a { flex: none; display: inline-flex; align-items: center; padding: 8px 15px; border-right: 1px solid #c4d1dc; color: #254b6c; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.module-nav a:first-child { border-left: 1px solid #c4d1dc; }
.module-nav a:hover { background: #e7f1f9; }
.module-nav a.is-active { color: #153e62; background: #fff; box-shadow: inset 0 3px var(--erp-blue); }

main { width: 100%; max-width: none; min-width: 0; min-height: calc(100dvh - 140px); margin: 0; padding: 16px clamp(12px, 1.25vw, 32px) 24px; background: #fff; }
.page-heading { display: flex; flex-direction: column; gap: 3px; padding: 0 0 13px; margin: 0 0 20px; border-bottom: 2px solid #7a9db9; }
.page-heading > span { color: #61778a; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
h1 { margin: 0; color: #173e60; font-size: 23px; line-height: 1.2; }
h2 { margin: 22px 0 10px; color: #234c6e; font-size: 17px; }
.lead { margin-top: 0; }
footer { color: #587087; font-size: 11px; }

.card, .table-wrap, .tree-order, .item-result, .ready-row { border: 1px solid var(--line); border-radius: 3px; background: #fff; box-shadow: none; }
.card { padding: 16px; }
.flash { border: 1px solid #a7cdb4; border-left: 4px solid var(--ok); border-radius: 2px; background: #edf8ef; padding: 9px 12px; }
.flash.error { border-color: #e2aaa7; border-left-color: var(--bad); background: #fff2f0; }
label { color: #344e67; font-size: 12px; font-weight: 600; }
label span { line-height: 1.3; }
label small, .search-help { color: #607487; font-weight: 400; }
input, select, button { min-height: 34px; padding: 6px 9px; border: 1px solid #9db1c3; border-radius: 2px; background: #fff; color: var(--ink); font-size: 13px; }
input:focus, select:focus { outline: 2px solid #72a7d0; outline-offset: 1px; border-color: #467fae; }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 6px 12px; border: 1px solid #214e72; border-radius: 2px; background: linear-gradient(180deg, #3c78a4, #285b83); color: #fff; font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; box-shadow: inset 0 1px #ffffff4d; }
button:hover, .button:hover { background: linear-gradient(180deg, #4c89b5, #306b99); }
button:focus-visible, .button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #df9b3f; outline-offset: 2px; }
.button.secondary { border: 1px solid #8ca8bf; color: #285577; background: linear-gradient(180deg, #fff, #e8f0f6); box-shadow: inset 0 1px #fff; }
.button.secondary:hover { background: #dcebf5; }
.form-grid { gap: 13px 18px; }
.narrow label + label { margin-top: 12px; }
.narrow button { margin-top: 14px; }

.metrics { gap: 10px; }
.metrics article { min-height: 90px; padding: 12px 15px; border: 1px solid #b7cad9; border-top: 3px solid #4a81aa; border-left-width: 1px; border-radius: 2px; background: linear-gradient(180deg, #f5f9fc, #e9f1f7); }
.metrics strong { color: #214d71; font-size: 28px; line-height: 1.2; }
.metrics span { color: #4e6579; font-size: 12px; }
.table-wrap { overflow: auto; }
table { width: 100%; font-size: 12px; }
th, td { padding: 6px 9px; border-right: 1px solid #e3eaf0; border-bottom: 1px solid #d4dfe8; }
th:last-child, td:last-child { border-right: 0; }
th { position: sticky; top: 0; z-index: 1; background: linear-gradient(180deg, #e6eef5, #d7e3ed); color: #324f68; font-size: 11px; font-weight: 700; }
tbody tr:nth-child(even) { background: #f4f8fb; }
tbody tr:hover { background: #e8f3fa; }

.dispatch-filter { padding: 11px 14px; }
.dispatch-filter label { min-width: 220px; }
.result-count { color: #566f84; font-size: 12px; }
.tree-controls { margin-bottom: 10px; }
.tree-order { overflow: hidden; }
.tree-order > summary { padding: 10px 13px; border-bottom: 1px solid #b8cad9; background: linear-gradient(180deg, #edf4f9, #dceaf4); }
.tree-order > summary strong { color: #214b70; font-size: 14px; }
.tree-order-contents { padding: 3px 9px 10px; }
.tree-order-actions { padding: 8px 12px 0; }
.tree-part { margin: 5px 0 0 8px; border-left-color: #a7c3d8; }
.tree-part > summary { padding: 6px 8px; border-bottom: 1px solid #ecf1f5; }
.tree-part-title strong { color: #254f73; }
.tree-count, .tree-drawing { font-size: 11px; }
.tree-operation { padding: 7px 9px; margin: 4px 0 4px 8px; border-left: 3px solid #5e8db1; border-radius: 2px; background: #fbfdff; }
.tree-operation-main strong { font-size: 12px; }
.tree-operation-data { font-size: 11px; }
.status { padding: 3px 8px; border: 1px solid #b6cbd9; border-radius: 2px; background: #eaf2f7; color: #285777; font-size: 11px; font-weight: 700; }

.item-search-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px 14px; width: 100%; max-width: none; padding: 12px; }
.item-search-form label { min-width: 0; }
.item-search-form input, .item-search-form select { width: 100%; }
.item-search-actions { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 9px; border-top: 1px solid #d7e2eb; }
.item-search-actions small { margin-left: auto; color: var(--muted); }
.item-results-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 15px 0 7px; color: #244d6d; }
.item-results-heading strong { font-size: 15px; }
.item-results-heading span { color: var(--muted); font-size: 12px; }
.item-table-scroll { height: clamp(240px, calc(100dvh - 360px), 1200px); min-width: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.item-table { min-width: 1280px; table-layout: fixed; white-space: normal; }
.item-table th, .item-table td { padding: 7px 6px; vertical-align: middle; overflow-wrap: anywhere; }
.item-table th { overflow-wrap: normal; }
.item-table th:nth-child(1) { width: 10.5%; }
.item-table th:nth-child(2) { width: 14%; }
.item-table th:nth-child(3) { width: 6%; }
.item-table th:nth-child(4), .item-table th:nth-child(5) { width: 8.5%; }
.item-table th:nth-child(6) { width: 8%; }
.item-table th:nth-child(7) { width: 3%; }
.item-table th:nth-child(8) { width: 6%; }
.item-table th:nth-child(9), .item-table th:nth-child(10) { width: 5%; }
.item-table th:nth-child(11) { width: 3.5%; }
.item-table th:nth-child(12) { width: 6%; }
.item-table th:nth-child(13), .item-table th:nth-child(14) { width: 5%; }
.item-table th:nth-child(15) { width: 6%; }
.item-table .item-code { color: #214e72; font: 700 12px/1.4 Consolas, "Segoe UI", monospace; }
.item-table .item-number { text-align: right; font-variant-numeric: tabular-nums; }
.item-table th:first-child, .item-table td:first-child { position: sticky; left: 0; border-right: 2px solid #9eb8cc; }
.item-table th:last-child, .item-table td:last-child { position: sticky; right: 0; border-left: 2px solid #9eb8cc; }
.item-table th:first-child, .item-table th:last-child { z-index: 3; }
.item-table td:first-child, .item-table td:last-child { z-index: 2; background: #fff; }
.item-table tbody tr:nth-child(even) td:first-child, .item-table tbody tr:nth-child(even) td:last-child { background: #f4f8fb; }
.item-table tbody tr:hover td:first-child, .item-table tbody tr:hover td:last-child { background: #e8f3fa; }
.item-table .button { min-height: 27px; padding: 3px 7px; }
.item-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); }
.ready-search-form { max-width: none; }
.ready-table { min-width: 1280px; }
.ready-table th:nth-child(1) { width: 8%; }
.ready-table th:nth-child(2) { width: 4.5%; }
.ready-table th:nth-child(3) { width: 11%; }
.ready-table th:nth-child(4) { width: 13%; }
.ready-table th:nth-child(5) { width: 4.5%; }
.ready-table th:nth-child(6) { width: 11%; }
.ready-table th:nth-child(7) { width: 8%; }
.ready-table th:nth-child(8), .ready-table th:nth-child(9) { width: 4%; }
.ready-table th:nth-child(10) { width: 4.5%; }
.ready-table th:nth-child(11) { width: 7.5%; }
.ready-table th:nth-child(12) { width: 9.5%; }
.ready-table th:nth-child(13) { width: 4.5%; }
.ready-table th:nth-child(14) { width: 6%; }
.ready-barcode { color: #214e72; font: 12px/1.4 Consolas, "Segoe UI", monospace; }
.ready-table .status { white-space: nowrap; }
.ready-table td:nth-child(13) a { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.item-results { gap: 0; border: 1px solid var(--line); }
.item-result { gap: 12px; padding: 7px 10px; border: 0; border-bottom: 1px solid #d6e1e9; border-radius: 0; }
.item-result:last-child { border-bottom: 0; }
.item-result:nth-child(even) { background: #f4f8fb; }
.item-result:hover { background: #eaf4fb; }
.item-result > div { display: grid; grid-template-columns: minmax(170px, 210px) minmax(200px, 1fr); align-items: center; gap: 3px 12px; flex: 1; }
.item-result small { grid-column: 1 / -1; overflow-wrap: anywhere; }
.item-result strong { font-family: Consolas, "Segoe UI", monospace; font-size: 12px; }
.item-result .button { min-height: 29px; padding: 4px 11px; }
.item-edit-form { border-top: 3px solid #4f83a9; }
.item-section { border: 1px solid #c3d2df; padding: 12px 14px 15px; margin-bottom: 15px; background: #fbfdff; }
.item-section legend { padding: 0 7px; color: #24547a; font-size: 13px; }
.item-advanced { padding: 8px 14px 14px; border: 1px solid #c3d2df; background: #fbfdff; }
.item-advanced summary { color: #24547a; font-size: 13px; }
.item-readonly { padding: 10px 12px; border: 1px solid #d0dce6; background: #f1f5f8; }
.item-form-actions { justify-content: flex-end; padding-top: 12px; border-top: 1px solid #d2dfe8; }

.ready-list { gap: 0; border: 1px solid var(--line); }
.ready-row { padding: 8px 10px; border: 0; border-bottom: 1px solid #d8e1e9; border-radius: 0; }
.ready-row:nth-child(even) { background: #f5f9fc; }
.ready-row .priority { color: #a76322; font-size: 14px; }
.ready-main strong { color: #214d70; font-size: 13px; }
.operation { margin: 14px 0; padding: 13px 16px; border: 1px solid #b9cbd9; border-left: 4px solid #d88931; background: #f7fafc; }
.operation h2 { font-size: 18px; }
.terminal-actions { gap: 10px; }
.terminal-actions button { min-height: 39px; }
.terminal-actions .start { background: linear-gradient(180deg, #358a5b, #236b45); border-color: #205d3d; }
.terminal-actions .pause { background: linear-gradient(180deg, #c7833f, #a76329); border-color: #995820; }
.terminal-actions .finish { background: linear-gradient(180deg, #4c78aa, #315b8c); border-color: #284f7c; }

/* Výrobný terminál: veľké dotykové plochy a samostatný panel na odvádzanie kusov. */
.terminal-shell { width: 100%; max-width: 1600px; margin-inline: auto; }
.terminal-page { padding-top: 12px; }
.terminal-page .page-heading { padding-bottom: 7px; margin-bottom: 11px; }
.terminal-page .page-heading h1 { font-size: 20px; }
.terminal-toolbar { align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px; }
.terminal-toolbar .scan { max-width: none; min-width: 0; }
.terminal-toolbar .scan input { min-width: 0; min-height: 42px; font: 600 17px/1.3 Consolas, "Segoe UI", monospace; }
.terminal-toolbar .scan button, .terminal-toolbar > .button { min-height: 42px; }
.terminal-empty { margin: 16px 0; }
.terminal-ticket { margin: 9px 0; padding: 0; overflow: hidden; border-top: 3px solid #4e82a9; }
.terminal-ticket-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 13px; background: #e9f2f8; border-bottom: 1px solid #c9d9e5; }
.terminal-eyebrow { color: #52718b; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.terminal-ticket-heading h2 { margin: 1px 0 0; font-size: 18px; }
.terminal-ticket-heading .status { flex: none; }
.terminal-ticket-details { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0; }
.terminal-ticket-details > div { min-width: 0; padding: 6px 12px; border-right: 1px solid #d8e3eb; border-bottom: 1px solid #d8e3eb; }
.terminal-ticket-details > div:last-child { border-right: 0; }
.terminal-ticket-details dt { color: #607789; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.terminal-ticket-details dd { margin: 2px 0 0; overflow-wrap: anywhere; font-weight: 700; }
.terminal-quantity-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: #f4f8fb; }
.terminal-quantity-summary > div { display: flex; flex-direction: column; gap: 2px; padding: 7px 12px; border-right: 1px solid #d8e3eb; }
.terminal-quantity-summary > div:last-child { border-right: 0; }
.terminal-quantity-summary span { color: #4d657a; font-size: 11px; font-weight: 600; }
.terminal-quantity-summary strong { color: #204968; font-size: 21px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.terminal-quantity-summary .terminal-remaining { background: #e3f1f8; }
.terminal-quantity-summary .terminal-remaining strong { color: #135d82; }
.terminal-step-hint { padding: 8px 11px; margin: 9px 0; border-left: 3px solid #d88931; background: #fff8e9; color: #634827; }
.terminal-worker-picker { display: grid; grid-template-columns: minmax(260px, 1fr) auto; align-items: end; gap: 7px 12px; margin: 9px 0; padding: 10px 12px; border-left: 4px solid #d88931; }
.terminal-worker-picker label { min-width: 0; }
.terminal-worker-picker select { width: 100%; }
.terminal-worker-picker small { grid-column: 1 / -1; color: #607487; }
.terminal-drawing { margin: 9px 0 12px; padding: 0; overflow: hidden; }
.terminal-drawing summary { padding: 8px 12px; cursor: pointer; background: #e8f1f8; color: #214e70; font-weight: 700; }
.terminal-drawing-actions { padding: 6px 12px; text-align: right; border-top: 1px solid #c6d7e4; }
.terminal-drawing-actions a { color: #285b83; font-size: 12px; font-weight: 600; }
.terminal-drawing iframe { display: block; width: 100%; height: clamp(360px, 54vh, 620px); border: 0; border-top: 1px solid #c6d7e4; background: #eef3f6; }
.terminal-drawing-empty { margin: 9px 0 12px; padding: 10px 12px; color: #607487; }
.terminal-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "report keypad" "other other"; align-items: start; gap: 12px; }
.terminal-report-form { grid-area: report; padding: 0; overflow: hidden; }
.terminal-panel-heading { padding: 8px 12px; border-bottom: 1px solid #c6d7e4; background: #e8f1f8; }
.terminal-panel-heading h3 { margin: 0; color: #214e70; font-size: 15px; }
.terminal-panel-heading span { display: block; margin-top: 2px; color: #5c7387; font-size: 11px; }
.terminal-report-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 10px 12px; }
.terminal-report-fields label { min-width: 0; font-size: 13px; }
.terminal-report-fields input { width: 100%; height: 54px; text-align: center; font-size: 27px; font-weight: 700; font-variant-numeric: tabular-nums; }
.terminal-report-fields .keypad-target input { border: 2px solid #317cad; background: #f1f9ff; box-shadow: 0 0 0 3px #b7d9ee; }
.terminal-report-fields small { min-height: 18px; }
.terminal-note { margin: 0 12px 8px; border: 1px solid #d1e0ea; }
.terminal-note summary { padding: 5px 9px; color: #345d7a; cursor: pointer; font-size: 12px; font-weight: 600; }
.terminal-note label { padding: 0 9px 8px; }
.terminal-note input { width: 100%; }
.terminal-report-buttons { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; padding: 9px 12px; border-top: 1px solid #d3e0ea; background: #f5f8fb; }
.terminal-report-buttons button { min-height: 54px; font-size: 15px; }
.terminal-report-buttons .finish { border-color: #284f7c; background: linear-gradient(180deg, #4c78aa, #315b8c); }
.terminal-report-buttons .finish:hover { background: #35699d; }
.terminal-keypad { grid-area: keypad; padding: 0 0 12px; overflow: hidden; }
.terminal-keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 12px; }
.terminal-keypad-grid button { min-height: 60px; padding: 0; border: 1px solid #a4b8c9; background: linear-gradient(180deg, #fff, #dce8f0); color: #213e58; font-size: 24px; font-weight: 600; box-shadow: 0 2px 1px #7690a03b; touch-action: manipulation; }
.terminal-keypad-grid button:hover { background: #d4e8f6; }
.terminal-keypad-grid button:active { background: #b5d2e6; box-shadow: inset 0 2px 3px #50718a66; }
.terminal-keypad-clear { width: calc(100% - 24px); margin: 0 12px; }
.terminal-other-actions { grid-area: other; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.terminal-other-actions form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px 12px; }
.terminal-other-actions h3 { grid-column: 1 / -1; margin: 0; color: #2a526f; font-size: 14px; }
.terminal-other-actions label { min-width: 0; }
.terminal-other-actions input, .terminal-other-actions select { width: 100%; }
.terminal-other-actions .terminal-pause-form { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
.terminal-other-actions button { min-height: 45px; font-size: 13px; }
.terminal-other-actions .start { border-color: #205d3d; background: linear-gradient(180deg, #358a5b, #236b45); }
.terminal-other-actions .pause { border-color: #995820; background: linear-gradient(180deg, #c7833f, #a76329); }

@media (max-width: 1080px) {
  .terminal-ticket-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .terminal-ticket-details > div:nth-child(2) { border-right: 0; }
  .terminal-workspace { grid-template-columns: minmax(0, 1fr) 285px; }
  .terminal-other-actions form, .terminal-other-actions .terminal-pause-form { display: flex; flex-direction: column; align-items: stretch; }
}
@media (max-width: 740px) {
  .terminal-toolbar { flex-direction: column; align-items: stretch; }
  .terminal-toolbar .scan { width: 100%; }
  .terminal-ticket-details, .terminal-quantity-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .terminal-quantity-summary > div:nth-child(2) { border-right: 0; }
  .terminal-worker-picker { grid-template-columns: 1fr; }
  .terminal-worker-picker small { grid-column: auto; }
  .terminal-drawing-actions { text-align: left; }
  .terminal-drawing iframe { height: 420px; }
  .terminal-workspace { grid-template-columns: 1fr; grid-template-areas: "report" "keypad" "other"; }
  .terminal-keypad-grid button { min-height: 66px; }
}
@media (max-width: 500px) {
  .terminal-ticket-heading { align-items: flex-start; }
  .terminal-ticket-heading h2 { font-size: 17px; }
  .terminal-ticket-details > div { padding: 8px 10px; }
  .terminal-quantity-summary > div { padding: 9px 10px; }
  .terminal-quantity-summary strong { font-size: 20px; }
  .terminal-report-fields { gap: 8px; padding: 10px; }
  .terminal-report-fields input { font-size: 24px; }
  .terminal-report-buttons { grid-template-columns: 1fr; }
  .terminal-other-actions { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  main { border: 0; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-search-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-result > div { grid-template-columns: minmax(145px, 190px) 1fr; }
}
@media (max-width: 650px) {
  .app-topbar { flex-wrap: wrap; gap: 4px 10px; padding: 8px 12px; }
  .app-suite-label { display: none; }
  header.app-header nav.module-nav { padding: 0 5px; }
  .module-nav a { padding: 8px 11px; }
  main { padding: 14px 11px 35px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-search-form { grid-template-columns: 1fr; }
  .item-search-actions { align-items: stretch; flex-direction: column; }
  .item-search-actions small { margin-left: 0; }
  .item-result > div { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
  .item-result .button { align-self: flex-start; }
  .item-form-actions { align-items: stretch; }
}

/* Pracovná plocha 16:9: horný blok filtrov a výsledky vo zvyšku okna.
   Pri menšom okne / väčšom zoome sa obnoví bežné posúvanie celej stránky. */
@media screen and (min-width: 1000px) and (min-height: 650px) {
  body:has(main.results-page) { height: 100dvh; display: flex; flex-direction: column; }
  body:has(main.results-page) > header, body:has(main.results-page) > footer { flex: 0 0 auto; }
  body:has(main.results-page) > footer { padding: 7px 12px; }
  main.results-page { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; padding-bottom: 10px; }
  .results-page > :not(.item-table-scroll) { flex-shrink: 0; }
  .results-page .page-heading { padding-bottom: 9px; margin-bottom: 12px; }
  .results-page .item-results-heading { margin: 10px 0 6px; }
  .results-page .item-table-scroll { flex: 1 1 0; height: auto; min-height: 160px; }
  .results-page .item-pagination { flex: 0 0 auto; margin: 7px 0 0; }
  .results-page .item-search-form label { gap: 4px; }
  .results-page .item-search-actions { padding-top: 7px; }
}
@media screen and (min-width: 1600px) {
  body { font-size: 14px; }
  table { font-size: 13px; }
  .item-table .item-code, .ready-barcode { font-size: 13px; }
  .item-table th, .item-table td { padding: 8px; }
  .item-edit-form { max-width: none; }
  .item-edit-form .form-grid { max-width: none; grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.routing-filters { display: grid; grid-template-columns: minmax(240px, 1.5fr) minmax(190px, 1fr) minmax(190px, .8fr); gap: 9px 14px; width: 100%; padding: 12px; }
.routing-filters input:not([type="checkbox"]), .routing-filters select { width: 100%; min-width: 0; }
.routing-filters .check { align-self: end; min-height: 34px; }
.routing-guidance { margin-top: 10px; padding: 8px 11px; border-left: 3px solid #7a9db9; background: #f0f5f9; color: #46627a; font-size: 12px; }
.routing-root-list table { min-width: 780px; white-space: normal; }
.routing-root-list td:nth-child(2) { width: 45%; }
.routing-code { font-family: Consolas, "Segoe UI", monospace; font-weight: 700; }
.routing-tree { min-width: 0; overflow: auto; contain: layout paint; overscroll-behavior: contain; scrollbar-gutter: stable; border: 1px solid var(--line); padding: 6px 8px 12px; background: #fafcfe; }
.routing-node { margin: 7px 0 0 12px; border: 1px solid #c3d3df; border-left: 3px solid #9ab9d0; background: #fff; }
.routing-tree > .routing-node { margin-left: 0; }
.routing-node > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 11px; background: #edf4f9; cursor: pointer; list-style: none; }
.routing-node > summary::-webkit-details-marker { display: none; }
.routing-node > summary::before { content: '▸'; color: var(--brand); }
.routing-node[open] > summary::before { content: '▾'; }
.routing-node-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 10px; flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.routing-node-title strong { color: #214e72; font: 700 13px/1.4 Consolas, "Segoe UI", monospace; }
.routing-node-count, .routing-node-quantity { color: #5b7387; font-size: 11px; }
.routing-node-body { padding: 7px 8px 9px; }
.routing-operation-table { min-width: 1050px; table-layout: fixed; white-space: normal; }
.routing-operation-table th, .routing-operation-table td { padding: 5px 6px; vertical-align: middle; overflow-wrap: anywhere; }
.routing-operation-table th:nth-child(1) { width: 7%; }
.routing-operation-table th:nth-child(2) { width: 21%; }
.routing-operation-table th:nth-child(3) { width: 6%; }
.routing-operation-table th:nth-child(4) { width: 15%; }
.routing-operation-table th:nth-child(5) { width: 11%; }
.routing-operation-table th:nth-child(6) { width: 26%; }
.routing-operation-table th:nth-child(7) { width: 14%; }
.routing-operation-table input:not([type="checkbox"]), .routing-operation-table select { width: 100%; min-width: 0; }
.routing-used { color: #6b7480; font-size: 11px; }
.routing-operation-table .check { font-size: 11px; flex-direction: row; gap: 5px; }
.routing-no-operations { margin: 3px 0 8px; color: var(--muted); font-size: 12px; }
.routing-add { border: 1px dashed #a9bfce; margin-top: 8px; padding: 7px 10px; background: #f7fbfd; }
.routing-add > summary { color: var(--brand); cursor: pointer; font-weight: 600; }
.routing-add-fields { display: grid; grid-template-columns: 75px minmax(165px,1.1fr) 70px minmax(130px,.8fr) minmax(120px,.6fr) minmax(165px,1.3fr); gap: 9px; margin: 10px 0 6px; }
.routing-add-fields input, .routing-add-fields select { width: 100%; min-width: 0; }
.routing-add small { color: var(--muted); }
.routing-save-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 7px 14px; margin-top: 8px; }
.routing-save-actions small { color: var(--muted); margin-right: auto; font-size: 11px; }
.routing-marked-delete { opacity: .6; background: #fff0ed !important; }
.routing-focused { border-left-color: #d88931; }
@media screen and (min-width: 1000px) and (min-height: 650px) {
  .results-page .routing-tree { flex: 1 1 0; min-height: 160px; }
  .routing-page .tree-controls { margin-bottom: 7px; }
}
@media (max-width: 900px) {
  .routing-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .routing-filters .check { grid-column: 1/-1; }
  .routing-add-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .routing-tree { max-height: 70dvh; }
}
@media (max-width: 650px) {
  .routing-filters, .routing-add-fields { grid-template-columns: 1fr; }
  .routing-node-title { min-width: 0; flex-basis: 90%; }
  .routing-node { margin-left: 6px; }
  .routing-node-body { padding: 5px; }
}
@media print {
  body, main { background: #fff; }
  header.app-header, .skip-link, footer, button, .button, .tree-controls { display: none !important; }
  main { border: 0; max-width: none; padding: 0; }
  .card, .tree-order, .table-wrap { box-shadow: none; }
  .item-table-scroll { height: auto; overflow: visible; }
  .item-table { min-width: 0; }
  .item-table th:first-child, .item-table th:last-child, .item-table td:first-child, .item-table td:last-child { position: static; }
  .routing-tree { overflow: visible; max-height: none; }
  .routing-filters, .routing-save-actions, .routing-add { display: none; }
  th { position: static; }
}
/* PDF import and approval use the same compact, wide ERP controls. */
.routing-approval-form{display:inline-flex;margin:0;flex:0 0 auto}
.routing-approval-form button{white-space:nowrap;padding:5px 9px;min-height:28px}
.routing-approved{color:#13623b;font-weight:600;white-space:nowrap}
.routing-unapproved{color:#8c5d17;white-space:nowrap}
.routing-operation-table td small{display:block;font-size:10px;color:#57738d}
.import-controls{display:grid;gap:12px;margin-bottom:12px}
.import-controls p{margin:0;overflow-wrap:anywhere}
.import-controls form{margin:0;align-items:end;flex-wrap:wrap}
.import-controls .check{max-width:650px}
.import-inline{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;margin:5px}
.import-preview{margin-top:12px;overflow-wrap:anywhere}
.import-table-scroll{max-height:55vh;overflow:auto}
.import-table-scroll thead{position:sticky;top:0;z-index:1}
.import-monitor{margin:12px 0;padding:10px 12px}
.import-monitor article{border-top:1px solid #c8d8e5;padding:8px 0;overflow-wrap:anywhere}
.import-monitor [data-batch-list]{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:8px 14px}
.import-monitor [data-batch-link]{text-decoration:none}
.import-controls .import-filters label:first-of-type{flex:0 1 160px}
.import-monitor progress{width:min(500px,100%);height:12px;margin:5px 0;accent-color:#286591}
.import-monitor p{margin:4px 0}
.import-monitor [hidden]{display:none!important}
.import-table-scroll td{overflow-wrap:anywhere}
.import-table-scroll [data-file-info]{display:block;color:#58718a;max-width:330px;font-size:11px}
.import-table-scroll [data-file-error]{max-width:370px;white-space:normal}

/* Jedno-oknová kontrola technológa: fronta, výkres a údaje zostávajú vedľa seba. */
.routing-review-page { padding-bottom: 12px; }
.routing-review-topbar { display: grid; grid-template-columns: minmax(230px,auto) minmax(180px,1fr) auto; align-items: center; gap: 12px; margin-bottom: 10px; padding: 9px 12px; border: 1px solid #b8cbd9; background: #eef5fa; }
.routing-review-topbar > div { display: flex; flex-direction: column; }
.routing-review-topbar span { color: var(--muted); font-size: 12px; }
.routing-review-topbar progress { width: 100%; height: 13px; accent-color: #26704d; }
.routing-review-layout { display: grid; grid-template-columns: minmax(190px,235px) minmax(430px,1.05fr) minmax(570px,1.2fr); gap: 10px; height: calc(100dvh - 205px); min-height: 560px; }
.routing-review-queue,.routing-review-pdf,.routing-review-form { min-width: 0; min-height: 0; border: 1px solid #b8cbd9; background: #fff; }
.routing-review-queue { overflow: auto; }
.routing-review-queue h2 { position: sticky; top: 0; z-index: 2; margin: 0; padding: 9px 10px; border-bottom: 1px solid #c5d4df; background: #e7f0f7; font-size: 14px; }
.routing-review-queue-item { display: grid; grid-template-columns: 23px minmax(0,1fr) auto; gap: 7px; align-items: start; padding: 9px 8px; border-bottom: 1px solid #dde6ed; color: #243f57; text-decoration: none; }
.routing-review-queue-item:hover { background: #f3f8fb; }
.routing-review-queue-item.is-active { background: #dcebf6; box-shadow: inset 3px 0 #24628f; }
.routing-review-queue-item strong,.routing-review-queue-item small { display: block; overflow-wrap: anywhere; }
.routing-review-queue-item strong { font: 700 11px/1.35 Consolas,"Segoe UI",monospace; }
.routing-review-queue-item small { margin-top: 2px; color: #5a7185; font-size: 10px; }
.routing-review-queue-item em { color: #718394; font-size: 10px; font-style: normal; }
.routing-review-state { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: #fff1d8; color: #8c5d17; font-weight: 800; }
.routing-review-state.is-approved { background: #dff3e7; color: #16633e; }
.routing-review-pdf { display: flex; flex-direction: column; overflow: hidden; background: #59636c; }
.routing-review-pdf header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 47px; padding: 7px 9px; border-bottom: 1px solid #a9bbc9; background: #eef4f8; }
.routing-review-pdf header div { display: flex; flex-direction: column; min-width: 0; }
.routing-review-pdf header small { color: #587087; overflow-wrap: anywhere; }
.routing-review-pdf iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
.routing-review-no-pdf { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 24px; color: #fff; text-align: center; }
.routing-review-no-pdf span { color: #e3e8ec; }
.routing-review-form { display: flex; flex-direction: column; overflow: auto; }
.routing-review-section { padding: 11px 12px; border-bottom: 1px solid #cfdae3; }
.routing-review-section h3 { margin: 0 0 8px; color: #244f71; font-size: 14px; }
.routing-review-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.routing-review-heading span { color: #60778b; font-size: 11px; }
.routing-review-heading h2 { margin: 2px 0 9px; color: #214e72; font-size: 16px; overflow-wrap: anywhere; }
.routing-review-badge { flex: none; padding: 4px 7px; border: 1px solid #deb777; background: #fff5df; color: #805616!important; font-weight: 700; }
.routing-review-badge.is-approved { border-color: #8fc4a6; background: #e6f5ec; color: #16633e!important; }
.routing-review-data { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px 12px; margin: 0; }
.routing-review-data div { min-width: 0; }
.routing-review-data dt { color: #667d91; font-size: 10px; text-transform: uppercase; }
.routing-review-data dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.routing-review-evidence { margin: 9px 0 0; padding: 7px 9px; border-left: 3px solid #6e97b5; background: #f1f6f9; font-size: 11px; }
.routing-review-warnings { margin: 9px 0 0; font-size: 11px; }
.routing-review-warnings ul { margin: 5px 0 0; padding-left: 18px; }
.routing-review-bom { max-height: 190px; }
.routing-review-bom table { min-width: 520px; white-space: normal; }
.routing-review-bom th,.routing-review-bom td { padding: 5px 7px; }
.routing-review-bom td small { display: block; color: #60768a; }
.routing-review-operation-scroll { max-height: 330px; }
.routing-review-operation-scroll .routing-operation-table { min-width: 920px; }
.routing-review-form .routing-add-fields { grid-template-columns: 65px minmax(150px,1fr) 65px minmax(125px,.9fr) minmax(100px,.7fr) minmax(150px,1.1fr); }
.routing-review-actions { position: sticky; bottom: 0; z-index: 4; display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; padding: 10px 12px; border-top: 1px solid #9fb5c7; background: #eaf2f7; box-shadow: 0 -4px 12px #17334b18; }
.routing-review-actions button:last-child { background: #176946; }
@media(max-width:1250px) {
  .routing-review-layout { grid-template-columns: 190px minmax(380px,1fr) minmax(480px,1.1fr); }
}
@media(max-width:1000px) {
  .routing-review-layout { grid-template-columns: 180px minmax(0,1fr); height: auto; }
  .routing-review-queue { grid-row: 1/3; max-height: 900px; }
  .routing-review-pdf { height: 62dvh; min-height: 430px; }
  .routing-review-form { overflow: visible; }
  .routing-review-actions { position: sticky; }
}
@media(max-width:700px) {
  .routing-review-topbar { grid-template-columns: 1fr; }
  .routing-review-layout { display: flex; flex-direction: column; min-height: 0; }
  .routing-review-queue { max-height: 230px; order: 1; }
  .routing-review-pdf { height: 58dvh; min-height: 380px; order: 2; }
  .routing-review-form { order: 3; }
  .routing-review-data { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .routing-review-form .routing-add-fields { grid-template-columns: 1fr; }
  .routing-review-actions { flex-wrap: wrap; }
  .routing-review-actions > * { flex: 1 1 150px; }
}
