:root {
  --blue: #3d7a2a; --blue2: #336a22;   /* zelená Profi HELP (mírně tmavší) */ --bg: #ffffff; --bg2: #f6f7f9; --line: #e3e6eb;
  --text: #1f2937; --muted: #6b7280; --danger: #dc4c3e; --radius: 8px;
  --input: #f8f9fb; --hover: #eff7ec;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181d; --bg2: #1d2027; --line: #2d313a; --text: #e6e8ec; --muted: #9aa1ad; --input: #20242c; --hover: #23302a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { background: var(--blue); }   /* iOS: barva pod stavovým řádkem (body má vlastní bílé pozadí) */
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg); -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* rozvržení: boční menu přes celou výšku | sloupec (zelená lišta + obsah) */
body { --side-w: 230px; }
body.nav-collapsed { --side-w: 64px; }
#app { display: flex; height: 100%; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#side { width: var(--side-w); flex: none; display: flex; flex-direction: column; background: var(--bg2); border-right: 1px solid var(--line);
  transition: width .18s ease; overflow: hidden; }
.side-head { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 12px) 8px 12px 12px; flex: none; }
/* logo firmy místo názvu aplikace; po sbalení menu zmizí */
.side-logo-link { flex: 1; min-width: 0; display: block; line-height: 0; }
.side-logo-full { width: 100%; max-width: 186px; height: auto; display: block; }   /* logo bez pozadí */
.side-collapse { color: var(--muted); font-size: 18px; flex: none; }
/* PC/Mac: logo je v zelené horní liště (na všech stránkách), v menu zůstane jen tlačítko sbalení */
@media (min-width: 900px) {
  .side-logo-link { display: none; }
  .side-head { justify-content: flex-end; }
}

/* horní lišta (jen nad hlavním obsahem) */
.topbar {
  display: flex; align-items: center; gap: 10px; background: var(--blue); color: #fff;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px 22px; flex: none; min-height: 56px;
  position: sticky; top: 0; z-index: 7;   /* Safari 26 podle „přilepené“ lišty obarví stavový řádek místo rozmazání */
}
.top-brand { display: block; line-height: 0; }
.top-brand img { height: 24px; width: auto; display: block; }
.topbar .top-sync { color: #fff; opacity: .9; font-size: 12px; white-space: nowrap; margin-right: 4px; }
@media (max-width: 899px) {
  .topbar { padding-left: 12px; gap: 8px; }
  .top-brand img { height: 19px; }
  .top-sync { display: none; }            /* telefon: verze a synchronizace jsou v hlavičce Přehledu */
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.spacer { flex: 1; }
.icon-btn { background: none; border: 0; font-size: 20px; padding: 6px 8px; border-radius: 6px; cursor: pointer; color: inherit; line-height: 1; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.toggle { border: 0; border-radius: 20px; width: 58px; height: 30px; background: rgba(255,255,255,.25); position: relative; cursor: pointer; }
.toggle span { position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; font-size: 13px; line-height: 24px; transition: left .15s; }
.toggle.on { background: #ffb020; }
.toggle.on span { left: 31px; }
.sync { width: 9px; height: 9px; border-radius: 50%; background: #7ee2a0; font-size: 11px; }
.sync.pending { background: #ffd166; }
.sync.off { width: auto; height: auto; background: #ff8a7a; color: #fff; padding: 1px 7px; border-radius: 10px; }

#sidebar { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 8px 10px; }
#main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }

/* sbalené menu (počítač): jen ikony, název tabulky v bublině */
body.nav-collapsed .side-logo-link, body.nav-collapsed .nav-name, body.nav-collapsed .nav-count, body.nav-collapsed .nav-title,
body.nav-collapsed .nav-item .mini, body.nav-collapsed #sidebar .add-btn { display: none; }
body.nav-collapsed .side-head { flex-direction: column; padding: 12px 0; gap: 6px; }
body.nav-collapsed .side-collapse { transform: rotate(180deg); }
body.nav-collapsed .nav-item { justify-content: center; padding: 10px 0; }
body.nav-collapsed .nav-icon { font-size: 19px; }
.nav-title { font-size: 12px; text-transform: uppercase; color: var(--muted); padding: 6px 10px; letter-spacing: .5px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-name { flex: 1; }
.nav-count { font-size: 12px; opacity: .6; }
.add-btn { width: 100%; margin-top: 8px; padding: 9px; border: 1.5px dashed var(--line); background: none; border-radius: var(--radius); cursor: pointer; color: var(--blue2); font-weight: 600; }
.add-btn:hover { border-color: var(--blue2); }

/* lišty, tlačítka */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.toolbar h1 { font-size: 20px; margin: 0; white-space: nowrap; }
.search { flex: 1; min-width: 160px; }
.search input { width: 100%; }
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 13px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; font-weight: 500; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--blue2); border-color: var(--blue2); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { border-color: transparent; }
.btn.back .back-label { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.btn.is-disabled, .link-btn.is-disabled { opacity: .45; filter: grayscale(.6); }   /* akce teď nejde – po kliknutí se ukáže proč */
.link-btn { background: none; border: 0; color: var(--blue2); cursor: pointer; padding: 6px 4px; font-weight: 500; }
.mini { background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; padding: 2px 7px; font-size: 13px; color: var(--text); text-decoration: none; line-height: 1.5; }
.mini.danger { color: var(--danger); }
.muted { color: var(--muted); }
.grid td.card-head, .grid td.card-tags { display: none; }   /* jen pro kartové zobrazení na telefonu */
.small { font-size: 12px; }
.strong { font-weight: 700; }
.right { text-align: right; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* tabulka seznamu */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none; background: var(--bg); }
.grid th.sorted { color: var(--blue2); }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--hover); }
.grid tr.none td { color: var(--muted); cursor: default; text-align: center; }
.grid td.num { color: var(--muted); width: 1%; white-space: nowrap; }
.grid.small td, .grid.small th { padding: 7px 10px; font-size: 14px; }
.list-foot { padding: 10px 18px; font-size: 13px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 11px; font-size: 13px; border: 1px solid; white-space: nowrap; filter: saturate(1.3) brightness(.8); }

/* formulář záznamu */
.record { max-width: 860px; padding: 8px 22px 30px; }
.rec-title { font-size: 30px; font-weight: 600; color: #559c3a; margin: 6px 0 14px; word-break: break-word; }
.form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 22px; }   /* minmax: široký obsah pole nesmí roztáhnout celý formulář */
.fld { min-width: 0; }
.fld.full { grid-column: 1 / -1; }
.fld-label { font-size: 14px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fld-tools { margin-left: auto; display: none; gap: 4px; }
body.editing .fld-tools { display: inline-flex; }
body.editing .fld { outline: 1.5px dashed #ffb02088; outline-offset: 5px; border-radius: 4px; }
input:not([type=checkbox]):not([type=color]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--input); outline: none; min-height: 44px;
}
textarea { resize: vertical; min-height: 44px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue2); box-shadow: 0 0 0 3px #336a2233; background: var(--bg); }
input.invalid { border-color: var(--danger); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.with-suffix, .with-actions { display: flex; align-items: center; gap: 6px; }
.suffix { color: var(--muted); min-width: 18px; }
.calc-note { margin-top: 3px; font-family: ui-monospace, Menlo, monospace; }
.calc-note:empty { display: none; }
.with-actions .mini { padding: 9px 11px; }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg { border: 0; border-right: 1px solid var(--line); background: var(--input); padding: 10px 16px; cursor: pointer; min-height: 44px; }
.seg:last-child { border-right: 0; }
.seg.on { color: #fff; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--input); padding: 7px 13px; border-radius: 18px; cursor: pointer; }
.chip.on { color: #fff; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.slider { width: 48px; height: 28px; border-radius: 14px; background: #cfd4dc; position: relative; transition: background .15s; }
.slider::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: left .15s; box-shadow: 0 1px 2px #0003; }
.switch input:checked + .slider { background: #4cc96e; }
.switch input:checked + .slider::after { left: 23px; }

.formula { padding: 6px 0; font-size: 17px; color: #559c3a; font-weight: 500; }
.formula.big { font-size: 26px; font-weight: 600; }
.linkbox { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 44px; }
.link-chip { border: 1px solid var(--line); background: var(--input); padding: 8px 12px; border-radius: var(--radius); cursor: pointer; font-weight: 500; }
.link-chip:hover { border-color: var(--blue2); }

.files { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.file { position: relative; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; max-width: 160px; }
.file a { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: inherit; }
.file img { width: 145px; height: 110px; border-radius: 4px; object-fit: cover; background: var(--bg2); }

/* prohlížeč fotek */
.viewer { position: fixed; inset: 0; z-index: 45; background: #000; color: #fff; display: flex; flex-direction: column; }
.viewer-bar { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; background: #111; }
.viewer-btn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 22px; background: #fff2; color: #fff; font-size: 20px; cursor: pointer; }
.viewer-count { flex: none; font-size: 14px; opacity: .85; }
.viewer-name { flex: 1; min-width: 0; font-size: 13px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-img.loading { opacity: .25; }
.viewer-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 8px 14px; border-radius: 18px; background: #0009; font-size: 14px; pointer-events: none; }
.viewer-status:empty { display: none; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: #0006; color: #fff; font-size: 32px; line-height: 1; cursor: pointer; }
.viewer-nav.prev { left: 6px; }
.viewer-nav.next { right: 6px; }
.file-icon { font-size: 30px; }
.file-name { font-size: 12px; word-break: break-all; text-align: center; }
.file .mini { position: absolute; top: -8px; right: -8px; background: var(--bg); }

.items-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.items-table th { font-size: 12px; color: var(--muted); text-align: left; padding: 4px; font-weight: 600; }
.items-table td { padding: 3px; vertical-align: top; }
.items-table td:nth-child(2), .items-table td:nth-child(3) { width: 76px; }
.items-table td:nth-child(4) { width: 110px; }
.items-table td.right { white-space: nowrap; padding-top: 12px; }
.items-table tfoot td { padding-top: 10px; font-size: 16px; }

.related { margin-top: 28px; }
.pending-note { background: #fff4d6; color: #7a5500; border-radius: var(--radius); padding: 8px 12px; margin: -6px 0 14px; font-size: 14px; }
.related-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.related-title .rel-cols { margin-left: auto; font-weight: 400; font-size: 13px; width: auto; padding: 2px 8px; }
.sort-box { display: flex; align-items: center; gap: 4px; }
.sort-box select { max-width: 190px; }
.sort-box .sort-dir { min-width: 36px; padding-left: 8px; padding-right: 8px; }
.related .table-wrap { border: 1px solid var(--line); border-radius: var(--radius); }
.related-actions { display: flex; gap: 18px; padding: 4px 6px; flex-wrap: wrap; }

.bottombar {
  position: fixed; left: var(--side-w); right: 0; bottom: 0; display: flex; align-items: center; gap: 2px; transition: left .18s ease;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); z-index: 6;
}

/* dialogy */
.overlay { position: fixed; inset: 0; background: #0006; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--bg); border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px #0004; }
.modal-head { display: flex; align-items: center; padding: 12px 16px 8px 20px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 18px; }
.modal-body { padding: 4px 20px 12px; overflow-y: auto; }
.modal-body h3 { font-size: 14px; margin: 18px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .danger { margin-right: auto; }
.frow { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.frow > span { font-size: 13px; font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.choice-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.choice-row input[type=color] { width: 40px; height: 40px; border: 0; padding: 0; background: none; flex: none; }
.pick-list { margin-top: 10px; display: flex; flex-direction: column; max-height: 55vh; overflow-y: auto; }
.pick { text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 12px 6px; cursor: pointer; }
.pick:hover { background: var(--hover); }
.pick .num { color: var(--muted); font-size: 13px; }
.login { padding: 26px; gap: 14px; max-width: 340px; }
.login-logo { width: 100%; height: auto; margin: 6px 0 2px; }
.login { overflow-y: auto; }
.login input { width: 100%; }
#login { background: var(--bg2); }   /* neprůhledné: pod přihlášením není nic vidět */
.login-err { color: var(--danger); font-size: 13px; }
.login-err:empty { display: none; }
.login-text, .login-head { margin: 0; }
.login-qr { display: block; width: 190px; height: 190px; margin: 0 auto; background: #fff; border-radius: 6px; }
.login-secret { word-break: break-all; }
.code-input { text-align: center; font-size: 20px; letter-spacing: 2px; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 0 0 10px; }
.recovery-codes code { font-size: 12px; white-space: nowrap; }
.sec-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sec-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sec-bad b { color: var(--danger); }
.sec-log { max-height: 40vh; overflow-y: auto; }
details { margin-top: 10px; } summary { cursor: pointer; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: #222c; color: #fff; padding: 9px 16px; border-radius: 20px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* mobil / iPhone */
@media (max-width: 899px) {
  /* telefon/úzké okno: menu se vysouvá zleva přes obsah, nahoře lišta s názvem */
  body, body.nav-collapsed { --side-w: 0px; }
  #side { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px #0003; }
  body.nav-open #side { transform: none; }
  body.nav-open #side-backdrop { position: fixed; inset: 0; z-index: 39; background: #0004; }
  body.nav-collapsed .side-logo-link, body.nav-collapsed .nav-name, body.nav-collapsed .nav-count, body.nav-collapsed .nav-title { display: revert; }
  body.nav-collapsed .side-head { flex-direction: row; padding: calc(env(safe-area-inset-top) + 12px) 10px 12px 16px; }
  body.nav-collapsed .nav-item { justify-content: flex-start; padding: 9px 10px; }
  .side-collapse { display: none; }
  .top-brand { display: block; }
  .record { padding: 6px 16px 30px; }
  .toolbar { padding: 10px 12px; }
  .toolbar h1 { font-size: 18px; }
}
/* počítač: ☰ v liště jen u sbaleného menu (rozbalí ho) */
@media (min-width: 900px) { body:not(.nav-collapsed) #btn-menu { display: none; } }
@media (max-width: 600px) {
  .grid.auto-cols:not(.fixed) td:nth-child(n+5), .grid.auto-cols:not(.fixed) th:nth-child(n+5) { display: none; }   /* jen dokud si sloupce nevyberete sami */
  .rec-title { font-size: 26px; }
  .form { gap: 14px 14px; }
  .fld.half.t-choice, .fld.half.t-link, .fld.half.t-items { grid-column: 1 / -1; }
  .segmented { display: flex; }
  .seg { flex: 1 1 auto; padding: 10px 8px; }
  .rec-toolbar .btn:not(.back) { padding: 7px 9px; font-size: 14px; }
  .bottombar .muted { display: none; }
}

/* tisk záznamu */
@media print {
  .topbar, #side, #sidebar, .bottombar, .toolbar, .fld-tools, .related-actions, .link-btn, .mini, #toast { display: none !important; }
  #main { overflow: visible; padding: 0; }
  .layout, #app, .main-col { display: block; height: auto; }
  input, textarea, select { border: 0 !important; background: none !important; padding: 2px 0 !important; min-height: 0 !important; }
}

/* přehled (úvodní stránka) */
.dash { padding: 0 22px 40px; max-width: 1400px; }
.hero { padding: 4px 22px 18px; color: #fff;   /* přes celou šířku, nahoře přesně barva horní lišty -> jeden celek */
  background: radial-gradient(120% 140% at 100% 100%, #5f9e42 0%, transparent 55%), linear-gradient(180deg, var(--blue) 0%, #468a31 100%); }
/* PC/Mac: jeden nízký řádek – pozdrav a datum vlevo, rychlá tlačítka vpravo */
.hero-inner { max-width: 1356px; display: flex;   /* stejná šířka jako obsah pod hlavičkou (.dash 1400 px − okraje) */ align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
@media (min-width: 900px) {
  .hero .sync-info { display: none; }      /* verze a synchronizace jsou v horní liště */
}
.hero .hero-quick { margin-top: 0; }
@media (max-width: 899px) { .hero-inner { gap: 10px; } }
.hero-stats { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.hero-stat { display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 14px;
  background: rgba(255,255,255,.14); color: #fff; cursor: pointer; text-align: left; min-width: 170px; }
.hero-stat:hover { background: rgba(255,255,255,.24); }
.hero-stat-num { font-size: 30px; font-weight: 800; line-height: 1; }
.hero-stat-label { display: flex; flex-direction: column; font-weight: 600; line-height: 1.2; }
.hero-stat-label small { font-weight: 400; opacity: .8; font-size: 12px; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero-hello { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.hero-date { opacity: .85; margin-top: 0; font-size: 14px; }
.hero .sync-info { color: #fff; opacity: .8; font-size: 12px; text-align: right; }
.hero-quick { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.quick { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 22px; padding: 9px 16px; background: rgba(255,255,255,.18); color: #fff; font-weight: 600; cursor: pointer; backdrop-filter: blur(4px); }
.quick:hover { background: rgba(255,255,255,.3); }
.dash-section { margin-top: 22px; }
.dash-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dash-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0; font-weight: 700; }
.dash-head .link-btn { margin-left: auto; }
.dash-count { background: var(--hover); color: var(--blue); font-weight: 700; font-size: 12px; padding: 1px 9px; border-radius: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }   /* dlaždice vyplní šířku */
.tile {
  --c: var(--blue); display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--c) 22%, var(--line)); border-radius: 16px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 9%, var(--bg)), var(--bg) 70%);
  box-shadow: 0 1px 2px #0000000a; transition: transform .12s, box-shadow .12s;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 22px #00000014; }
.tile:active { transform: scale(.98); }
.tile-icon { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 22px;
  background: color-mix(in srgb, var(--c) 16%, var(--bg)); }
.tile-body { display: flex; flex-direction: column; min-width: 0; }
.tile-num { font-size: 30px; font-weight: 800; line-height: 1.05; color: var(--c); }
.tile-label { font-weight: 600; color: var(--text); }
.tile-sub { font-size: 12px; color: var(--muted); }
.tile.alert { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.tile.alert .tile-icon { animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 15%, transparent); } }
.recent { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--bg); }
.recent-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; }
.recent-row:last-child { border-bottom: 0; }
.recent-row:hover { background: var(--hover); }
.recent-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.recent-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-sub { font-size: 13px; color: var(--muted); }
.recent-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge-wrap { padding: 8px 0; }

/* souhrnné karty na přehledu (Zakázky, Faktury) */
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-top: 22px; }
.sum-card { --c: var(--blue); display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--c) 25%, var(--line));
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 8%, var(--bg)), var(--bg) 65%); box-shadow: 0 1px 3px #0000000d; }
.sum-card.alert { border-color: color-mix(in srgb, var(--c) 50%, var(--line)); }
.sum-head { display: flex; align-items: center; gap: 10px; }
.sum-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; background: color-mix(in srgb, var(--c) 15%, var(--bg)); }
.sum-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.sum-main { display: flex; align-items: baseline; gap: 12px; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: var(--text); }
.sum-num { font-size: 44px; font-weight: 800; line-height: 1; color: var(--c); }
.sum-main-label { display: flex; flex-direction: column; font-size: 17px; font-weight: 700; line-height: 1.25; }
.sum-main-label small { font-size: 13px; font-weight: 500; color: var(--muted); }
.sum-main:hover .sum-main-label { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--c) 50%, transparent); }
.sum-chips { display: flex; gap: 6px 18px; flex-wrap: wrap; }
/* Nová / Rozpracovaná: bez rámečku, jen odkaz (podtržení při najetí) */
.sum-chip { --c: var(--blue); border: 0; background: none; padding: 2px 0; color: var(--text); cursor: pointer; font-size: 14px; }
.sum-chip:hover { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--c) 60%, transparent); text-underline-offset: 3px; }
.sum-chip b { color: var(--c); }
.sum-lines { display: flex; flex-direction: column; gap: 6px; }
.sum-line { --c: var(--blue); display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer; padding: 10px 12px;
  border-radius: 12px; border: 0; border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 10%, var(--bg)); color: var(--text); font-weight: 400; }
.sum-line:hover { background: color-mix(in srgb, var(--c) 17%, var(--bg)); }
.sum-line-text { flex: 1; }
.sum-arrow { color: var(--muted); font-size: 20px; }
@media (max-width: 600px) {
  .sum-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
  /* telefon: kompaktnější přehled, aby se vešlo i 5 posledních zakázek bez posouvání */
  .sum-card { padding: 13px 15px; gap: 9px; }
  .sum-num { font-size: 36px; }
  .sum-main-label { font-size: 16px; }
  .sum-line { font-size: 14px; padding: 8px 12px; }
  .sum-lines { gap: 5px; }
  .dash-section { margin-top: 16px; }
  .dash-head { margin-bottom: 7px; }
  .recent-row { padding: 9px 12px; }
  .recent-tags { gap: 4px; }
}
.all-done { display: flex; align-items: center; gap: 14px; margin-top: 22px; padding: 16px 18px; border-radius: 16px;
  border: 1px solid color-mix(in srgb, #43a047 30%, var(--line)); background: color-mix(in srgb, #43a047 8%, var(--bg)); }
.all-done-icon { font-size: 26px; }
.sync-info { font-size: 12px; color: var(--muted); }

/* sekce formuláře (Zakázka / Realizace / Dokončení) a pole zobrazená jen v některém stavu */
.fld.section-head { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--hover);
  border-left: 4px solid var(--blue); }
.fld.section-head:first-child { margin-top: 0; }
.fld.section-head .fld-label { margin: 0; font-size: 15px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .5px; }
.when-tag { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: #2563eb; background: #2563eb14; border-radius: 8px; padding: 1px 7px; }
.when-tag.off { color: var(--muted); background: var(--hover); }
body.editing .fld.hidden-field { opacity: .45; }
.when-edit { margin: 4px 0 0 26px; display: flex; flex-direction: column; gap: 8px; }

/* filtr seznamu */
.filter-bar { padding: 10px 18px 0; }
.filter-chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border: 1.5px solid var(--line); border-radius: 18px; font-size: 14px; font-weight: 500; }
.filter-chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.filter-chip button { border: 0; background: var(--hover); border-radius: 50%; width: 24px; height: 24px; cursor: pointer; color: var(--text); }

/* adresa s našeptávačem */
.addr { position: relative; }
.addr-list { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin-top: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px #0002; overflow: hidden; }
.addr-list.open { display: block; }
.addr-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 11px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.addr-item:last-child { border-bottom: 0; }
.addr-item:hover, .addr-item.on { background: var(--hover); }

/* šířka a výběr sloupců */
.grid th { position: relative; }
.grid.fixed { table-layout: fixed; min-width: 100%; }
.grid.fixed td { max-width: none; overflow-wrap: anywhere; }
.grid.fixed th { overflow: hidden; text-overflow: ellipsis; }
.col-resize { position: absolute; top: 0; right: -4px; width: 9px; height: 100%; cursor: col-resize; z-index: 2; touch-action: none; }
.col-resize::after { content: ""; position: absolute; left: 4px; top: 25%; height: 50%; width: 1px; background: var(--line); }
.grid th:hover .col-resize::after, .grid th.resizing .col-resize::after { background: var(--blue); width: 3px; left: 3px; }
@media (pointer: coarse) {   /* dotykové displeje: širší úchyt pro prst */
  .col-resize { width: 22px; right: -11px; }
  .col-resize::after { left: 10px; }
  .grid th.resizing .col-resize::after { left: 9px; }
}
.cols-edit { border: 1px solid var(--line); border-radius: var(--radius); max-height: 50vh; overflow-y: auto; }
.cols-row { display: flex; align-items: center; gap: 6px; padding: 2px 10px; border-bottom: 1px solid var(--line); }
.cols-row:last-child { border-bottom: 0; }
.cols-row .check { margin: 6px 0; }
.cols-row.off { opacity: .55; }
.cols-row .mini:disabled { opacity: .3; cursor: default; }

.addr-hint { margin-top: 4px; }

/* ===== telefon ===== */
@media (max-width: 600px) {
  body { font-size: 16px; }
  input:not([type=checkbox]):not([type=color]), select, textarea { font-size: 16px; }   /* iPhone pak při psaní nepřibližuje */
  .hide-sm { display: none; }

  /* přehled */
  .dash { padding: 0 14px 30px; }
  .hero { padding: 12px 16px 14px; }
  .hero-quick { margin-top: 10px; }
  .hero-stats { margin-top: 12px; }
  .hero-stat { padding: 8px 14px 8px 10px; min-width: 0; }
  .hero-stat-num { font-size: 24px; }
  .hero-stat-label { font-size: 12px; }
  .hero-stat-label small { font-size: 11px; }
  .hero-top { flex-direction: column; gap: 4px; }
  .hero .sync-info { text-align: left; }
  .hero-hello { font-size: 23px; }
  .quick { padding: 8px 13px; font-size: 14px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "icon num" "body body"; align-items: center; gap: 6px 10px; padding: 12px; }
  .tile-icon { grid-area: icon; width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
  .tile-body { display: contents; }
  .tile-num { grid-area: num; font-size: 26px; }
  .tile-label { grid-column: 1 / -1; font-size: 14px; line-height: 1.25; }
  .tile-sub { grid-column: 1 / -1; margin-top: -4px; }
  .recent-tags { flex-direction: column; align-items: flex-end; }

  /* seznamy jako karty */
  .toolbar { gap: 8px; }
  .toolbar .search { order: 5; flex-basis: 100%; }
  /* seznam na telefonu: 1. řádek nadpis + tlačítka, 2. řádek hledání + řazení */
  .list-toolbar::after { content: ''; order: 4; flex-basis: 100%; }
  .list-toolbar .search { flex: 1 1 0; min-width: 0; }
  .list-toolbar .sort-box { order: 6; }
  .list-toolbar .sort-box select { max-width: 150px; }
  .table-wrap { overflow: visible; padding: 8px 12px; }
  .grid.cards, .grid.cards.fixed { width: 100% !important; min-width: 0; table-layout: auto; }
  .grid.cards colgroup, .grid.cards thead { display: none; }
  .grid.cards tbody { display: flex; flex-direction: column; gap: 8px; }
  /* karta: 1. řádek #číslo + název (jméno a příjmení / název zakázky), 2. údaje, 3. štítky (stav, platba) */
  .grid.cards tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); box-shadow: 0 1px 2px #0000000a; }
  .grid.cards tbody tr:hover { background: var(--hover); }
  .grid.cards td { display: block !important; border: 0; padding: 0; max-width: none; text-align: left; font-size: 14px; color: var(--muted); order: 2; }
  .grid.cards td:empty, .grid.cards td.num, .grid.cards td.is-tag, .grid.cards td.in-title { display: none !important; }
  .grid.cards td[data-label]::before { content: attr(data-label) ": "; font-size: 12px; opacity: .75; }
  .grid.cards td.card-head { order: 1; flex-basis: 100%; display: flex !important; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text); }
  .card-num { font-size: 12px; font-weight: 400; color: var(--muted); flex: none; }
  .card-name { min-width: 0; }
  .grid.cards td.card-tags { order: 3; flex-basis: 100%; display: flex !important; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
  .grid.cards tr.none { justify-content: center; color: var(--muted); }

  /* formulář: jeden sloupec, víc vzduchu */
  .record { padding: 4px 14px 30px; }
  .rec-title { font-size: 24px; margin: 4px 0 10px; }
  .form { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  input[type=date] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; text-align: left; }   /* iOS jinak datum roztáhne přes okraj */
  input[type=date]::-webkit-date-and-time-value { text-align: left; }
  .related .table-wrap { overflow-x: auto; }

  /* položky faktury na telefonu: každá položka jako karta, nic se neposouvá do boku */
  .items .table-wrap { overflow: visible; padding: 0; }
  .items-table { display: block; min-width: 0; }
  .items-table thead { display: none; }
  .items-table tbody, .items-table tfoot { display: block; }
  .items-table tbody tr { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius); }
  .items-table td { display: block; padding: 0; }
  .items-table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
  .items-table td.item-text { flex: 1 0 100%; }
  .items-table td.item-num { flex: 1 1 64px; width: auto; min-width: 0; }
  .items-table td.line-total { flex: 1 1 calc(100% - 60px); width: auto; padding: 0; font-weight: 600; text-align: left; align-self: center; }   /* vlastní řádek pod čísly */
  .items-table td.item-del { flex: none; }
  .items-table tfoot tr { display: flex; justify-content: space-between; padding: 2px 10px 8px; }
  .items-table tfoot td { width: auto; }
  .items-table tfoot td:last-child { display: none; }
  .fld.half { grid-column: 1 / -1; }
  .fld-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
  .segmented { display: flex; flex-wrap: wrap; width: 100%; }
  .seg { flex: 1 1 auto; padding: 10px 8px; font-size: 14px; }
  .related { margin-top: 22px; }
  .bottombar .icon-btn { font-size: 22px; padding: 8px 10px; }
}
