/* ============================================================
   CRM Salesmani — mobile first.
   Pravidla, kterých se držíme: velké dotykové cíle (min 48 px),
   jedna věc na obrazovce, čísla velká a čitelná na první pohled.
   ============================================================ */

:root {
  --plocha:        #f4f5f7;
  --karta:         #ffffff;
  --text:          #101828;
  --text-tlumeny:  #667085;
  --linka:         #e4e7ec;

  --hlavni:        #1d4ed8;
  --na-vyplni:     #ffffff;
  --hlavni-tmavy:  #1e40af;
  --hlavni-svetly: #eff4ff;

  --uspech:        #067647;
  --uspech-svetly: #ecfdf3;
  --varovani:      #b54708;
  --varovani-svetly:#fffaeb;
  --chyba:         #b42318;
  --chyba-svetly:  #fef3f2;

  --r:    14px;
  --r-male: 10px;
  --stin: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --stin-vyssi: 0 8px 24px rgba(16, 24, 40, .12);

  --nav-vyska: calc(64px + env(safe-area-inset-bottom));
}

@media (prefers-color-scheme: dark) {
  :root {
    --plocha:        #0f1116;
    --karta:         #181b22;
    --text:          #f2f4f7;
    --text-tlumeny:  #98a2b3;
    --linka:         #2a2f3a;

    --hlavni:        #6a94ff;
    --na-vyplni:     #0b1220;
    --hlavni-tmavy:  #4f7ffb;
    --hlavni-svetly: #1a2340;

    --uspech:        #5fd39a;
    --uspech-svetly: #10241c;
    --varovani:      #f7b955;
    --varovani-svetly:#2a2010;
    --chyba:         #ff8a80;
    --chyba-svetly:  #2b1614;

    --stin: none;
    --stin-vyssi: 0 8px 24px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--plocha);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }

.skryto { display: none !important; }
.tlumene { color: var(--text-tlumeny); font-size: .875rem; margin: 0; }
.stred { text-align: center; }

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

.prihlaseni {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.prihlaseni__karta { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.prihlaseni__logo { font-size: 2.5rem; text-align: center; }
.prihlaseni h1 { text-align: center; }
.prihlaseni .tlumene { text-align: center; margin-bottom: 4px; }

/* ---------- Kostra aplikace ---------- */

.hlavicka {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--karta) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--linka);
}

.obsah {
  padding: 14px 14px calc(var(--nav-vyska) + 84px);
  display: grid;
  gap: 14px;
  max-width: 760px;
  margin: 0 auto;
}

/* ---------- Spodní navigace ---------- */

.navigace {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: flex;
  background: color-mix(in srgb, var(--karta) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--linka);
  padding-bottom: env(safe-area-inset-bottom);
}
.navigace button {
  flex: 1;
  display: grid; gap: 2px; justify-items: center;
  min-height: 64px;
  padding: 8px 2px;
  border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .7rem; font-weight: 600;
  color: var(--text-tlumeny);
}
.navigace button span { font-size: 1.35rem; line-height: 1; }
.navigace button[aria-current="page"] { color: var(--hlavni); }

/* ---------- Plovoucí tlačítko ---------- */

.fab {
  position: fixed; z-index: 29;
  right: 16px; bottom: calc(var(--nav-vyska) + 14px);
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 0 22px;
  border: 0; border-radius: 999px;
  background: var(--hlavni); color: var(--na-vyplni);
  font: inherit; font-size: 1rem; font-weight: 700;
  box-shadow: var(--stin-vyssi);
  cursor: pointer;
}
.fab span { font-size: 1.4rem; line-height: 1; }
.fab:active { transform: scale(.97); }

/* ---------- Karty ---------- */

.karta {
  background: var(--karta);
  border: 1px solid var(--linka);
  border-radius: var(--r);
  box-shadow: var(--stin);
  padding: 16px;
}
.karta--tesna { padding: 0; overflow: hidden; }

.sekce { display: grid; gap: 10px; }
.sekce__hlavicka { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

/* ---------- Velké tlačítko start/stop ---------- */

.smena { display: grid; gap: 10px; text-align: center; }
.smena p { margin: 0; }
.smena__stav { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-tlumeny); }
.smena__cas { font-size: 3.25rem; line-height: 1.1; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.smena__cas--bezi { color: var(--uspech); }
.smena__od { font-size: .875rem; color: var(--text-tlumeny); }


/* ---------- Tlačítka ---------- */

.tl {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r-male);
  font: inherit; font-weight: 600; color: var(--text);
  background: var(--karta);
  cursor: pointer;
}
.tl:active { transform: scale(.98); }
.tl:disabled { opacity: .5; cursor: default; transform: none; }
.tl--hlavni { background: var(--hlavni); color: var(--na-vyplni); }
.tl--obrys  { background: transparent; border-color: var(--linka); }
.tl--tiche  { background: transparent; border-color: transparent; color: var(--hlavni); padding: 0 8px; }
.tl--nebezpeci { background: transparent; border-color: var(--linka); color: var(--chyba); }
.tl--velke  { min-height: 54px; font-size: 1.05rem; width: 100%; }
.tl--male   { min-height: 40px; font-size: .875rem; }
.tl--siroke { width: 100%; }

/* Start/stop směny — musí stát až za .tl, jinak by ho základní pravidlo přebilo. */
.tl--smena { min-height: 68px; font-size: 1.15rem; border-radius: var(--r); }
.tl--start { background: var(--uspech); border-color: var(--uspech); color: var(--na-vyplni); }
.tl--stop  { background: var(--chyba);  border-color: var(--chyba);  color: var(--na-vyplni); }

.tlacitka { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }

/* ---------- Formulářová pole ---------- */

.pole { display: grid; gap: 6px; }
.pole > span { font-size: .8rem; font-weight: 600; color: var(--text-tlumeny); }
.pole input, .pole select, .pole textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--plocha);
  border: 1px solid var(--linka);
  border-radius: var(--r-male);
  appearance: none;
}
.pole textarea { min-height: 84px; resize: vertical; }
.pole input:focus, .pole select:focus, .pole textarea:focus {
  outline: 2px solid var(--hlavni); outline-offset: 1px; border-color: transparent;
}
.pole select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-tlumeny) 50%),
                    linear-gradient(135deg, var(--text-tlumeny) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.dvojice { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

.formular { display: grid; gap: 14px; }

/* ---------- Volba výsledku (velké dlaždice) ---------- */

.volby { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.volba {
  display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 8px 12px;
  border: 1.5px solid var(--linka); border-radius: var(--r-male);
  background: var(--karta);
  font-size: .9rem; font-weight: 600;
  cursor: pointer; text-align: left;
}
.volba input { position: absolute; opacity: 0; pointer-events: none; }
.volba:has(input:checked) { border-color: var(--hlavni); background: var(--hlavni-svetly); color: var(--hlavni); }
.volba__tecka { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--text-tlumeny); }

/* ---------- Statistické dlaždice ---------- */

.dlazdice { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.dlazdice--tri { grid-template-columns: repeat(3, 1fr); }
.dlazdice__polozka {
  background: var(--karta); border: 1px solid var(--linka); border-radius: var(--r);
  padding: 12px; text-align: center; box-shadow: var(--stin);
}
.dlazdice__cislo { font-size: 1.65rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dlazdice__popis { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-tlumeny); }
.dlazdice__polozka--uspech .dlazdice__cislo { color: var(--uspech); }
.dlazdice__polozka--hlavni .dlazdice__cislo { color: var(--hlavni); }

/* ---------- Seznamy ---------- */

.seznam { display: grid; }
.polozka {
  display: grid; gap: 4px;
  width: 100%;
  padding: 14px 16px;
  border: 0; border-bottom: 1px solid var(--linka);
  background: var(--karta);
  font: inherit; color: inherit; text-align: left;
  cursor: pointer;
}
.polozka:last-child { border-bottom: 0; }
.polozka:active { background: var(--plocha); }
.polozka__radek { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.polozka__nazev { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.polozka__meta { font-size: .8rem; color: var(--text-tlumeny); display: flex; gap: 8px; flex-wrap: wrap; }
.polozka__cas { font-size: .8rem; font-weight: 700; color: var(--text-tlumeny); font-variant-numeric: tabular-nums; white-space: nowrap; }

.oddelovac {
  padding: 14px 4px 2px;
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-tlumeny);
}

/* ---------- Štítky ---------- */

.stitek {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; white-space: nowrap;
  background: var(--plocha); color: var(--text-tlumeny);
}
.stitek--uspech { background: var(--uspech-svetly); color: var(--uspech); }
.stitek--varovani { background: var(--varovani-svetly); color: var(--varovani); }
.stitek--chyba { background: var(--chyba-svetly); color: var(--chyba); }
.stitek--hlavni { background: var(--hlavni-svetly); color: var(--hlavni); }
.stitek--bezi::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: puls 1.6s ease-in-out infinite; }
@keyframes puls { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------- Filtry ---------- */

.filtry {
  display: flex; gap: 8px; overflow-x: auto;
  margin: 0 -14px; padding: 0 14px 2px;
  scrollbar-width: none;
}
.filtry::-webkit-scrollbar { display: none; }
.filtr {
  flex: 0 0 auto;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--linka); border-radius: 999px;
  background: var(--karta); color: var(--text-tlumeny);
  font: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer;
}
.filtr[aria-pressed="true"] { background: var(--hlavni); border-color: var(--hlavni); color: var(--na-vyplni); }

.hledani { position: relative; }
.hledani input { padding-left: 40px; }
.hledani::before { content: "🔍"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: .95rem; opacity: .6; }

/* ---------- Graf (jednoduché sloupce) ---------- */

.graf { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 8px; }
.graf__den { flex: 1; display: grid; align-content: end; justify-items: center; min-width: 0; }
.graf__sloupec { width: 100%; background: var(--hlavni); }
.graf__den > .graf__sloupec:first-child { border-radius: 4px 4px 0 0; }
.graf__sloupec--uspech { background: var(--uspech); }
.graf__popis { margin-top: 4px; font-size: .6rem; color: var(--text-tlumeny); white-space: nowrap; }

.pruh { display: grid; gap: 4px; }
.pruh__vrch { display: flex; justify-content: space-between; font-size: .85rem; }
.pruh__drah { height: 8px; border-radius: 999px; background: var(--plocha); overflow: hidden; }
.pruh__vypln { height: 100%; border-radius: 999px; background: var(--hlavni); }

/* ---------- Vysouvací panel ---------- */

.panel { position: fixed; inset: 0; z-index: 50; }
.panel__pozadi { position: absolute; inset: 0; background: rgba(16, 24, 40, .55); }
.panel__obsah {
  position: absolute; inset: auto 0 0 0;
  max-height: 92dvh; overflow-y: auto;
  padding: 6px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--karta);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--stin-vyssi);
  animation: vyjed .22s ease-out;
}
@media (min-width: 700px) {
  .panel__obsah {
    inset: 50% auto auto 50%; transform: translate(-50%, -50%);
    width: min(560px, 92vw); border-radius: var(--r); animation: none;
  }
}
@keyframes vyjed { from { transform: translateY(100%) } to { transform: translateY(0) } }
.panel__uchyt { width: 40px; height: 4px; margin: 6px auto 10px; border-radius: 999px; background: var(--linka); }
.panel__hlavicka {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 4px 0 12px; margin-bottom: 4px;
  background: var(--karta);
}

/* ---------- Hlášky a toast ---------- */

.hlaska { padding: 11px 14px; border-radius: var(--r-male); font-size: .875rem; margin: 0; }
.hlaska--chyba { background: var(--chyba-svetly); color: var(--chyba); }
.hlaska--info { background: var(--hlavni-svetly); color: var(--hlavni); }

.toast {
  position: fixed; z-index: 60;
  left: 50%; bottom: calc(var(--nav-vyska) + 84px); transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 999px;
  background: #101828; color: #fff;
  font-size: .9rem; font-weight: 600;
  box-shadow: var(--stin-vyssi);
}
.toast--chyba { background: var(--chyba); }

.prazdno { padding: 36px 20px; text-align: center; color: var(--text-tlumeny); display: grid; gap: 6px; }
.prazdno__ikona { font-size: 2rem; }

.nacitani { padding: 40px; text-align: center; color: var(--text-tlumeny); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .tl:active, .fab:active { transform: none; }
}
