:root {
  --bg: #ffffff;
  --bg2: #f3f5f8;
  --text: #1d2430;
  --muted: #5f6b7a;
  --line: #d6dbe3;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #c62828;
  --s1: #2e7d32; --s2: #7cb342; --s3: #f9a825; --s4: #ef6c00; --s5: #c62828;
  --shadow: 0 2px 10px rgba(0,0,0,.18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c2129; --bg2: #262c36; --text: #e7ebf0; --muted: #9aa5b3; --line: #3a4350;
    --accent: #4d8ef0; --shadow: 0 2px 10px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; font: 14px/1.35 system-ui, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
button, .tlacitko, input, select, textarea { font: inherit; color: inherit; }
button, .tlacitko {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
  cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap;
}
button:hover, .tlacitko:hover { border-color: var(--accent); }
button.primarni { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.nebezpeci { color: var(--danger); border-color: var(--danger); background: transparent; }
button.ikona { background: none; border: none; font-size: 18px; padding: 2px 6px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}

#lista {
  position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 10; display: flex; align-items: center;
  gap: 12px; padding: 0 12px; background: var(--bg); border-bottom: 1px solid var(--line);
}
#lista .nazev { font-weight: 700; font-size: 16px; }
#lista .nazev span { font-weight: 400; color: var(--muted); }
#lista .akce { display: flex; gap: 6px; align-items: center; }
#statistika { margin-left: auto; color: var(--muted); font-size: 13px; }
#uzivatel { color: var(--muted); font-size: 13px; white-space: nowrap; }
#uzivatel .tlacitko { padding: 3px 8px; margin-left: 4px; }
.menu { position: relative; }
.rozbal {
  position: absolute; top: 38px; left: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow); padding: 6px; min-width: 260px; z-index: 30;
  display: flex; flex-direction: column; gap: 2px;
}
.rozbal button { text-align: left; border: none; background: none; padding: 8px 10px; }
.rozbal button:hover { background: var(--bg2); }
.rozbal hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

#mapa { position: fixed; top: 48px; left: 0; right: 0; bottom: 0; }
.karta { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
#vrstvy { position: fixed; top: 58px; left: 10px; z-index: 5; padding: 8px 10px; min-width: 190px; }
#vrstvy .titulek { font-weight: 600; cursor: pointer; user-select: none; }
#vrstvy label { display: block; padding: 2px 0; cursor: pointer; }
#vrstvy .skupina { margin-top: 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
#vrstvy.sbaleno #vrstvyObsah { display: none; }

#kresleni { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 8; padding: 8px 10px; display: flex; gap: 8px; align-items: center; }

#panel {
  position: fixed; top: 48px; right: 0; bottom: 0; width: 400px; max-width: 100%; z-index: 9;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.panelHlava { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panelHlava h2 { margin: 0; font-size: 16px; }
#panelObsah { overflow-y: auto; padding: 12px; flex: 1; }
.pole { margin-bottom: 10px; }
.pole > label, .pole > .popisek { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.radek { display: flex; gap: 8px; }
.radek > * { flex: 1; }
.sekce { margin: 14px 0 8px; font-weight: 600; border-top: 1px solid var(--line); padding-top: 10px; display: flex; justify-content: space-between; align-items: center; }

.stavy { display: flex; gap: 4px; }
.stavy button { flex: 1; padding: 6px 0; font-weight: 600; }
.stavy button.zvolen[data-s="1"] { background: var(--s1); color: #fff; }
.stavy button.zvolen[data-s="2"] { background: var(--s2); color: #fff; }
.stavy button.zvolen[data-s="3"] { background: var(--s3); color: #000; }
.stavy button.zvolen[data-s="4"] { background: var(--s4); color: #fff; }
.stavy button.zvolen[data-s="5"] { background: var(--s5); color: #fff; }
.zavady { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; font-size: 13px; }
.zavady label { display: flex; gap: 4px; align-items: flex-start; cursor: pointer; }

.znackaKarta { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; background: var(--bg2); }
.znackaKarta .hlava { display: flex; gap: 8px; align-items: center; }
.znackaKarta .hlava img { width: 44px; height: 44px; object-fit: contain; }
.znackaKarta .hlava .txt { flex: 1; min-width: 0; }
.znackaKarta .hlava .kod { font-weight: 700; }
.znackaKarta .hlava .nm { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.znackaKarta .detail { margin-top: 8px; }
.kodVyber { display: flex; gap: 8px; align-items: center; cursor: pointer; border: 1px dashed var(--line); border-radius: 8px; padding: 6px; }
.kodVyber img { width: 40px; height: 40px; object-fit: contain; }

.fotky { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fotky .f { position: relative; }
.fotky img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: zoom-in; display: block; }
.fotky .f button { position: absolute; top: 2px; right: 2px; padding: 0 5px; font-size: 12px; background: rgba(0,0,0,.6); color: #fff; border: none; }
.tlacitka { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; position: sticky; bottom: -12px; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
.info { font-size: 12px; color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modalOkno { background: var(--bg); width: min(900px, 96vw); height: min(720px, 92vh); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.modalOkno > input { margin: 10px 12px 0; width: auto; }
#katalogSkupiny, #katalogNedavne { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px 0; }
#katalogSkupiny button.zvolen { background: var(--accent); color: var(--accent-text); }
#katalogNedavne:empty { display: none; }
#katalogNedavne img { width: 34px; height: 34px; object-fit: contain; cursor: pointer; }
#katalogMrizka { flex: 1; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; align-content: start; }
.kpol { border: 1px solid var(--line); border-radius: 8px; padding: 6px; text-align: center; cursor: pointer; background: var(--bg); }
.kpol:hover { border-color: var(--accent); }
.kpol img { width: 60px; height: 60px; object-fit: contain; }
.kpol .k { font-weight: 700; font-size: 12px; }
.kpol .n { font-size: 11px; color: var(--muted); line-height: 1.2; max-height: 2.4em; overflow: hidden; }
#foto img { max-width: 96vw; max-height: 92vh; }

/* mapové značky */
.mz { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.mz .stoh { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 2px; border-radius: 4px; background: rgba(255,255,255,.75); border: 2px solid transparent; }
.mz .stoh img { width: 26px; height: 26px; object-fit: contain; display: block; }
.mz .stoh .vic { font-size: 10px; font-weight: 700; color: #222; }
.mz.vybran .stoh { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,95,191,.35); }
.mz .pata { width: 10px; height: 10px; border-radius: 50%; background: #444; border: 2px solid #fff; margin-top: 1px; position: relative; }
.mz .smer { position: absolute; left: 50%; bottom: 5px; width: 0; height: 0; transform-origin: 50% 100%; pointer-events: none; z-index: 2; opacity: .9; }
.mz .smer::before { content: ""; position: absolute; left: -1.5px; bottom: 0; width: 3px; height: 30px; background: #111; box-shadow: 0 0 0 1.5px #fff; }
.mz .smer::after { content: ""; position: absolute; left: -6px; bottom: 28px; border: 6px solid transparent; border-bottom: 9px solid #111; border-top: 0; filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff); }
.mz.stav1 .pata { background: var(--s1); } .mz.stav2 .pata { background: var(--s2); } .mz.stav3 .pata { background: var(--s3); }
.mz.stav4 .pata { background: var(--s4); } .mz.stav5 .pata { background: var(--s5); }
.mz.zavada .stoh { outline: 2px dashed var(--s5); outline-offset: 1px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 50; }

table.seznam { width: 100%; border-collapse: collapse; font-size: 13px; }
table.seznam td, table.seznam th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.seznam tr:hover td { background: var(--bg2); cursor: pointer; }
table.seznam img { width: 24px; height: 24px; object-fit: contain; vertical-align: middle; }
.stavTecka { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #999; }
.st1 { background: var(--s1); } .st2 { background: var(--s2); } .st3 { background: var(--s3); } .st4 { background: var(--s4); } .st5 { background: var(--s5); }

@media (max-width: 700px) {
  #lista { gap: 6px; padding: 0 8px; }
  #lista .nazev span, #statistika, #uzivatelJmeno { display: none; }
  #uzivatel { margin-left: auto; }
  #panel { top: auto; height: 62vh; width: 100%; border-left: none; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; }
  #vrstvy { top: 56px; left: 8px; }
  .zavady { grid-template-columns: 1fr; }
}
.jenCteni .tlacitka, .jenCteni #pridatZnacku, .jenCteni .sekce label.tlacitko, .jenCteni .fotky .f button { display: none !important; }

.nahledVelky { width: 100%; max-height: 260px; object-fit: contain; border-radius: 8px; background: var(--bg2); cursor: zoom-in; display: block; margin-bottom: 4px; }
