﻿:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef0f4; --text: #1b1f24; --muted: #5d6673;
  --border: #d5d9e0; --primary: #0f6d6d; --primary-text: #ffffff; --danger: #b42318; --danger-bg: #fde8e6;
  --ok: #1d7a3a; --ok-bg: #e5f5ea; --warn-bg: #fff6db; --focus: #2a7fff; --row-err: #fde2df;
  --radius: 10px; --gap: 14px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #121417; --surface: #1b1e23; --surface-2: #252931; --text: #e7eaee; --muted: #9aa3ae;
  --border: #343a44; --primary: #3fb4b0; --primary-text: #0b1515; --danger: #ff8a7a; --danger-bg: #3a1d1a;
  --ok: #6fd28c; --ok-bg: #16301f; --warn-bg: #3a3215; --focus: #6aa8ff; --row-err: #4a1f1b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); }
h1 { font-size: 1.45rem; margin: 0 0 var(--gap); }
h2 { font-size: 1.15rem; margin: 1.4em 0 .6em; }
h3 { font-size: 1rem; margin: 1.2em 0 .5em; }
code { font-family: ui-monospace, Consolas, monospace; }

header.top { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 18px 8px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
nav.main { display: flex; flex-wrap: wrap; gap: 2px 4px; width: 100%; }
nav.main a { text-decoration: none; color: var(--text); padding: 6px 10px; border-radius: 8px; }
nav.main a:hover, nav.main a[aria-current] { background: var(--surface-2); }
nav.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
nav.tabs a { text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; font-size: .92rem; }
nav.tabs a:hover { background: var(--surface-2); }
nav.tabs a[aria-current="page"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.who { display: flex; align-items: center; gap: 10px; font-size: .9rem; flex-shrink: 0; }
.theme-toggle { font-size: 1.1rem; padding: 6px 10px; }

main { max-width: 1100px; margin: 0 auto; padding: 18px; }
main.wide { max-width: 1500px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: var(--gap); }
.card.narrow { max-width: 460px; margin: 30px auto; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(140px, 190px) 1fr auto; gap: 10px; align-items: center; }
.bar { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); }
.bar span.paper { background: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.stack { display: grid; gap: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.qr { background: #fff; padding: 8px; border-radius: 8px; }
.secret { word-break: break-all; }
ol.codes { columns: 2; font-size: 1.1rem; }

label { display: grid; gap: 4px; font-size: .92rem; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
input, select, textarea, button, .button {
  font: inherit; font-size: 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 9px 11px; min-height: 42px;
}
input[type="checkbox"] { min-height: auto; width: 20px; height: 20px; }
textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus, button:focus-visible, .button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
button, .button { cursor: pointer; background: var(--surface-2); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.primary, .button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
button.danger, .button.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; color: var(--primary); padding: 0; min-height: auto; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--gap); }
.back { margin: 0 0 12px; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.pick button { border-radius: 999px; }
.pick button[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.pick button[aria-pressed="true"]::before { content: '✓ '; }
tr.markable { cursor: pointer; }
tr.markable:hover td { background: var(--surface-2); }
.plates form { display: inline-flex; gap: 6px; align-items: center; margin: 0; padding: 4px 8px 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
nav.groups { display: flex; flex-wrap: wrap; gap: 8px; margin: var(--gap) 0; }
nav.groups .button.primary .badge { background: var(--primary-text); color: var(--primary); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 8px 0; }
legend { padding: 0 6px; color: var(--text); font-weight: 600; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: var(--gap); border: 1px solid; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.flash.err { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.flash.warn { background: var(--warn-bg); border-color: var(--border); }

table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { padding: 8px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { font-weight: 600; color: var(--muted); font-size: .85rem; }
table.data th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.data th.sortable:hover { color: var(--text); }
table.data th.sortable::after { content: ' ↕'; opacity: .4; }
table.data th[aria-sort="ascending"]::after { content: ' ▲'; opacity: 1; }
table.data th[aria-sort="descending"]::after { content: ' ▼'; opacity: 1; }
table.data th[aria-sort] { color: var(--text); }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data th.tick, table.data td.tick { width: 2.2rem; text-align: center; vertical-align: middle; padding-left: 6px; padding-right: 6px; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.bulk-bar button { min-height: 36px; padding: 6px 10px; }
table.data tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
table.data tr.group td { background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); white-space: nowrap; }
.badge.locked { background: var(--ok-bg); color: var(--ok); }
.badge.cancelled { background: var(--danger-bg); color: var(--danger); }
.badge.open { background: var(--warn-bg); }

/* Editor řádků */
.lines { display: grid; gap: 8px; }
.line { display: grid; gap: 8px; grid-template-columns: minmax(140px, 1.2fr) minmax(200px, 3fr) repeat(3, minmax(90px, 1fr)) 80px 90px 44px; align-items: start; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.line.no-machine { grid-template-columns: minmax(200px, 3fr) repeat(3, minmax(90px, 1fr)) 80px 90px 44px; }
.line.no-pct .f-pct { display: none; }
.line.no-pct { grid-template-columns: 110px minmax(200px, 3fr) repeat(3, minmax(90px, 1fr)) 90px 44px; }
.line.no-machine.no-pct { grid-template-columns: minmax(200px, 3fr) repeat(3, minmax(90px, 1fr)) 90px 44px; }
.line.short { background: var(--row-err); border-color: var(--danger); }
.line input { width: 100%; }
.line .auto, input.auto { background: var(--surface-2); }
.line .stockinfo { font-size: .8rem; color: var(--muted); padding-top: 4px; }
.line.short .stockinfo { color: var(--danger); font-weight: 600; }
.line .f-label { font-size: .75rem; color: var(--muted); }
.picker { position: relative; }
.picker ul { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; max-height: 280px; overflow: auto; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.picker li { padding: 9px 10px; cursor: pointer; }
.picker li[aria-selected="true"], .picker li:hover { background: var(--surface-2); }
.picker li.empty { cursor: default; color: var(--muted); font-size: .9rem; }
.line select { width: 100%; }
.summary { display: grid; gap: 4px; justify-content: end; text-align: right; font-variant-numeric: tabular-nums; margin-top: var(--gap); }
.summary b { font-size: 1.1rem; }

@media (max-width: 760px) {
  .line, .line.no-machine, .line.no-pct, .line.no-machine.no-pct { grid-template-columns: 1fr 1fr 1fr; }
  .line .f-product { grid-column: 1 / -1; }
  .line .f-machine { grid-column: 1 / 2; }
  .who .muted { display: none; }
  main { padding: 12px; }
}

.cz-date { position: relative; display: inline-flex; align-items: center; gap: 4px; max-width: 16rem; }
label .cz-date, .row .cz-date, .filters .cz-date { width: 100%; }
table.data .cz-date { max-width: none; width: 100%; }
.cz-date-text { width: 8.4em; font-variant-numeric: tabular-nums; }
table.data .cz-date-text, label .cz-date-text { flex: 1; width: auto; min-width: 7.6em; }
.cz-date-open { min-height: 42px; padding: 0 10px; flex: 0 0 auto; }
.cz-date-native { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; white-space: nowrap; }
.cz-cal { position: fixed; z-index: 40; width: 292px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); padding: 8px; }
.cz-cal[hidden] { display: none !important; }
.cz-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.cz-cal-head b { font-weight: 650; }
.cz-cal-head button, .cz-cal-foot button { min-height: 36px; padding: 4px 10px; }
.cz-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cz-cal-grid.months { grid-template-columns: repeat(3, 1fr); }
.cz-cal-dow { font-size: .75rem; color: var(--muted); padding: 4px 0; }
.cz-cal-grid button { min-height: 34px; padding: 2px; }
.cz-cal-grid button.out { visibility: hidden; }
.cz-cal-grid button.weekend:not([aria-pressed="true"]) { color: var(--muted); }
.cz-cal-grid button[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.cz-cal-grid button.today:not([aria-pressed="true"]) { border-color: var(--focus); }
.cz-cal-foot { margin-top: 6px; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 12px 0; }
.cal-head { text-align: center; color: var(--muted); font-size: .8rem; }
.cal-day { min-height: 96px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-day.pad { background: transparent; border-color: transparent; }
.cal-day.weekend { background: #ececec; }
.cal-day.holiday { background: #c8ebc8; }
[data-theme="dark"] .cal-day.weekend { background: #2c3036; }
[data-theme="dark"] .cal-day.holiday { background: #1e4a32; color: #e7eaee; }
.cal-day.today { outline: 2px solid var(--primary); }
.cal-day.picked { box-shadow: inset 0 0 0 2px var(--focus); }
.cal-num { font-weight: 700; text-decoration: none; color: inherit; }
.cal-flag { font-size: .7rem; line-height: 1.2; }
.chip { display: inline-block; font-size: .72rem; line-height: 1.25; border-radius: 4px; padding: 1px 4px; color: #1b1f24; }
.chip.plain { background: var(--surface-2); color: var(--text); }
.split { display: flex; min-height: 28px; border-radius: 4px; overflow: hidden; }
.split a { flex: 1 1 0; min-width: 0; font-size: .7rem; line-height: 1.2; padding: 2px 3px; color: #1b1f24; text-decoration: none; overflow: hidden; }
.split a.done { text-decoration: line-through; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches label { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.dot { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.note { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }

@media print {
  .cz-cal { display: none !important; }
  header.top, .no-print, .actions, .back, .flash { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: none; padding: 0; }
}
