/* ============================================================
   SMĚNY – mobile-first vzhled, žádné externí knihovny
   Automaticky světlý / tmavý režim podle nastavení telefonu
   ============================================================ */

:root {
  --bg: #f4f1ec;
  --card: #ffffff;
  --card2: #f7f4ef;
  --ink: #23201c;
  --muted: #7a7268;
  --line: #e6e0d7;
  --accent: #b4451f;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3da;
  --accent-soft-ink: #8a3417;
  --ok: #2e7d4f;
  --ok-soft: #dff0e5;
  --danger: #bd3434;
  --danger-soft: #f8dfdf;
  --warn: #96650a;
  --warn-soft: #f5e9cd;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 32, 28, .05), 0 4px 16px rgba(35, 32, 28, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --card: #211f1c;
    --card2: #2a2723;
    --ink: #efeae2;
    --muted: #a59c90;
    --line: #3a352e;
    --accent: #e06a3f;
    --accent-ink: #201008;
    --accent-soft: #3d271d;
    --accent-soft-ink: #f2b79e;
    --ok: #63bd8b;
    --ok-soft: #24352b;
    --danger: #e57e7e;
    --danger-soft: #3d2626;
    --warn: #ddab4a;
    --warn-soft: #3a3122;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body.has-nav { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .35rem 0 .7rem; }
a { color: var(--accent); text-underline-offset: 2px; }
code { background: var(--card2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.ic { flex: none; vertical-align: -4px; }

/* ---------- horní lišta ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-in {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
  min-height: 54px;
}

.topbar-tit { flex: 1; min-width: 0; }
.topbar-tit h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: .74rem; color: var(--muted); margin-top: -2px; }

.topbar-akce {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 12px;
}
.topbar-akce:active { background: var(--card2); }
.topbar-jmeno { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-zpet {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-left: -8px;
  border-radius: 12px;
  color: var(--ink);
}
.topbar-zpet:active { background: var(--card2); }

/* ---------- obsah ---------- */

.obsah {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 14px 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card h2 { margin-bottom: .35rem; }

.flash {
  max-width: 680px;
  margin: 10px auto 0;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: .95rem;
  width: calc(100% - 28px);
  transition: opacity .4s, transform .4s;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-err { background: var(--danger-soft); color: var(--danger); }
.flash.mizi { opacity: 0; transform: translateY(-6px); }

/* ---------- dolní navigace ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar-in {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  max-width: 680px;
  margin: 0 auto;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: .68rem;
  font-weight: 600;
  border-radius: 14px;
  margin: 4px 3px;
}
.tab.aktivni { color: var(--accent); background: var(--accent-soft); }
.tab:active { background: var(--card2); }
.tab.aktivni:active { background: var(--accent-soft); }

/* ---------- tlačítka ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 18px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform .06s;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-blok { display: flex; width: 100%; }
.btn-velke { display: flex; width: 100%; min-height: 56px; font-size: 1.05rem; }
.btn-mini { min-height: 40px; padding: 6px 14px; font-size: .9rem; border-radius: 11px; }
.btn-carkovane { border-style: dashed; color: var(--muted); background: transparent; }

/* ---------- formuláře ---------- */

.pole { display: block; margin-bottom: 12px; font-size: .86rem; font-weight: 600; color: var(--muted); }

.pole input, .pole select, .pole textarea,
input[type="time"], input[type="date"] {
  display: block;
  width: 100%;
  margin-top: 5px;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
}
.pole textarea { min-height: 84px; resize: vertical; }
.pole input:focus, .pole select:focus, .pole textarea:focus,
.btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.rada { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rada-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.rada > *, .rada-3 > * { min-width: 0; }
input[type="date"], input[type="time"] { max-width: 100%; }

.zaskrtavaci {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 12px 0;
  font-size: .95rem;
}
.zaskrtavaci input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }

/* výběrové „čipy" (důvody ztrát, přestávky) */
.vyber-chipy { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.vyber-chipy label { position: relative; }
.vyber-chipy input { position: absolute; opacity: 0; inset: 0; }
.vyber-chipy span {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
}
.vyber-chipy input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-soft-ink);
}
.vyber-chipy input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------- přihlášení ---------- */

.login-hlava { text-align: center; padding: 18px 0 6px; }
.login-logo { width: 86px; height: 86px; border-radius: 22px; box-shadow: var(--shadow); }
.login-podnik { margin: 12px 0 2px; font-size: 1.35rem; }
.login-pokyn { color: var(--muted); margin: 0 0 14px; }

.login-jmena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn-jmeno { min-height: 64px; font-size: 1.12rem; }

.pin-blok { max-width: 320px; margin: 0 auto; }

.pin-tecky { display: flex; justify-content: center; gap: 16px; margin: 20px 0 22px; }
.pin-tecky span {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  transition: background .12s, border-color .12s;
}
.pin-tecky span.plna { background: var(--accent); border-color: var(--accent); }

.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-kl {
  min-height: 68px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .05s;
  -webkit-user-select: none;
  user-select: none;
}
.pin-kl:active { transform: scale(.94); background: var(--card2); }
.pin-zpet, .pin-smaz { font-size: 1.05rem; color: var(--muted); box-shadow: none; background: transparent; }

/* ---------- seznamy a řádky ---------- */

.radek {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.radek:first-child { border-top: 0; }
.radek-hlavni { flex: 1; min-width: 0; }
.radek-tit { font-weight: 700; }
.radek-pop { font-size: .85rem; color: var(--muted); }

.den-nadpis {
  font-size: .85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 18px 4px 8px;
}
.den-nadpis.dnes { color: var(--accent); }

/* ---------- čipy, odznaky ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--card2);
  font-size: .8rem;
  font-weight: 700;
}
.chip-tecka { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 800;
  white-space: nowrap;
}
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-ceka { background: var(--warn-soft); color: var(--warn); }
.b-chybi { background: var(--danger-soft); color: var(--danger); }
.b-navrh { background: transparent; color: var(--muted); border: 1.5px dashed var(--muted); }
.b-info { background: var(--accent-soft); color: var(--accent-soft-ink); }

/* ---------- dostupnost: mřížka dnů ---------- */

.dg-hlavicka {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  text-align: center;
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
}

.dg-tyden { margin-bottom: 14px; }
.dg-popisek { font-size: .78rem; color: var(--muted); font-weight: 700; margin: 0 2px 5px; }

.dg-mrizka { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }

.dg-den {
  position: relative;
  min-height: 56px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 0;
  -webkit-user-select: none;
  user-select: none;
}
.dg-den small { font-size: .58rem; font-weight: 700; color: var(--muted); line-height: 1.1; }
.dg-den:active { transform: scale(.95); }

.dg-ne { background: var(--danger-soft); border-color: var(--danger); }
.dg-ne small { color: var(--danger); }
.dg-cast { background: var(--warn-soft); border-color: var(--warn); }
.dg-cast small { color: var(--warn); }
.dg-lock { opacity: .45; cursor: default; }
.dg-lock:active { transform: none; }
.dg-dnes { outline: 2px solid var(--accent); outline-offset: 1px; }
.dg-mimo { visibility: hidden; }

/* ---------- spodní „sheet" ---------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.sheet-overlay.viditelny { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform .25s cubic-bezier(.3, .9, .3, 1);
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
}
.sheet.viditelny { transform: none; }
.sheet-madlo { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { font-size: 1.1rem; }
.sheet .obsah-sheet { max-width: 640px; margin: 0 auto; }

/* ---------- plán (admin) ---------- */

.tyden-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.tyden-nav .btn { min-height: 46px; padding: 8px 16px; }
.tyden-nav strong { font-size: 1.02rem; }

.den-chipy {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}
.den-chip {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 7px 2px;
  font: inherit;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  position: relative;
}
.den-chip b { font-size: .95rem; }
.den-chip.aktivni { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.den-chip .tecka-chybi {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}
.den-chip.aktivni .tecka-chybi { background: #fff; }

.provoz-hlava {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
  font-weight: 800;
}
.provoz-hlava .chip-tecka { width: 11px; height: 11px; }

.slot-skupina { padding: 9px 0; border-top: 1px solid var(--line); }
.slot-skupina:first-of-type { border-top: 0; }
.slot-cas { font-size: .84rem; font-weight: 700; color: var(--muted); margin-bottom: 7px; }

.slot-lide { display: flex; flex-wrap: wrap; gap: 8px; }

.os-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
}
.os-chip.navrh { background: transparent; border: 1.5px dashed var(--accent); color: var(--accent); }
.os-chip:active { transform: scale(.96); }

.slot-prazdny {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1.5px dashed var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
}

.kandidat { width: 100%; text-align: left; }
.kandidat .radek-pop { font-weight: 400; }

/* ---------- tabulky ---------- */

.table-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }

table.tabulka { border-collapse: collapse; width: 100%; font-size: .88rem; }
.tabulka th, .tabulka td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
.tabulka th { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.tabulka td.cislo, .tabulka th.cislo { text-align: right; }

/* mřížka potřeby lidí */
.potreba-vstup { width: 52px; min-height: 44px; text-align: center; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; font-weight: 700; padding: 6px 2px; }

/* ---------- měsíční přehled (lidé × dny) ---------- */

.mp-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mp-tab th, .mp-tab td { padding: 5px 6px; }
.mp-tab th { line-height: 1.15; }
.mp-jmeno {
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 2;
  box-shadow: 2px 0 0 var(--line);
  font-weight: 700;
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-vikend { background: var(--card2); }
.mp-dnes { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.mp-x { color: var(--accent); font-weight: 800; font-size: 1.02rem; }
.mp-x.mp-pozor {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 8px;
  padding: 1px 5px;
}
.mp-navrh { color: var(--muted); font-weight: 800; font-size: 1.15rem; }
.mp-ned { color: var(--danger); font-weight: 800; }

/* ---------- graf nákladů (sloupce po dnech) ---------- */

.gr-obal {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  min-height: 190px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 0;
}
.gr-sloupec {
  flex: 1 0 auto;
  min-width: 16px;
  max-width: 46px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  gap: 0;
}
.gr-bar {
  background: var(--accent);
  border-radius: 4px 4px 0 0;
}
.gr-bar.gr-plan {
  background: var(--accent-soft);
  border: 1.5px dashed var(--accent);
  border-bottom: 0;
}
.gr-castka { font-size: .58rem; font-weight: 800; text-align: center; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.gr-pop { font-size: .6rem; font-weight: 700; text-align: center; color: var(--muted); line-height: 1.15; margin-top: 4px; }
.gr-pop.gr-vikend { color: var(--danger); }
.gr-dnes .gr-pop { color: var(--accent); }
.gr-vzorek {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
  vertical-align: -1px;
}
.gr-vzorek-plan { background: var(--accent-soft); border: 1.5px dashed var(--accent); }

/* ---------- statistiky ---------- */

.stat-mrizka { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat-cislo { font-size: 1.45rem; font-weight: 800; }
.stat-pop { font-size: .78rem; color: var(--muted); font-weight: 600; }

/* ---------- ztráty ---------- */

.ztrata-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); flex: none; }

/* ---------- instalace ---------- */

.kontroly { list-style: none; margin: 0; padding: 0; }
.kontroly li { padding: 7px 0; border-top: 1px solid var(--line); font-size: .95rem; }
.kontroly li:first-child { border-top: 0; }
.k-ok { color: var(--ok); }
.k-chyba { color: var(--danger); font-weight: 700; }
.k-varovani { color: var(--warn); }
.ok-blok { text-align: center; padding: 28px 18px; }
.dulezite { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 14px; }

/* ---------- drobnosti ---------- */

.ztlum { color: var(--muted); font-size: .87rem; }
.text-chyba { color: var(--danger); font-weight: 700; }
.text-ok { color: var(--ok); font-weight: 700; }
.skryte { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mezera { height: 10px; }
.pravy { text-align: right; }
.stred { text-align: center; }

.prazdno {
  text-align: center;
  color: var(--muted);
  padding: 42px 18px;
}
.prazdno .ic { width: 44px; height: 44px; opacity: .5; }

details.rozbal > summary {
  cursor: pointer;
  font-weight: 700;
  padding: 10px 0;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- větší obrazovky ---------- */

@media (min-width: 720px) {
  .obsah, .topbar-in, .flash, .tabbar-in { max-width: 760px; }
  .login-jmena { grid-template-columns: repeat(3, 1fr); }
  .dg-den { min-height: 64px; }
  .sheet { max-width: 560px; left: 50%; transform: translate(-50%, 105%); border-radius: 22px; bottom: 18px; }
  .sheet.viditelny { transform: translate(-50%, 0); }
}
