[hidden] { display: none !important; }
:root {
  --bg: #f1f5f9; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #0f172a; --ok: #16a34a; --warn: #d97706; --err: #dc2626; --blue: #2563eb;
  --r: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
/* vypne „stažení dolů pro obnovení“ v Chrome, které by smazalo rozpracovaný účet */
html { overscroll-behavior: none; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); display: flex; flex-direction: column; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: .7em 1em; background: #e2e8f0; color: var(--ink); touch-action: manipulation; }
button:active { transform: scale(.97); }
button.primary { background: var(--blue); color: #fff; }
button.danger { background: #fee2e2; color: var(--err); }
button.ghost { background: transparent; border: 1px solid var(--line); }
button:disabled { opacity: .5; }
input, select, textarea { width: 100%; padding: .65em .75em; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .7em 0 .25em; }
label.check { display: flex; gap: .5em; align-items: center; color: var(--ink); font-size: 1rem; }
label.check input { width: auto; }
h2 { margin: .2em 0 .6em; font-size: 1.25rem; }
h3 { margin: 1.2em 0 .5em; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75em; }
.card { background: var(--card); border-radius: var(--r); padding: 1em; margin: .75em; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.page { flex: 1; overflow: auto; padding-bottom: 2em; }
/* Ikony (SVG) místo emoji */
.ico { flex: none; vertical-align: -0.22em; }
button .ico, a .ico { vertical-align: -0.22em; }

/* Na širokém monitoru zúžíme obsah do vycentrovaného sloupce; horní lišta i menu drží stejný sloupec */
@media (min-width: 680px) {
  .page { max-width: 720px; margin: 0 auto; width: 100%; }
  /* na monitoru: horní lišta i pokladna jako zaoblené bloky ve stejném sloupci jako karty */
  body #topbar { width: calc(100% - 1.5em); max-width: calc(720px - 1.5em); margin: .6em auto 0; box-sizing: border-box; border-radius: 14px; padding: .45em .7em; }
  /* bez overflow:hidden – na nízkém okně se pokladna musí dát posunout; zaoblení nese displej a spodek bloku */
  #app .pos { width: calc(100% - 1.5em); max-width: calc(720px - 1.5em); margin: .6em auto; }
  #app .pos .display { border-radius: 14px 14px 0 0; }
  body #menu { top: 3.8em; }
  body #menu { left: max(.75em, calc((100% - 720px) / 2 + .75em)); right: auto; transform: none; width: min(420px, 92vw); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  body { background: #e9edf3; }
}
.err { color: var(--err); }
.okc { color: var(--ok); }

/* horní lišta */
#topbar { display: flex; align-items: center; gap: .5em; background: var(--brand); color: #fff; padding: calc(.4em + env(safe-area-inset-top)) .6em .4em; }
#topbar .title { flex: 1; min-width: 0; line-height: 1.15; }
#topbar .title b, #topbar .title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar .title small { opacity: .7; }
button.icon { background: transparent; color: #fff; font-size: 1.4rem; padding: .2em .5em; }
#topbar .back { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; font-size: .9rem; padding: .45em .8em; border-radius: 99px; white-space: nowrap; flex: none; }
#topbar .back:hover { background: rgba(255,255,255,.24); }
.pill { border-radius: 99px; padding: .35em .8em; font-size: .85rem; background: #334155; color: #fff; white-space: nowrap; }
.pill.on { background: #166534; } .pill.off { background: #9a3412; } .pill.wait { background: #a16207; }
#menu { position: fixed; z-index: 20; top: 3.2em; left: .5em; background: #fff; border-radius: var(--r); box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: .4em; min-width: 240px; }
#menu a { display: flex; gap: .7em; align-items: center; padding: .8em 1em; color: var(--ink); text-decoration: none; border-radius: 8px; }
#menu a .ico { color: var(--muted); }
#menu a.logout { color: var(--err); border-top: 1px solid var(--line); margin-top: .3em; font-weight: 600; cursor: pointer; }
#menu a.logout .ico { color: var(--err); }
#menu a:hover, #menu a.active { background: var(--bg); }
#menu .ver { color: var(--muted); font-size: .75rem; text-align: center; padding: .8em 1em .4em; }
#app { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* pokladna */
.pos { flex: 1; display: grid; grid-template-rows: auto minmax(10.5rem, 1fr) auto auto auto; min-height: 0; max-width: 720px; width: 100%; margin: 0 auto; }
.display { background: #0b1220; color: #fff; padding: .4em .8em; text-align: right; }
.display .amt { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.display .sub { color: #94a3b8; min-height: 1.2em; font-size: .9rem; }
.cart { overflow: auto; overscroll-behavior: contain; background: #fff; border-bottom: 1px solid var(--line); }
.cart .empty { color: var(--muted); text-align: center; padding: 1em; }
.cart .it { display: flex; align-items: center; gap: .5em; padding: .25em .8em; min-height: 2rem; border-bottom: 1px solid #f1f5f9; }
.cart .it .l { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart .it .l small { color: var(--muted); margin-left: .4em; }
.cart .it .a { font-weight: 600; font-variant-numeric: tabular-nums; }
.cart .it button { background: transparent; color: var(--err); padding: .1em .5em; font-size: 1.1rem; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .4em; padding: .4em; }
.cats button { color: #fff; font-weight: 600; min-height: 3.1em; line-height: 1.15; padding: .4em; }
.cats button .vr { display: none; }
.cats button small { display: block; font-weight: 400; opacity: .85; font-size: .78rem; }
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35em; padding: 0 .4em .4em; }
.keys button { font-size: 2rem; padding: .7em 0; min-height: 2.6em; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.08); font-variant-numeric: tabular-nums; }
.keys button.fn { background: #e2e8f0; font-size: 1.3rem; }
.keys button.c { background: #fee2e2; color: var(--err); }
.pay { display: grid; grid-template-columns: 1fr 1fr; gap: .4em; padding: 0 .4em calc(.4em + env(safe-area-inset-bottom)); }
.pay button { font-size: 1.15rem; font-weight: 700; padding: .8em .3em; color: #fff; }
.pay .cash { background: var(--ok); } .pay .qr { background: #7c3aed; } .pay .card { background: var(--blue); margin: 0; border-radius: 10px; box-shadow: none; }
.totalbar { display: flex; justify-content: space-between; align-items: baseline; padding: .35em .8em; font-weight: 700; background: #fff; }
.totalbar .v { font-size: 1.4rem; }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
/* počítač / tablet na šířku: tlačítka zboží vpravo vedle číselníku, vše na jedné obrazovce bez posouvání */
@media (min-width: 960px) and (orientation: landscape) {
  body.is-pos #topbar { max-width: calc(1400px - 1.5em); }
  body.is-pos #menu { left: max(.75em, calc((100% - 1400px) / 2 + .75em)); }
  #app .pos { max-width: calc(1400px - 1.5em); min-height: 0; overflow: hidden;
    grid-template-columns: minmax(380px, 36%) 1fr; grid-template-rows: auto minmax(60px, 1fr) auto auto auto;
    grid-template-areas: "disp cats" "cart cats" "tot cats" "keys cats" "pay cats"; column-gap: .8em; }
  .pos .pad { display: contents; }
  .pos .display { grid-area: disp; }
  .pos .cart { grid-area: cart; }
  .pos .totalbar { grid-area: tot; border-radius: 0 0 14px 14px; margin-bottom: .45em; }
  .pos .keys { grid-area: keys; padding: 0; }
  .pos .pay { grid-area: pay; padding: .35em 0 0; }
  .pos .cats { grid-area: cats; overflow-y: auto; align-content: start; padding: 0; gap: .5em;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .pos .cats button { min-height: clamp(52px, 9vh, 84px); font-size: 1.05rem; border-radius: 12px; }
  .pos .keys button { min-height: 0; height: clamp(44px, 8vh, 72px); padding: 0; font-size: 1.7rem; }
  .pos .keys button.fn { font-size: 1.2rem; }
  .pos .pay button { height: clamp(48px, 8vh, 64px); padding: 0 .3em; }
}
/* mobil: vše na jednu obrazovku. Rozměry jsou v px a dvh (ne v rem), aby je nerozhodilo
   zvětšené písmo v telefonu; když místo nestačí, ustoupí nejdřív seznam položek účtu
   a jako poslední záchrana se posouvají jen tlačítka položek, nikdy celá stránka. */
@media (max-width: 679px) {
  html { -webkit-text-size-adjust: none; text-size-adjust: none; }
  html, body { position: fixed; inset: 0; overflow: hidden; }
  body { height: var(--app-h, 100dvh); bottom: auto; }
  #topbar { padding-top: calc(3px + env(safe-area-inset-top)); padding-bottom: 3px; }
  #topbar .title b { font-size: 15px; } #topbar .title small { font-size: 12px; }
  #topbar .pill { font-size: 12px; } #topbar .badge { font-size: 10px; }
  .cats button { line-height: 1; }
  .pos { grid-template-rows: auto minmax(64px, 1fr) auto auto auto; overflow: hidden; }
  .display { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 1px 10px; }
  .display .sub { font-size: 12px; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .display .amt { font-size: 24px; line-height: 1.2; white-space: nowrap; }
  .cart .it { padding: 1px 10px; min-height: 22px; font-size: 13px; }
  .cart .it button { font-size: 15px; padding: 0 8px; }
  .cart .empty { padding: 8px; font-size: 13px; }
  .totalbar { padding: 1px 10px; border-top: 1px solid var(--line); font-size: 14px; }
  .totalbar .v { font-size: 17px; }
  .cats { grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 3px 4px; max-height: 40dvh; overflow-y: auto; }
  .cats button { height: clamp(26px, 3.9dvh, 34px); min-height: 0; padding: 0 2px; font-size: 10.5px; font-weight: 600; line-height: 1.05; border-radius: 6px; overflow: hidden; overflow-wrap: anywhere; display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .cats button small { display: none; } /* místo řádku „DPH 21 %“ je na mobilu jen značka v rohu */
  .cats button { position: relative; padding: 0 11px 0 5px; }
  .cats button .vr { display: block; position: absolute; top: 1px; right: 2px; font-style: normal; font-size: 8px; font-weight: 700; line-height: 1; padding: 1px 2px; border-radius: 3px; background: rgba(0,0,0,.28); color: #fff; }
  /* barva značky podle sazby: 21 % bílá s červeným číslem, 12 % žlutá, 0 % tmavá */
  .cats button .vr { font-size: 8.5px; padding: 1px 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
  .cats button .vr21 { background: #fff; color: #dc2626; }
  .cats button .vr12 { background: #facc15; color: #1f2937; }
  .cats button .vr0 { background: #1f2937; color: #fff; }
  .keys { gap: 3px; padding: 0 4px 3px; }
  .keys button { font-size: 20px; padding: 0; min-height: 0; height: clamp(32px, 5.4dvh, 46px); border-radius: 6px; }
  .keys button.fn { font-size: 16px; }
  .keys button[data-k="clr"] { font-size: 10.5px !important; line-height: 1.05; }
  .pay { gap: 3px; padding: 0 4px calc(3px + env(safe-area-inset-bottom)); }
  .pay button { font-size: 14px; padding: 0 4px; height: clamp(34px, 5.6dvh, 46px); border-radius: 6px; }
  .pay button .ico { width: 18px; height: 18px; }
}

/* statistiky */
.stnav { display: flex; align-items: center; justify-content: space-between; gap: .5em; margin: .2em 0 .6em; }
.stnav b { flex: 1; text-align: center; font-size: 1.05rem; }
.stnav button { flex: 0 0 auto; font-size: 1.4rem; padding: .1em .8em; }
.kpi small { display: block; font-size: .78rem; margin-top: .15em; }
.t.st td:first-child { white-space: nowrap; }
.chart { position: relative; margin: .3em 0 1em; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .gl { stroke: #e5e9ef; stroke-width: 1; }
.chart .base { stroke: #94a3b8; stroke-width: 1; }
.chart .ax { fill: #64748b; font-size: 11px; }
.chart .val { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .fill { fill: #2563eb; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar.on .hit { fill: rgba(37, 99, 235, .07); }
.chart .tip { position: absolute; top: 0; background: #0f172a; color: #fff; font-size: .82rem; line-height: 1.35; padding: .45em .65em; border-radius: 8px; pointer-events: none; white-space: nowrap; }
.chart .tip .muted { color: #cbd5e1; font-size: .78rem; }

/* QR platba */
.qrpay { text-align: center; }
.qrpay h2 { margin-top: 0; }
.qrpay .big { font-size: 2rem; font-weight: 800; margin: .1em 0 .3em; }
.qrbox { display: flex; justify-content: center; background: #fff; padding: .4em; border-radius: 12px; border: 1px solid var(--line); }
.qrpay .muted { font-size: .85rem; margin: .5em 0 .8em; }
.paym { display: grid; gap: .35em; margin-bottom: .4em; }

/* seznamy */
.list .li { display: flex; gap: .6em; align-items: center; padding: .7em .2em; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .li .grow { flex: 1; min-width: 0; }
.list .li .grow small { display: block; color: var(--muted); }
.badge { font-size: .75rem; padding: .2em .55em; border-radius: 99px; white-space: nowrap; font-weight: 600; }
.b-ok { background: #dcfce7; color: #166534; } .b-pending { background: #fef3c7; color: #92400e; } .b-error { background: #fee2e2; color: #991b1b; } .b-off { background: #e2e8f0; color: #475569; } .b-local { background: #e0e7ff; color: #3730a3; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t td, table.t th { padding: .4em .3em; border-bottom: 1px solid var(--line); text-align: left; }
table.t td.n, table.t th.n { text-align: right; }
.big { font-size: 1.6rem; font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6em; }
.kpi { background: var(--bg); border-radius: 10px; padding: .7em; }
.kpi b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.tabs { display: flex; flex-wrap: wrap; gap: .35em; padding: .2em 0 .6em; }
.tabs button { flex: 0 0 auto; }
.tabs button { white-space: nowrap; background: #fff; border: 1px solid var(--line); }
.tabs button.sel { background: var(--ink); color: #fff; }
.swatch { width: 1.4em; height: 1.4em; border-radius: 6px; display: inline-block; vertical-align: middle; }

/* modal + toast */
#modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
#modal .sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 1.1em 1.1em calc(1.1em + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { #modal { align-items: center; } #modal .sheet { border-radius: 18px; } }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 1.5em; background: var(--ink); color: #fff; padding: .75em 1.2em; border-radius: 12px; z-index: 40; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
#toast.bad { background: var(--err); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4em; margin: .5em 0; }
.recbtns { display: grid; grid-template-columns: 1fr 1fr; gap: .6em; }
.recbtns button { padding: 1.3em .4em; font-size: 1.25rem; font-weight: 700; line-height: 1.2; color: #fff; }
.recbtns .rec-none { background: var(--blue); }
.recbtns .rec-print { background: var(--ok); }
.recbtns .rec-virt { background: #475569; }
.change { font-size: 1.6rem; font-weight: 700; text-align: center; margin: .4em 0; }
.preview { text-align: center; background: var(--bg); padding: .6em; border-radius: 10px; }
.preview canvas, .preview img { max-width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.login { max-width: 380px; margin: 8vh auto; width: calc(100% - 1.5em); }
.login h1 { font-size: 1.6rem; margin: 0 0 .2em; }

#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  #printArea img { width: 80mm; }
}
