/* RevizeApp V2 — complete styles: dark+forest themes, font scaling, all V1 components */

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f3460;
  --text: #e4e4e4;
  --text-muted: #8a8a9a;
  --primary: #e94560;
  --primary-hover: #c73852;
  --ok: #4caf50;
  --fail: #f44336;
  --warn: #ff9800;
  --border: #2a2a4a;
  --radius: 8px;
  --row-h: 56px;
  --nav-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: var(--nav-h);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 12px;
}

/* ========== HEADER ========== */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}
.app-header h1 {
  flex: 1;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-email {
  font-size: 0.7rem;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
/* Při otevřené klávesnici dolní lištu skryj — jinak ji iOS připne nad
   klávesnici a překáží při psaní. */
body.kb-open .bottom-nav { display: none !important; }
.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.65rem;
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.15s;
}
.bottom-nav .nav-item.active,
.bottom-nav .nav-item:active { color: var(--primary); }
.bottom-nav .nav-item .nav-icon { font-size: 1.3rem; }

/* ========== BUTTONS ========== */
.btn {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:active { opacity: 0.75; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-fail { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #000; }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; min-height: 36px; }
.btn-xs { padding: 10px 14px; font-size: 0.8rem; min-height: 36px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:active { background: rgba(255,255,255,0.05); }
.btn-ghost.active { background: rgba(255,193,7,0.18); color: #ffc107; }
.btn-group { display: flex; gap: 6px; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 10px; }
.form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* CRITICAL: 16px MUSÍ být s !important. iOS Safari zoomuje cokoli < 16px
     (input, select, textarea = vše triggeruje auto-zoom). Bez !important
     specifičtější selektory (.setting-row select, .search-full) přepsaly
     globální 16px → uživatel viděl zoom při kliknutí na list/dropdown.
     Pevně 16px (ne rem) protože root font-size se mění s theme.fontSize. */
  font-size: 16px !important;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a8a9a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
/* Checkboxy: globální appearance:none (pro textová pole) jim vypínal nativní
   vzhled → fajfka po zaškrtnutí NEBYLA vidět. Vrátit nativní render + barva appky. */
input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 20px;
  height: 20px;
  padding: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.form-row > div { display: flex; flex-direction: column; justify-content: flex-end; }
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.form-row-3 > div { display: flex; flex-direction: column; justify-content: flex-end; }
.input-with-btn {
  display: flex;
  gap: 4px;
}
.input-with-btn input { flex: 1; }

/* Input clear button */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap input { flex: 1; padding-right: 28px; }
.input-wrap .input-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  display: none;
}
.input-wrap input:not(:placeholder-shown) + .input-clear { display: block; }

/* ========== LOGIN ========== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
  background: var(--bg-card);
  border-radius: 12px;
  text-align: center;
}
.login-card h1 { margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 0.85rem; }
.error-msg { color: var(--fail); font-size: 0.85rem; margin-top: 8px; }

/* ========== STATS GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.stat-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: border 0.15s;
  border: 1px solid transparent;
}
.stat-box.active { border-color: var(--primary); }
.stat-value { display: block; font-size: 1.4rem; font-weight: 700; }
.stat-label { font-size: 0.65rem; color: var(--text-muted); }
.stat-box .stat-value.text-ok { color: var(--ok); }
.stat-box .stat-value.text-fail { color: var(--fail); }
.stat-box .stat-value.text-warn { color: var(--warn); }

/* ========== STATUS BLOCKS (V1-style) ========== */
.status-blocks {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.status-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 2px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}
.status-block .sb-count {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
}
.status-block .sb-label {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.status-block-vyprselo { border-color: var(--fail); }
.status-block-vyprselo .sb-count { color: var(--fail); }
.status-block-brzy { border-color: var(--warn); }
.status-block-brzy .sb-count { color: var(--warn); }
.status-block-nevyhovuje { border-color: #b71c1c; }
.status-block-nevyhovuje .sb-count { color: #ef5350; }
.status-block-vyhovuje { border-color: var(--ok); }
.status-block-vyhovuje .sb-count { color: var(--ok); }
.status-block-dnes { border-color: #42a5f5; }
.status-block-dnes .sb-count { color: #42a5f5; }

.status-block.active {
  background: rgba(255,255,255,0.08);
}
.status-block-vyprselo.active { background: rgba(244,67,54,0.15); }
.status-block-brzy.active { background: rgba(255,152,0,0.15); }
.status-block-nevyhovuje.active { background: rgba(183,28,28,0.15); }
.status-block-vyhovuje.active { background: rgba(76,175,80,0.15); }
.status-block-dnes.active { background: rgba(66,165,245,0.15); }

/* === NOVÁ STAVOVÁ LIŠTA: počty (pilulky) + termínové koše === */
/* 4 pilulky VŽDY vedle sebe (grid, ne wrap) — vejde se i 4místný počet (5000).
   Popisky zkrácené: Celk. / OK / NOK / Dnes, ať zůstane čitelná velikost čísla. */
.zc-counts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 4px 0 7px; }
.zc-cnt { display: flex; align-items: baseline; justify-content: center; gap: 4px; padding: 4px 4px;
  border: 1px solid var(--border); border-radius: 20px; background: var(--bg-card); cursor: pointer;
  font-weight: 600; user-select: none; min-width: 0; overflow: hidden; }
.zc-cnt i { font-style: normal; font-size: 0.66rem; opacity: 0.85; white-space: nowrap; }
.zc-cnt b { font-weight: 800; font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* velmi úzké displeje (≤360 px): zmenši popisek, číslo nech čitelné */
@media (max-width: 360px) {
  .zc-counts { gap: 3px; }
  .zc-cnt { padding: 4px 2px; gap: 3px; }
  .zc-cnt i { font-size: 0.58rem; }
  .zc-cnt b { font-size: 0.76rem; }
}
.zc-cnt.active { filter: brightness(1.15); }
.zc-all.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.zc-vyh { color: #42d392; } .zc-vyh.active { border-color: #42d392; box-shadow: 0 0 0 2px #42d392 inset; }
.zc-nev { color: #f5484d; } .zc-nev.active { border-color: #f5484d; box-shadow: 0 0 0 2px #f5484d inset; }
.zc-dnes { color: #00bcd4; } .zc-dnes.active { border-color: #00bcd4; box-shadow: 0 0 0 2px #00bcd4 inset; }
.zc-bezrev { color: #ffab40; } .zc-bezrev.active { border-color: #ffab40; box-shadow: 0 0 0 2px #ffab40 inset; }
/* Řádek spotřebiče bez revize — jantarový pruh vlevo, ať je v seznamu vidět „chybí". */
.device-row.bkt-bezrevize { box-shadow: inset 3px 0 0 #ffab40; }

.zc-buckets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.zc-bkt { border: 1px solid; border-radius: 9px; padding: 6px 4px 5px; text-align: center; cursor: pointer; user-select: none; color: #fff; }
.zc-bkt .zc-n { font-size: 1.2rem; font-weight: 900; line-height: 1; }
.zc-bkt .zc-l { font-size: 0.55rem; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.05; opacity: 0.95; }
.zc-bkt.active { filter: brightness(1.12); box-shadow: 0 0 0 2px rgba(255,255,255,0.4) inset; }
.zc-vyprselo { background: #565d6b; border-color: #565d6b; }
.zc-brzy { background: #9c6738; border-color: #9c6738; }
.zc-mesic { background: #2f80ed; border-color: #2f80ed; }
.zc-rok { background: #e6c14a; border-color: #e6c14a; color: #2a2205; }

.zc-toolbar { display: flex; align-items: center; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.zc-toolbar .btn-filter-toggle {
  margin-left: auto; padding: 6px 11px; font-size: 0.74rem; font-weight: 600;
  border-color: var(--primary); background: rgba(233,69,96,0.1); color: #ffc2cd; white-space: nowrap;
  /* Pojistka: kdyby popisek přece jen narostl, tlačítko se smrskne místo toho,
     aby kvůli nowrap spadlo pod řádek s ŘAZENÍ. */
  min-width: 0; overflow: hidden; flex-shrink: 1;
}
.zc-toolbar .adv-label { display: inline; }  /* .adv-label má display:block — v řádku by lámal */

/* ========== FILTER ROW (Vše + Filtry) ========== */
.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.btn-filter-all, .btn-filter-toggle {
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}
.btn-filter-all:active, .btn-filter-toggle:active { background: var(--bg-input); }

/* ========== ADVANCED FILTERS ========== */
.adv-filters {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.adv-filter-group { margin-bottom: 8px; }
.adv-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.chip-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.adv-chip {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.75rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.adv-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Našeptávač značek pod polem výrobce */
.vyrobce-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.vyrobce-chip {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.vyrobce-chip:hover, .vyrobce-chip:active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
/* Když je pole Výrobce aktivní (vyjíždí roletka značek), chipy skryj — jinak se
   roletka a chipy překrývaly a klik padal na zakrytý chip pod roletkou. */
.ac-wrap:focus-within + .vyrobce-chips { display: none; }

/* ========== PC TABULKA (široká obrazovka) ========== */
/* Vstupní tlačítko jen na širokém displeji (PC/notebook), na mobilu skryté */
.pc-only { display: none; }
@media (min-width: 1024px) {
  .pc-only { display: inline-flex; }
}
.pctab-screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.pctab-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; }
.pctab-inner { display: flex; flex-direction: column; height: 100%; }
.pctab-head {
  display: flex;
  position: sticky; top: 0;
  background: var(--bg-card);
  border-bottom: 2px solid var(--primary);
  font-weight: 600; font-size: 0.74rem;
  color: var(--text-muted);
  z-index: 2;
}
.pctab-body { flex: 1; min-height: 0; }
.pctab-row { display: flex; border-bottom: 1px solid var(--border); }
.pctab-row.pctab-odd { background: rgba(255,255,255,0.02); }
.pctab-row:hover { background: rgba(80,140,255,0.08); }
.pctab-cell {
  flex: 0 0 auto;
  padding: 6px 8px;
  font-size: 0.8rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-right: 1px solid var(--border);
  display: flex; align-items: center;
}
.pctab-hcell { padding-top: 8px; padding-bottom: 8px; }
.pctab-center { justify-content: center; text-align: center; }
.pctab-ok { color: var(--ok); }
.pctab-nok { color: var(--fail, #e53935); font-weight: 600; }
.pctab-vyprselo { color: var(--fail, #e53935); font-weight: 600; }
.pctab-brzy { color: #ef6c00; }

/* ========== SEARCH ROW ========== */
.search-row {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  margin-bottom: 8px;
}
.search-icon {
  font-size: 0.9rem;
  margin-right: 8px;
  opacity: 0.5;
}
.search-full {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  color: var(--text);
  border: none;
  /* Min 16px — viz globální pravidlo input/select/textarea. iOS jinak zoomuje. */
  font-size: 16px;
  outline: none;
}
.search-full::placeholder { color: var(--text-muted); }
.search-clear {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-muted); font-size: 0.85rem; cursor: pointer;
  padding: 3px 8px; margin-left: 6px; flex-shrink: 0; line-height: 1;
}
.search-clear:hover { color: var(--text); border-color: var(--primary); }

/* === POSUN INVENTÁRNÍCH ČÍSEL === */
.posun-ov { position: fixed; inset: 0; background: rgba(4,4,12,0.72); display: flex; align-items: flex-end; justify-content: center; z-index: 3000; }
.posun-box { background: var(--bg); border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; padding: 14px 14px 16px; }
.posun-hd { display: flex; align-items: center; font-weight: 600; font-size: 0.95rem; }
.posun-x { margin-left: auto; background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; }
.posun-info { font-size: 0.72rem; color: var(--text-muted); line-height: 1.4; margin: 6px 0 10px; }
.posun-ctrl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 9px; margin-bottom: 8px; }
.posun-lbl { font-size: 0.72rem; color: var(--text-muted); }
.posun-seg { display: flex; gap: 5px; }
.posun-seg button { padding: 7px 11px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-muted); border-radius: 8px; font-size: 0.78rem; cursor: pointer; font-weight: 600; }
.posun-seg button.on { border-color: var(--primary); color: #fff; background: rgba(233,69,96,0.22); }
.posun-step { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.posun-step button { width: 30px; height: 30px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); border-radius: 8px; font-size: 1.1rem; cursor: pointer; }
.posun-step #posun-amt { min-width: 24px; text-align: center; font-weight: 800; }
.posun-bar { display: flex; gap: 8px; align-items: center; font-size: 0.74rem; color: var(--text-muted); margin-bottom: 6px; }
.posun-bar a { color: var(--primary); cursor: pointer; }
.posun-bar .posun-sp { margin-left: auto; }
.posun-sortrow { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.posun-sb { padding: 5px 10px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-muted); border-radius: 8px; font-size: 0.72rem; cursor: pointer; }
.posun-sb.on { border-color: var(--primary); color: #fff; background: rgba(233,69,96,0.2); }
.posun-list { flex: 1; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; min-height: 120px; }
.posun-r { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-bottom: 1px solid rgba(255,255,255,0.04); cursor: pointer; user-select: none; }
.posun-r:last-child { border-bottom: none; }
.posun-r.sel { background: rgba(233,69,96,0.10); }
.posun-box2 { width: 22px; height: 22px; border-radius: 6px; border: 2px solid #4a5578; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.85rem; }
.posun-r.sel .posun-box2 { background: var(--primary); border-color: var(--primary); }
.posun-old { font-weight: 700; color: #5bd3a6; min-width: 66px; }
.posun-arr { color: var(--text-muted); }
.posun-new { font-weight: 700; }
.posun-new.ok { color: var(--ok); }
.posun-new.col { color: #f5484d; }
.posun-dup { font-size: 0.58rem; background: #f5484d; color: #fff; font-weight: 800; padding: 1px 6px; border-radius: 5px; }
.posun-nm { flex: 1; font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.posun-warn { margin-top: 10px; background: rgba(245,72,77,0.12); border: 1px solid #f5484d; color: #ffd0d2; border-radius: 8px; padding: 9px 11px; font-size: 0.75rem; display: none; }
.posun-warn.show { display: block; }
.posun-actions { display: flex; gap: 10px; margin-top: 12px; }
.posun-actions .btn { flex: 1; }

/* ========== ADD DEVICE BUTTON ========== */
.btn-add-device {
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ========== FILTER TABS (legacy) ========== */
.filter-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 0;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.filter-tab .tab-count {
  font-weight: 700;
  margin-left: 4px;
}

/* ========== HEADER COUNT ========== */
.header-count {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* ========== ZAKÁZKA CARD ========== */
.zak-card {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  gap: 10px;
}
.zak-card:active { background: var(--bg-input); }
.zak-card-main { flex: 1; min-width: 0; }
.zak-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.zak-card-stats {
  display: flex;
  gap: 10px;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.zak-card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* ========== SECTION ========== */
.section { margin-bottom: 16px; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.section-header h2 { font-size: 1rem; }

/* ========== LIST / DEVICE ROWS ========== */
.list-container { display: flex; flex-direction: column; gap: 3px; }

/* ===== Rozbalovací sekce (collapse) ===== */
.collapse-section {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
}
.collapse-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  min-height: 48px;
}
.collapse-toggle:active { background: rgba(255,255,255,0.05); }
.collapse-arrow {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.collapse-section.open .collapse-arrow { transform: rotate(90deg); }
.collapse-body {
  display: none;
  padding: 8px 14px 14px;
  border-top: 1px solid var(--border);
}
.collapse-section.open .collapse-body { display: block; }

/* ===== Správa místností (nastaveni → Místnosti) ===== */
.rooms-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.rooms-add-row input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}
.rooms-list { display: flex; flex-direction: column; gap: 6px; }
.room-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
  overflow: hidden;
}
.room-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}
.room-header-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.room-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.room-actions { display: flex; gap: 4px; flex-shrink: 0; }
.room-devices {
  border-top: 1px solid var(--border);
  padding: 6px 0;
  background: rgba(0,0,0,0.12);
}
.room-devices.hidden { display: none; }
.room-device {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  min-height: 54px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1.5px solid transparent;
  border-radius: 9px;
  margin: 5px 6px;
  background: var(--bg-input);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: border-color 0.1s, background 0.1s;
}
.room-device.sel { border-color: var(--primary); background: rgba(233,69,96,0.13); }
.room-device .rd-box {
  width: 26px; height: 26px; border-radius: 7px; border: 2px solid #4a5578;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: transparent; background: transparent; transition: 0.1s;
}
.room-device.sel .rd-box { background: var(--primary); border-color: var(--primary); color: #fff; }
.room-device .rd-inv { font-weight: 600; color: var(--primary); min-width: 56px; }
.room-device .rd-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-move-device {
  font-size: 1rem;
  min-width: 44px;
  min-height: 40px;
  flex-shrink: 0;
}

/* Výběr cílové místnosti = spodní panel s dlaždicemi (nahrazuje roletku) */
.room-picker-ov {
  position: fixed; inset: 0; background: rgba(4,4,12,0.72);
  display: flex; align-items: flex-end; justify-content: center; z-index: 2000;
}
.room-picker-sheet {
  background: var(--bg); border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 560px;
  max-height: 84vh; overflow-y: auto; padding: 16px 16px 18px;
}
.room-picker-sheet .rp-title { font-size: 1.05rem; margin: 0 0 2px; }
.rp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.rp-cell {
  padding: 16px 12px; border: 2px solid var(--border); border-radius: 12px;
  background: var(--bg-input); color: var(--text); cursor: pointer;
  font-size: 0.9rem; text-align: center; min-height: 58px; line-height: 1.2;
  display: flex; align-items: center; justify-content: center; transition: 0.1s;
}
.rp-cell.sel { border-color: var(--primary); background: rgba(233,69,96,0.16); font-weight: 600; box-shadow: 0 0 0 1px var(--primary) inset; }
.rp-cell.rp-new { border-style: dashed; color: var(--text-muted); }
.rp-newname { width: 100%; margin: 0 0 12px; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; }
.rp-actions { display: flex; gap: 10px; position: sticky; bottom: -18px; background: var(--bg); padding: 8px 0 0; }
.rp-actions .btn { flex: 1; }

/* Generování PDF — klikací výběr stran + podrobnější nastavení */
.pdf-pages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 4px; }
.pdf-page { position: relative; cursor: pointer; border: 2px solid var(--border); border-radius: 10px;
  padding: 8px 6px 6px; background: var(--bg-input); display: flex; flex-direction: column; align-items: center; gap: 5px; transition: 0.1s; }
.pdf-page.sel { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.pdf-page:not(.sel) { opacity: 0.5; filter: grayscale(0.4); }
.pdf-page svg { width: 100%; height: auto; border-radius: 4px; }
.pdf-page .pp-name { font-size: 0.66rem; text-align: center; line-height: 1.15; }
.pdf-page .pp-check { position: absolute; top: 5px; right: 5px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 0.65rem; display: flex; align-items: center; justify-content: center; opacity: 0; transform: scale(0.6); transition: 0.12s; }
.pdf-page.sel .pp-check { opacity: 1; transform: scale(1); }
.pdf-adv-toggle { width: 100%; text-align: left; display: flex; align-items: center; gap: 8px; background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 0.78rem; padding: 8px 0; }
.pdf-adv-toggle .chev { transition: transform 0.15s; }
.pdf-adv-toggle.open .chev { transform: rotate(90deg); }
.pdf-adv { display: none; padding: 12px; margin: 4px 0 8px; background: rgba(255,255,255,0.02); border: 1px dashed var(--border); border-radius: 8px; }
.pdf-adv.open { display: block; }
.pdf-seg { display: flex; gap: 6px; margin: 4px 0 0; }
.pdf-seg button { flex: 1; padding: 8px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-muted); border-radius: 7px; font-size: 0.76rem; cursor: pointer; }
.pdf-seg button.on { border-color: var(--primary); color: var(--text); background: rgba(233,69,96,0.12); font-weight: 600; }
.pdf-rooms { margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; max-height: 180px; overflow-y: auto; background: var(--bg-input); }
.pdf-rooms .prh { position: sticky; top: 0; background: var(--bg-card); padding: 7px 10px; font-size: 0.7rem; color: var(--text-muted); display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); }
.pdf-rooms .prh b { color: var(--primary); }
.pdf-rooms .prh a { color: var(--primary); cursor: pointer; }
.pdf-rooms label { display: flex; align-items: center; gap: 9px; padding: 8px 10px; font-size: 0.8rem; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.03); }
.pdf-rooms label:last-child { border-bottom: none; }
.pdf-rooms label input { width: 17px; height: 17px; accent-color: var(--primary); flex-shrink: 0; }
.list-item {
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s, transform 0.2s;
}
.list-item:active { background: var(--bg-input); }
.list-item-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}
.list-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Device row — fixed 56px for virtual scroll */
.device-row {
  display: flex;
  align-items: center;
  min-height: var(--row-h);
  padding: 6px 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border-left: 3px solid var(--border);
  cursor: pointer;
  gap: 8px;
  transition: background 0.15s;
  overflow: hidden;
  margin-bottom: 2px;
}
.device-row:active { background: var(--bg-input); }
.device-row.status-ok { border-left-color: var(--ok); }
.device-row.status-fail { border-left-color: var(--fail); }
.device-row.status-vyprselo { border-left-color: var(--fail); }
.device-row.status-brzy { border-left-color: var(--warn); }
.device-row.status-vyhovuje { border-left-color: var(--ok); }
.device-row.status-nevyhovuje { border-left-color: var(--fail); }
/* Levý proužek dle TERMÍNOVÉHO koše (colorblind-safe: šedá/hnědá/modrá/zlatá) — přebíjí status- výše */
.device-row.bkt-vyprselo { border-left-color: #565d6b; }
.device-row.bkt-brzy { border-left-color: #9c6738; }
.device-row.bkt-mesic { border-left-color: #2f80ed; }
.device-row.bkt-rok { border-left-color: #e6c14a; }
.device-row .dr-line1 { display: flex; align-items: center; gap: 6px; }
.device-row .dr-inv { color: #5bd3a6; }         /* zelenkavá INV (čitelné i pro barvosleposti) */
.device-row .dr-zminula { font-size: 0.72rem; opacity: 0.75; }
.device-row .dr-meta.dr-fail { color: #f5484d; font-weight: 600; }

.device-row .dr-status {
  width: 26px;
  text-align: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.device-row .dr-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.device-row .dr-inv {
  font-weight: 600;
  font-size: 0.85rem;
  margin-right: 6px;
}
.device-row .dr-name {
  font-size: 0.8rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-row .dr-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-row .dr-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn-action-row {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.btn-action-row:active { opacity: 0.7; }

/* Zakázka detail — flex layout so device list fills remaining space */
.zakazka-detail {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 12px);
  margin-bottom: calc(-1 * var(--nav-h));
  padding-bottom: var(--nav-h);
  box-sizing: border-box;
}

/* Device list wrap — fills remaining space, scrolls */
#device-list-wrap {
  flex: 1 1 auto;
  min-height: 100px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Čtečka mode indicator */
.ctecka-active #search-device {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(233,69,96,0.3);
}
.ctecka-badge {
  position: absolute;
  /* 8px + místo pro tlačítko ✕ (search-clear), ať se nepřekrývají */
  right: 46px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--primary);
  font-weight: 600;
  pointer-events: none;
}

/* Device stats bar */
.device-stats {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  flex-wrap: wrap;
}

/* ========== BADGES ========== */
.badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-input);
}
.badge-active { color: var(--ok); }
.badge-closed { color: var(--text-muted); }
.badge-ok { background: rgba(76,175,80,0.2); color: var(--ok); }
.badge-fail { background: rgba(244,67,54,0.2); color: var(--fail); }
.badge-warn { background: rgba(255,152,0,0.2); color: var(--warn); }

/* ========== TOOLBAR ========== */
.toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 100px;
  padding: 6px 10px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

/* ========== KOMBI SCREEN ========== */
.kombi-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 12px;
}
.kombi-section legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  padding: 0 6px;
}
.kombi-prev { background: rgba(255,255,255,0.02); }
.kombi-new { border-color: var(--primary); }
.prev-result { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.prev-note { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.prev-values { display: flex; gap: 10px; font-size: 0.75rem; color: var(--text-muted); flex-wrap: wrap; }
.result-row { margin-top: 10px; }

/* Presety bar */
.presety-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 0;
  scrollbar-width: none;
}
.presety-bar::-webkit-scrollbar { display: none; }
.preset-chip {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.7rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
}
.preset-chip:active { background: var(--primary); border-color: var(--primary); }

/* old ac-wrap moved to kombi section */

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h2 { font-size: 1rem; margin-bottom: 12px; }
.modal-box .modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #fff;
  background: var(--bg-card);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-info { background: var(--bg-card); }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--fail); }
.toast-warn { background: var(--warn); color: #000; }

/* ========== SCANNER ========== */
.scanner-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 500;
  display: flex;
  flex-direction: column;
}
.scanner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  color: #fff;
  font-size: 0.85rem;
}
.scanner-video {
  flex: 1;
  width: 100%;
  object-fit: cover;
}
.scanner-line {
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--primary);
  opacity: 0.7;
  animation: scanline 2s ease-in-out infinite;
}
@keyframes scanline {
  0%, 100% { top: 35%; }
  50% { top: 65%; }
}
.scanner-manual {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-card);
}
.scanner-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Min 16px — iOS by jinak zoomoval po focusu (čtečka skenuje rychle, zoom by rušil). */
  font-size: 16px;
}

/* ========== TABS (Šablony, Admin) ========== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== ZAKAZKA INFO ========== */
.zakazka-info {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ========== SWIPE ========== */
.swipe-wrap {
  touch-action: pan-y;
  overflow: hidden;
}
.swipe-hint {
  pointer-events: none;
  z-index: -1;
}
.swipe-tip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.swipe-tip strong { color: var(--text); }
.swipe-tip-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 4px;
}

/* ========== SETTINGS ========== */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row label { font-size: 0.85rem; }
.setting-row select, .setting-row input {
  padding: 4px 8px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Min 16px — viz globální pravidlo. iOS Safari zoomuje cokoli pod. */
  font-size: 16px;
}

/* ========== SHARING ========== */
.share-code {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin: 12px 0;
}
.share-qr {
  display: block;
  margin: 12px auto;
  max-width: 200px;
  border-radius: var(--radius);
}

/* ========== PROFIL ========== */
.profil-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 auto 12px;
}

/* ========== UTILITIES ========== */
.text-ok { color: var(--ok); }
.text-fail { color: var(--fail); }
.text-warn { color: var(--warn); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.loading { color: var(--text-muted); text-align: center; padding: 20px; }
.empty-state { color: var(--text-muted); text-align: center; padding: 20px; font-size: 0.85rem; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ========== OFFLINE BAR ========== */
.offline-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--warn);
  color: #000;
  text-align: center;
  padding: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  z-index: 1000;
  display: none;
}
body.offline .offline-bar { display: block; }
body.offline #app { padding-top: 28px; }

/* ========== VIRTUAL SCROLL ========== */
.vs-viewport {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========== HISTORY TABLE ========== */
.history-table {
  width: 100%;
  font-size: 0.68rem;
  border-collapse: collapse;
  line-height: 1.15;
}
.history-table th {
  text-align: left;
  padding: 3px 4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-size: 0.62rem;
}
.history-table td {
  padding: 3px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.history-table tr.rv-ok td:first-child { color: var(--ok); }
.history-table tr.rv-fail td:first-child { color: var(--fail); }

/* Full-width buttons */
.btn-full { width: 100%; padding: 12px; font-size: 1rem; }
.btn-fail { background: var(--fail); color: #fff; border: none; }
.btn-fail:active { opacity: 0.8; }

/* ========== RESPONSIVE ========== */
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 641px) {
  #app { max-width: 960px; }
  .device-row { padding: 0 16px; }
}

/* ========== KOMBI SCREEN ========== */
.kombi-screen {
  padding-bottom: 24px;
}

/* Numbered section labels with line */
.kombi-label-line {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 14px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Uppercase sub-labels */
.kombi-sub-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 3px;
  min-height: 1.9em;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 4px;
}

/* Preset icon grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.preset-icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.preset-icon-btn:active,
.preset-icon-btn.active {
  background: var(--primary);
  border-color: var(--primary);
}
.pi-icon {
  font-size: 1.2rem;
  line-height: 1;
}
.pi-label {
  font-size: 0.55rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Bigger inputs for main fields */
.input-big {
  font-size: 1.05rem !important;
  padding: 10px 28px 10px 10px !important;
}

/* Round S+1 button */
.btn-round {
  min-width: 48px;
  height: 42px;
  border-radius: 21px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 12px;
}

/* Toggle row (Třída I / II) */
.toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.toggle-btn {
  flex: 1;
  padding: 10px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.toggle-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.toggle-btn:not(.active):active {
  background: var(--bg-card);
}

/* Fix input-clear always visible inside kombi */
.kombi-screen .input-wrap .input-clear {
  display: block;
  opacity: 0.4;
}
.kombi-screen .input-wrap input:not(:placeholder-shown) + .input-clear,
.kombi-screen .input-wrap input:focus + .input-clear {
  opacity: 1;
}

/* Autocomplete wrap — focus-within raises z-index above siblings */
.ac-wrap {
  position: relative;
  z-index: 1;
}
.ac-wrap:focus-within {
  z-index: 9000;
}
.ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--primary);
  border-radius: 0 0 var(--radius) var(--radius);
  /* dvh respektuje vyjetou klávesnici (dynamic viewport height).
     Dropdown tak nezůstane částečně pod klávesnicí. */
  max-height: min(45dvh, 340px);
  /* Fallback pro starší prohlížeče bez dvh */
  max-height: min(45vh, 340px);
  max-height: min(45dvh, 340px);
  overflow-y: auto;
  padding-bottom: 8px;
  z-index: 9999;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  -webkit-overflow-scrolling: touch;
  /* pan-y: dovolí vertikální scroll prstem (= seznam značek/místností lze
     procházet), ale vypne pinch-zoom a horizontální gesta. Manipulation tady
     bylo nesprávně — ta neumí rozlišit scroll od tap a v kombinaci s pointerdown
     dělala seznam "neslétavatelný". */
  touch-action: pan-y;
}
.ac-list.show { display: block; }
/* Překlopení nahoru — když je pole u klávesnice, seznam se otevře nad polem,
   aby spodní položky neskončily za klávesnicí (iPhone). */
.ac-list.ac-up {
  top: auto;
  bottom: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
}
.ac-item {
  padding: 14px 14px;
  min-height: 48px;
  box-sizing: border-box;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* Rychlejší tap + prevence selection během scrollu */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: rgba(233,69,96,0.2);
}
.ac-item:active,
.ac-item.highlighted {
  background: var(--primary);
  color: #fff;
}
.ac-item .ac-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Header buttons alignment for kombi */
.kombi-screen .app-header {
  gap: 6px;
}
.btn-ok {
  background: var(--ok);
  color: #fff;
  border: none;
}
.btn-ok:active { opacity: 0.8; }

/* Majitel / Provozovatel row */
.kombi-screen .form-row {
  margin-bottom: 4px;
}

/* Textarea full-width */
.kombi-screen textarea {
  width: 100%;
  resize: vertical;
}

/* Input-wrap inside kombi textarea */
.kombi-screen .input-wrap textarea {
  flex: 1;
  padding-right: 28px;
}

/* Disabled fields (bez přívodu) */
.kombi-screen select:disabled,
.kombi-screen input:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: var(--bg-card);
}

/* === Measurement validation === */
.limit-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}
.val-msg {
  font-size: 0.75rem;
  min-height: 0;
  line-height: 1.3;
  padding: 0 2px;
  transition: all 0.15s;
}
.val-msg-warn {
  color: #f59e0b;
  padding-top: 2px;
}
.val-msg-fail {
  color: #ef4444;
  font-weight: 600;
  padding-top: 2px;
}
input.val-ok {
  border-color: var(--ok) !important;
}
input.val-warn {
  border-color: #f59e0b !important;
  background: rgba(245, 158, 11, 0.08) !important;
}
input.val-fail {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.12) !important;
  animation: val-pulse 0.4s ease;
}
@keyframes val-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* ===== Multi-select advanced filters + Dnes sort + souhrn ===== */
.adv-filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  gap: 8px;
}
.filter-summary {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: 400;
}
.dnes-sort-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  flex-wrap: wrap;
}
.dnes-sort-row .adv-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}
.sort-btn {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
}
.sort-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== Historie revizí — poslední zvýrazněná ===== */
.history-table tr.last-rev-ok {
  background: rgba(76,175,80,0.18);
  font-weight: 600;
}
.history-table tr.last-rev-fail {
  background: rgba(244,67,54,0.18);
  font-weight: 600;
}
.history-table tr.rev-editable { transition: background 0.2s; }
.history-table tr.rev-editable:hover { filter: brightness(1.1); }
/* Ikonky v historii revizí — hit target 36x36 aby šly trefit prstem */
.history-table .rev-edit-icon,
.history-table .rev-delete-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  font-size: 1rem;
  padding: 4px;
  margin: 0 2px;
  border-radius: 4px;
}
.history-table .rev-edit-icon:active,
.history-table .rev-delete-icon:active { background: rgba(255,255,255,0.1); }
.last-rev-badge {
  display: inline-block;
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  vertical-align: middle;
}
.last-rev-badge.ok { background: var(--ok); color: #fff; }
.last-rev-badge.fail { background: var(--fail); color: #fff; }

/* ===== Zvýraznění povinných kolonek ===== */
.highlight-required input,
.highlight-required select,
.highlight-required textarea,
input.highlight-required,
select.highlight-required,
textarea.highlight-required {
  border: 2px solid var(--ok) !important;
  box-shadow: 0 0 0 1px rgba(76,175,80,0.25);
}

/* ===== Centrování vycentrovaného řádku s jedním polem ===== */
.form-row-center {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.form-row-center > div { width: 48%; }

/* ===== Historie revizí — zjištěno na druhém řádku ===== */
.history-table tr.hist-zjist td {
  border-bottom: 1px solid var(--border);
  padding: 2px 6px 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: normal;
}
.history-table tr.hist-zjist td b {
  color: var(--text);
  font-weight: 500;
  margin-right: 6px;
}
