/* Zakázky – ukázka · styl aplikace */
:root {
  --navy: #0F1B3D; --navy-2: #22305a; --orange: #FF6B35; --orange-d: #e2541f;
  --bg: #F4F6FA; --card: #fff; --line: #E3E7EF; --muted: #5d6680; --ok: #12805c;
  --r: 16px; --tabs-h: 72px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-d: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--navy); background: #dfe3ec;
  font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--bg); position: relative; box-shadow: 0 0 40px rgba(15,27,61,.12); }

/* horní lišta */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--navy); color: #fff;
}
.bar-back { width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,.1); display: grid; place-items: center; cursor: pointer; flex: none; }
.bar-back svg { width: 22px; height: 22px; }
.bar-title { flex: 1; min-width: 0; }
.bar-title small { display: block; font-size: .72rem; opacity: .7; letter-spacing: .02em; }
.bar-title strong { display: block; font-family: var(--font-d); font-size: 1.2rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-badge { flex: none; font-size: .66rem; font-weight: 700; background: var(--orange); color: #fff; padding: 5px 9px; border-radius: 999px; line-height: 1.2; max-width: 112px; text-align: center; }

.view { padding: 16px 14px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom)); outline: none; }

/* spodní navigace */
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; font-size: .72rem; font-weight: 600; color: var(--muted); border-radius: 12px; min-height: 56px; }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabs circle { fill: currentColor; stroke: none; }
.tabs a.on { color: var(--navy); }
.tabs a.on svg { stroke: var(--orange); }
.tabs a.on circle { fill: var(--orange); }
.tabs .tab-add svg { width: 48px; height: 48px; padding: 11px; background: var(--orange); stroke: #fff; border-radius: 16px; margin-top: -22px; box-shadow: 0 8px 18px -6px rgba(255,107,53,.7); stroke-width: 2.6; }
.tabs .tab-add.on svg { stroke: #fff; background: var(--orange-d); }

/* obecné */
.muted { color: var(--muted); font-size: .9rem; margin: 0; }
.lead { margin: 0 0 14px; font-weight: 600; }
.hint { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
.sec { font-family: var(--font-d); font-size: 1.05rem; margin: 22px 0 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 12px 18px;
  border-radius: 14px; border: 1.5px solid var(--navy); background: #fff; color: var(--navy);
  font-weight: 700; text-decoration: none; cursor: pointer; width: 100%; text-align: center;
}
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:active { background: var(--orange-d); }
.btn.ghost { border-color: var(--line); }
.btn.danger-ghost { border-color: transparent; color: #b4232c; background: transparent; min-height: 44px; }
.btn.sm { min-height: 44px; margin-top: 10px; }
.btn:focus-visible, .tabs a:focus-visible, .filter:focus-visible, .card:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 8px; }
.actions { display: grid; gap: 10px; margin-top: 18px; }
.sent { margin: 0; padding: 14px; border-radius: 14px; background: #e6f5ee; color: var(--ok); font-weight: 600; text-align: center; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty-s { color: var(--muted); font-size: .9rem; }
.tag { font-size: .68rem; font-weight: 700; background: #fff1eb; color: var(--orange-d); padding: 3px 8px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }

/* stavy */
.chip { display: inline-block; font-size: .74rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.s-nova { background: #fff1eb; color: #c2410c; }
.s-plan { background: #e8eefc; color: #2446a8; }
.s-hotova { background: #e6f5ee; color: var(--ok); }
.s-fakt { background: var(--navy); color: #fff; }

/* filtry */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 0 -14px 10px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter { flex: none; min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; font-size: .88rem; cursor: pointer; }
.filter b { margin-left: 4px; color: var(--muted); font-weight: 700; }
.filter.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.filter.on b { color: #ffb08f; }

/* karty */
.list { display: grid; gap: 10px; }
.card { display: block; background: var(--card); border-radius: var(--r); padding: 14px 16px; text-decoration: none; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15,27,61,.04); }
.card:active { transform: scale(.99); }
.card h3, .tl-card h3 { font-family: var(--font-d); font-size: 1.08rem; margin: 8px 0 4px; line-height: 1.25; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }

/* dnes */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tl { display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: start; position: relative; }
.tl::before { content: ""; position: absolute; left: 26px; top: 30px; bottom: -14px; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl-time { font-family: var(--font-d); font-weight: 800; font-size: 1.05rem; background: #fff; border: 2px solid var(--orange); border-radius: 10px; text-align: center; padding: 4px 0; position: relative; z-index: 1; }
.tl.done .tl-time { border-color: var(--ok); color: var(--ok); }
.tl-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; text-decoration: none; }
.addr { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0 0; font-size: .9rem; }
.addr svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--orange); stroke-width: 2; margin-top: 1px; }

/* detail */
.detail-head { margin-bottom: 14px; }
.detail-head h2 { font-family: var(--font-d); font-size: 1.5rem; line-height: 1.15; margin: 8px 0 4px; }
.box { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 10px; }
.box h4 { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.box p { margin: 0; }
.box .big { font-weight: 700; font-size: 1.08rem; }
.box.link { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; min-height: 72px; }
.box.link h4 { margin-bottom: 2px; color: var(--navy); text-transform: none; letter-spacing: 0; font-size: 1rem; }
.arrow { font-size: 1.8rem; color: var(--muted); line-height: 1; }
.ok { width: 32px; height: 32px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 800; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ph { margin: 0; position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bg); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-del { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(15,27,61,.75); color: #fff; font-size: 1.2rem; cursor: pointer; }
.ph-add { aspect-ratio: 1; border: 2px dashed #c8cfdd; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); cursor: pointer; text-align: center; }
.ph-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ph-add:focus-within { outline: 3px solid var(--orange); }
.ph-add svg { width: 28px; height: 28px; fill: none; stroke: var(--orange); stroke-width: 1.8; stroke-linejoin: round; }

/* materiál */
.items { display: grid; gap: 8px; margin-bottom: 12px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; }
.item-main { grid-column: 1 / -1; display: flex; flex-direction: column; }
.item-main .muted { font-size: .82rem; }
.qty { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.qty button { width: 46px; height: 46px; border: 0; background: var(--bg); font-size: 1.3rem; font-weight: 700; cursor: pointer; }
.qty input { width: 58px; height: 46px; border: 0; text-align: center; font-weight: 700; -moz-appearance: textfield; appearance: textfield; }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.item-sum { text-align: right; font-weight: 700; display: flex; flex-direction: column; align-items: flex-end; }
.rm { border: 0; background: none; color: #b4232c; font-size: .78rem; padding: 6px 0 0; cursor: pointer; min-height: 32px; }
.totals { background: var(--navy); color: #fff; border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; font-size: .95rem; }
.totals .grand { font-family: var(--font-d); font-size: 1.3rem; font-weight: 800; border-top: 1px solid rgba(255,255,255,.2); padding-top: 8px; margin-top: 2px; }
.totals .grand span:last-child { color: #ffb08f; }
.quick { display: grid; gap: 6px; }
.quick button { display: flex; justify-content: space-between; gap: 10px; align-items: center; min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; text-align: left; font-size: .9rem; }
.quick button b { white-space: nowrap; color: var(--navy); }
.quick button::after { content: "+"; font-weight: 800; color: var(--orange); font-size: 1.2rem; margin-left: 4px; }

/* formuláře */
.form { display: grid; gap: 12px; }
.form label, .lbl { display: grid; gap: 4px; font-size: .84rem; font-weight: 600; color: var(--muted); }
.form input, .form textarea, #podepsal {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff;
  color: var(--navy); font-size: 16px; font-weight: 500;
}
.form textarea { resize: vertical; }
.form input:focus, .form textarea:focus, #podepsal:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,107,53,.2); }
.err { color: #b4232c; font-weight: 600; margin: 0; font-size: .9rem; }

/* podpis */
.sig-wrap { position: relative; background: #fff; border: 1.5px solid var(--line); border-radius: var(--r); margin: 10px 0 0; height: 230px; overflow: hidden; }
#sig { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.sig-line { position: absolute; left: 20px; right: 20px; bottom: 34px; border-top: 1.5px dashed #b9c1d3; font-size: .74rem; color: var(--muted); padding-top: 4px; pointer-events: none; }
.sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa3b8; font-weight: 600; pointer-events: none; }

/* protokol */
.sheet { background: #fff; border-radius: 6px; padding: 20px 18px; box-shadow: 0 10px 30px -12px rgba(15,27,61,.3); font-size: .88rem; }
.sheet-head { display: flex; justify-content: space-between; gap: 12px; border-bottom: 3px solid var(--navy); padding-bottom: 10px; }
.sheet-head span { color: var(--muted); font-size: .78rem; }
.sheet-no { text-align: right; font-size: .8rem; }
.sheet-no b { font-family: var(--font-d); font-size: 1.05rem; }
.sheet-demo { background: #fff1eb; color: #c2410c; font-weight: 700; font-size: .74rem; padding: 5px 8px; border-radius: 6px; margin: 10px 0; }
.sheet-dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 10px 0; }
.sheet-dl dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sheet-dl dd { margin: 0; font-weight: 600; }
.sheet-desc { color: #33405f; }
.sheet-t { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .8rem; }
.sheet-t th { text-align: left; font-size: .7rem; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 4px; }
.sheet-t td { padding: 6px 4px; border-bottom: 1px solid #f0f2f6; vertical-align: top; }
.sheet-t td:nth-child(n+2), .sheet-t th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.sheet-t tfoot td { border: 0; padding: 3px 4px; }
.sheet-t tfoot td:first-child { text-align: right; }
.sheet-t tfoot .g td { font-weight: 800; font-size: .95rem; border-top: 2px solid var(--navy); padding-top: 6px; }
.sheet-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.sheet-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.sheet-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; align-items: end; }
.sheet-sign p { margin: 0 0 4px; font-size: .74rem; color: var(--muted); }
.sheet-sign img { width: 100%; height: 70px; object-fit: contain; object-position: left bottom; display: block; }
.nosig { height: 70px; display: grid; place-items: center; color: #b4232c; font-weight: 600; font-size: .8rem; }
.sign-line { border-top: 1.5px solid var(--navy); font-size: .72rem; padding-top: 4px; }

/* fakturace */
.kpi { background: var(--navy); color: #fff; border-radius: var(--r); padding: 16px; display: grid; gap: 2px; }
.kpi span { font-size: .84rem; opacity: .8; }
.kpi strong { font-family: var(--font-d); font-size: 1.8rem; color: #ffb08f; }
.kpi small { opacity: .7; }
.ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: .9rem;
  width: max-content; max-width: min(92vw, 480px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
  box-shadow: 0 12px 28px -10px rgba(15,27,61,.6);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 20px; text-align: center; }

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } .card:active { transform: none; } }

/* tisk protokolu */
@media print {
  @page { margin: 14mm; }
  body, .app { background: #fff; box-shadow: none; }
  .bar, .tabs, .toast, .no-print { display: none !important; }
  .view { padding: 0; }
  .sheet { box-shadow: none; padding: 0; font-size: 11pt; }
}
.bar-back[hidden] { display: none; }
.qty { justify-self: start; width: max-content; }
