/* Objednávka ETERNAL – styl „vzorník barev v prodejním terminálu“ */
:root {
  --paper: #EFF1EE;
  --card: #FFFFFF;
  --ink: #1A1D1B;
  --muted: #6A716C;
  --line: #D6DAD5;
  --line-strong: #B9BFB9;
  --accent: #1E4DB0;
  --accent-ink: #FFFFFF;
  --order: #F5D64E;
  --order-soft: #FBF0BF;
  --warn: #B4321E;
  --ok: #2C7A4B;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 6px;
  --top-h: 52px;
  --sum-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--paper);
  padding-bottom: var(--sum-h);
}
button, input { font: inherit; color: inherit; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 4px; background: #fff; color: var(--muted);
}
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--order); box-shadow: inset 0 0 0 3px #1A1D1B, 0 0 0 2px var(--order); }
.brand h1 { margin: 0; font-family: var(--cond); font-weight: 600; font-size: 19px; letter-spacing: .01em; white-space: nowrap; }
.brand h1 span { font-weight: 700; letter-spacing: .06em; }
.brand-meta { font-family: var(--mono); font-size: 12px; color: #B8BEB9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid transparent; background: #fff; color: var(--ink); cursor: pointer; font-weight: 500;
  white-space: nowrap; transition: background .12s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--order); color: var(--ink); font-weight: 600; }
.btn.primary:hover { background: #F0CB2E; }
.btn.primary[disabled] { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.28); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.1); }
.main .btn.ghost, .summary .btn.ghost, .modal .btn.ghost { color: var(--ink); border-color: var(--line-strong); }
.main .btn.ghost:hover, .summary .btn.ghost:hover, .modal .btn.ghost:hover { background: #fff; }
.btn.danger { color: var(--warn); }

/* ---------- workspace ---------- */
.workspace { display: grid; grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
.sidebar {
  position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h) - var(--sum-h));
  overflow: auto; padding: 14px 12px 14px 20px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 16px;
}
.side-block.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-title { font-family: var(--cond); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.side-title span { font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 4px 10px; cursor: pointer;
  font-size: 12.5px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center;
}
.chip small { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.on small { color: #C9CEC9; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--order); display: none; }
.chip.has .dot { display: inline-block; }
.fam-nav { display: flex; flex-direction: column; gap: 1px; overflow: auto; }
.fam-nav a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 5px 8px; border-radius: 4px;
  color: var(--ink); text-decoration: none; font-size: 13px; line-height: 1.25;
}
.fam-nav a:hover { background: #fff; }
.fam-nav a.active { background: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.fam-nav a .n { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.fam-nav a .n.has { color: var(--ink); background: var(--order); padding: 0 5px; border-radius: 3px; font-weight: 600; }

.main { padding: 14px 20px 24px; min-width: 0; }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1 1 320px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 12px; height: 40px; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,77,176,.15); }
.search svg { color: var(--muted); flex: none; }
.search input { flex: 1; border: 0; outline: 0; height: 100%; background: transparent; font-size: 15px; min-width: 0; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.toolbar-right { display: flex; gap: 12px; align-items: center; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.switch input { width: 16px; height: 16px; accent-color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--ink); color: #fff; }

/* ---------- catalog cards ---------- */
.catalog { display: flex; flex-direction: column; gap: 14px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; scroll-margin-top: calc(var(--top-h) + 10px); }
.card.has-order { border-color: #E2C33A; box-shadow: 0 0 0 1px #E2C33A; }
.card-head { display: flex; align-items: baseline; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFAF8; }
.card-head h2 { margin: 0; font-family: var(--cond); font-size: 17px; font-weight: 700; letter-spacing: .005em; }
.card-head .cat { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .05em; }
.card-head .cnt { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.card-head .cnt b { color: var(--ink); background: var(--order); padding: 0 6px; border-radius: 3px; }
.card-head .cnt b:empty { display: none; }
.card-body { overflow-x: auto; }

table.grid { border-collapse: collapse; width: 100%; }
table.grid th, table.grid td { padding: 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td, table.grid tbody tr:last-child th { border-bottom: 0; }
table.grid thead th { font-family: var(--cond); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 7px 10px; text-align: left; white-space: nowrap; background: #fff; }
table.grid thead th.num, table.grid td.num { text-align: right; }
table.grid tbody th { font-weight: 500; text-align: left; padding: 0 10px; white-space: nowrap; }
table.grid tbody tr:hover { background: #F6F7F4; }
table.grid tbody tr.has { background: var(--order-soft); }
table.grid tbody tr.has:hover { background: #F7EAAE; }
.sw { display: inline-block; width: 13px; height: 13px; border-radius: 50%; margin-right: 8px; vertical-align: -2px; background: var(--c, transparent); box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
.sw.none { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.sw.clear { background: repeating-linear-gradient(45deg, #fff 0 3px, #D9DDD8 3px 6px); }
.sw.base { background: repeating-linear-gradient(-45deg, #fff 0 2px, #9AA09A 2px 4px); }
.code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.price { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.unit { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.name-fam { color: var(--muted); }
.name-var { font-weight: 500; }
td.total { font-family: var(--mono); font-size: 12.5px; text-align: right; padding-right: 12px; color: var(--muted); white-space: nowrap; }
tr.has td.total { color: var(--ink); font-weight: 600; }

/* množstevní buňka */
td.q { width: 68px; padding: 3px 4px; text-align: center; }
table.matrix td.q { width: 74px; }
td.q.none { color: var(--line-strong); }
.qty {
  width: 100%; height: 30px; border: 1px solid transparent; border-radius: 4px; background: transparent;
  text-align: center; font-family: var(--mono); font-size: 14px; font-weight: 500; padding: 0 4px;
  -moz-appearance: textfield; caret-color: var(--accent);
}
.qty::-webkit-outer-spin-button, .qty::-webkit-inner-spin-button { -webkit-appearance: none; }
.qty::placeholder { color: #C6CBC5; }
.qty:hover { border-color: var(--line-strong); background: #fff; }
.qty:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(30,77,176,.18); }
.qty.has { background: var(--order); border-color: #E2C33A; font-weight: 600; }
.qty.has:focus { background: #fff; }
table.matrix thead th.size { text-align: center; }
table.matrix thead th.size small { display: block; font-family: var(--mono); font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
table.matrix tbody th { min-width: 200px; }
table.matrix tbody th .code { display: block; font-size: 10.5px; margin-left: 21px; margin-top: -2px; }
table.matrix thead th:first-child { min-width: 200px; }

/* ---------- summary bar ---------- */
.summary {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: var(--sum-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px;
  background: #fff; border-top: 2px solid var(--ink); box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.focus-info { flex: 1 1 200px; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focus-info .code { margin-right: 8px; }
.focus-info b { font-weight: 600; }
.stats { display: flex; align-items: center; gap: 22px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; min-width: 56px; }
.stat-v { font-family: var(--mono); font-size: 17px; font-weight: 600; white-space: nowrap; }
.stat-l { font-family: var(--cond); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.stat.price .stat-v { font-size: 19px; }
.stat.weight { position: relative; padding-bottom: 5px; }
.stat.weight .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.stat.weight .bar span { display: block; height: 100%; width: 0; background: var(--warn); transition: width .2s; }
.stat.weight.ok .bar span { background: var(--ok); }
.stat.weight.ok .min-note { display: none; }
.stat.weight .min-note { color: var(--warn); }
.stat.weight.ok .stat-v { color: var(--ok); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; }
.modal[hidden] { display: none; }
.modal-back { position: absolute; inset: 0; background: rgba(26,29,27,.45); }
.modal-box { position: relative; background: #fff; border-radius: 8px; width: min(860px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: var(--cond); font-size: 18px; font-weight: 700; }
.modal-body { overflow: auto; padding: 0; }
.modal-body table.grid tbody th, .modal-body table.grid td { padding: 6px 10px; }
.modal-body .row-actions { padding: 12px 18px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-body p { padding: 0 18px; }
.hist-item { display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.hist-item .code { min-width: 130px; }
.hist-item .desc { flex: 1; min-width: 0; }
.hist-item .desc small { color: var(--muted); display: block; }
.mini { border: 1px solid var(--line-strong); background: #fff; border-radius: 4px; padding: 3px 8px; cursor: pointer; font-size: 12.5px; }
.mini:hover { background: var(--paper); }
.mini.danger { color: var(--warn); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--sum-h) + 14px); transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: min(560px, 90vw); }
.toast.error { background: var(--warn); }
.toast[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  :root { --sum-h: 96px; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 16px; gap: 10px; }
  .side-block.grow { display: none; }
  .main { padding: 12px 16px 24px; }
  .brand-meta { display: none; }
  .topbar { padding: 0 12px; }
  .btn { padding: 8px 10px; }
  .summary { flex-wrap: wrap; height: auto; min-height: var(--sum-h); padding: 8px 12px; gap: 8px; }
  .focus-info { flex-basis: 100%; }
  .stats { width: 100%; justify-content: space-between; gap: 10px; }
  .stat { min-width: 0; }
  table.matrix tbody th, table.matrix thead th:first-child { min-width: 140px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- mobil: dolaďování ---------- */
@media (max-width: 900px) {
  :root { --top-h: 96px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 6px; }
  .brand { flex: 1 1 100%; }
  .topbar-actions { flex: 1 1 100%; justify-content: flex-end; }
  .topbar-actions .btn { padding: 7px 10px; font-size: 13px; }
}
@media (max-width: 600px) {
  .stat.pieces, .stat.brutto { display: none; }
  .stat-v { font-size: 15px; }
  .stat.price .stat-v { font-size: 16px; }
  .summary .btn { padding: 6px 10px; font-size: 13px; }
  .stats { gap: 12px; }
}
@media (max-width: 600px) {
  .card-head { flex-wrap: wrap; row-gap: 2px; }
  .card-head h2 { flex: 1 1 auto; }
  .card-head .cnt { flex-basis: 100%; margin-left: 0; }
  .stat.weight .min-note { display: none; }
  .stats { gap: 16px; }
}
