/* Kuriér — mobile-first driver app. Colors follow the delivery sheet (Delivery Planner print). */
:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --ink: #1d2a1a;
  --ink-soft: #55604f;
  --line: #d5dccf;
  --brand: #2f6533;
  --brand-ink: #ffffff;
  --brand-wash: #e4efe3;
  --ok: #2f7a35;
  --ok-wash: #e3f2e1;
  --fail: #b42318;
  --fail-wash: #fdecea;
  --return: #c25400;
  --return-wash: #fff4ea;
  --focus: #7aa97d;
  --topbar-chip: rgba(255,255,255,.14);
  --topbar-line: rgba(255,255,255,.24);
  --radius: 12px;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  accent-color: var(--brand);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--brand) linear-gradient(135deg, rgba(255,255,255,.10), rgba(0,0,0,.12)); color: var(--brand-ink); padding-top: env(safe-area-inset-top); box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 8px 20px -12px rgba(0,0,0,.5); }
.topbar-inner { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; min-height: 60px; padding: 8px 16px; }
.topbar-back { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -10px; color: inherit; font-size: 34px; line-height: 1; text-decoration: none; border-radius: 50%; }
.topbar-back:hover { background: var(--topbar-chip); }
.topbar-title { flex: 1 0 auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { flex: none; width: 34px; height: 34px; }
.brand { display: flex; flex-direction: column; font-weight: 700; font-size: 18px; line-height: 1.1; letter-spacing: .01em; }
.brand-sub { margin-top: 2px; font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; opacity: .72; }
.topbar-user { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 3px; border: 1px solid var(--topbar-line); border-radius: 999px; background: var(--topbar-chip); }
.topbar-avatar { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-ink); color: var(--brand); font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.topbar-driver { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.topbar-logout { flex: none; margin: 0; }
.topbar-logout-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 38px; min-height: 38px; padding: 0 14px 0 12px; border: 1px solid transparent; border-radius: 999px; background: var(--topbar-chip); color: inherit; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.topbar-logout-btn:hover { background: var(--topbar-line); }
.topbar-logout-btn svg { flex: none; }
@media (max-width: 519px) {
  .topbar-logout-btn { padding: 0; }
  .topbar-logout-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 399px) {
  .brand-sub { display: none; }
}

.page { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
.page-title { font-size: 24px; line-height: 1.2; margin-bottom: 12px; overflow-wrap: anywhere; }
.hint { color: var(--ink-soft); font-size: 14px; }
.empty, .message p { color: var(--ink-soft); margin-bottom: 16px; }
.message h1 { font-size: 22px; margin-bottom: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 16px; border: 1.5px solid var(--brand); border-radius: 10px; background: var(--surface); color: var(--brand); font-family: inherit; font-size: 16px; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer; text-align: center; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-block { width: 100%; }
.btn-call { width: 100%; margin: 8px 0; font-size: 17px; }

/* Notices */
.notice { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.notice-error { background: var(--fail-wash); color: var(--fail); border-left: 4px solid var(--fail); }
.notice-done { background: var(--ok-wash); color: var(--ok); border-left: 4px solid var(--ok); margin-top: 12px; }

/* Add to home screen */
.install { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; padding: 14px 16px; border: 1.5px solid var(--brand); border-radius: var(--radius); background: var(--brand-wash); }
.install[hidden], .install [hidden] { display: none; }
.install img { flex: none; border-radius: 22%; }
.install-text { display: grid; gap: 8px; min-width: 0; }
.install h2 { font-size: 17px; }
.install-hint { font-size: 14px; color: var(--ink-soft); }
.install-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.install-actions .btn { min-height: 44px; }
.install-actions .btn-quiet { padding-left: 4px; padding-right: 4px; }
.btn-quiet { border-color: transparent; background: transparent; }

/* Login */
.login { max-width: 420px; margin: 8vh auto 0; }
.login-logo { display: block; width: 88px; height: 88px; margin: 0 auto 16px; }
.login h1 { font-size: 26px; margin-bottom: 20px; text-align: center; }
.login-form { display: grid; gap: 6px; margin-bottom: 16px; }
.login-form label { font-weight: 600; margin-top: 8px; }
.login-form input { width: 100%; min-height: 52px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: 17px; }
.login-form .btn { margin-top: 18px; }

/* Run list */
.run-group { margin-bottom: 24px; }
.run-group h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin-bottom: 8px; }
.run-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.run-card { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; }
.run-card.is-done { opacity: .75; }
.run-completed { font-size: 14px; font-weight: 600; color: var(--ok); }
.run-group-hint { margin: -4px 0 8px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.run-date { font-size: 14px; font-weight: 600; color: var(--brand); }
.run-name { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.run-meta, .run-progress { font-size: 14px; color: var(--ink-soft); }
.run-progress { display: grid; gap: 6px; margin-top: 6px; }

.progress { display: block; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; }
.progress-track { fill: var(--line); }
.progress-ok { fill: var(--ok); }
.progress-failed { fill: var(--fail); }

/* Run detail */
.run-head { margin-bottom: 16px; }
.run-head .page-title { margin-bottom: 10px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 10px; }
.facts div { padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.facts dt { font-size: 12px; color: var(--ink-soft); }
.facts dd { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.run-depot { font-size: 14px; color: var(--ink-soft); margin-bottom: 12px; overflow-wrap: anywhere; }
.summary { display: grid; gap: 6px; margin-bottom: 12px; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.actions > .btn, .route-parts { flex: 1 1 200px; }
.route-parts summary { list-style: none; width: 100%; }
.route-parts summary::-webkit-details-marker { display: none; }
.route-parts .hint { margin: 8px 0; }
.route-links { display: flex; flex-wrap: wrap; gap: 8px; }
.loading { padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.loading summary { font-weight: 600; cursor: pointer; padding: 6px 0; }
.loading ol { list-style: none; margin: 8px 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.loading li { padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }

.stops { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.stop { border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px; }
.stop-completed { border-color: var(--ok); }
.stop-failed { border-color: var(--fail); }
.stop-return { border-style: dashed; }
.stop-head { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; }
.stop-no { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: var(--surface); font-weight: 700; font-size: 18px; }
.stop-completed .stop-no { background: var(--ok); }
.stop-failed .stop-no { background: var(--fail); }
.stop-return .stop-no { background: var(--return); }
.stop-address { font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.stop-meta { margin-top: 4px; font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.stop-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 12px 0 4px; }
.stop-nav .btn { flex: 1 1 160px; }
.gps { font-size: 14px; font-variant-numeric: tabular-nums; }

.order { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; scroll-margin-top: 72px; }
.order-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.order-head h3 { font-size: 18px; overflow-wrap: anywhere; }
.badge { flex: 0 0 auto; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--brand-wash); color: var(--ink); }
.badge-completed { background: var(--ok-wash); color: var(--ok); }
.badge-failed { background: var(--fail-wash); color: var(--fail); }
.task { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin: 6px 0; }
.task-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; background: var(--brand-wash); color: var(--brand); }
.task-return .task-label { background: var(--return); color: #fff; }
.note-box { margin: 8px 0; padding: 8px 12px; border-left: 4px solid var(--return); border-radius: 6px; background: var(--return-wash); overflow-wrap: anywhere; }
.pay { margin: 6px 0; font-size: 15px; color: var(--ink-soft); }
.pay-collect { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--return); border-radius: 10px; background: var(--return-wash); color: var(--ink); font-weight: 600; }
.pay-collect strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.products { margin: 8px 0; }
.products summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.products ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.products li { display: grid; grid-template-columns: 40px 1fr; gap: 6px; font-size: 15px; }
.products .qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.products small { display: block; color: var(--ink-soft); }

.status-form { margin-top: 12px; display: grid; gap: 6px; }
.status-form label { font-size: 14px; font-weight: 600; }
.status-form input[type="text"] { width: 100%; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; }
.segmented { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 4px; }
.seg { min-height: 52px; padding: 8px 6px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; cursor: pointer; }
.seg-completed[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.seg-failed[aria-pressed="true"] { background: var(--fail); border-color: var(--fail); color: var(--surface); }
.seg-not_started[aria-pressed="true"] { background: var(--ink-soft); border-color: var(--ink-soft); color: var(--surface); }
label.seg { display: flex; align-items: center; justify-content: center; text-align: center; }
.status-form label.seg { font-size: 15px; }
.status-form label.fail-reason { font-size: 16px; }
.seg-failed.is-pressed { background: var(--fail); border-color: var(--fail); color: var(--surface); }
.status-note { padding: 8px 12px; border-radius: 8px; background: var(--bg); color: var(--ink-soft); font-size: 14px; overflow-wrap: anywhere; }

/* Reasons under "Nedoručené": opened by the hidden checkbox before the buttons. */
.fail-toggle:checked + .segmented .seg-failed { border-color: var(--return); box-shadow: 0 0 0 2px var(--return); }
.fail-toggle:focus-visible + .segmented .seg-failed, .other-toggle:focus-visible + .fail-reason { outline: 3px solid var(--focus); outline-offset: 2px; }
.fail-panel { display: none; gap: 8px; margin-top: 4px; padding: 14px; border: 2px solid var(--return); border-radius: var(--radius); background: var(--return-wash); transform-origin: top center; }
.fail-toggle:checked ~ .fail-panel { display: grid; animation: fail-open .22s ease-out; }
.fail-title { font-weight: 700; color: var(--return); }
.fail-reason { width: 100%; justify-content: flex-start; border-color: var(--return); color: var(--ink); background: var(--surface); }
.other-toggle:checked + .fail-reason { background: var(--return); color: var(--surface); }
.fail-other { display: none; gap: 6px; }
.other-toggle:checked ~ .fail-other { display: grid; animation: fail-open .18s ease-out; }
.btn-fail { background: var(--fail); border-color: var(--fail); color: var(--surface); }
/* Saved-outcome confirmation: slides up, stays briefly, then fades out without blocking taps. */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20; max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-weight: 600; text-align: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); pointer-events: none; opacity: 0; animation: toast 3.2s ease-out; }
@keyframes toast {
  0% { opacity: 0; transform: translateY(12px); }
  8%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}
@keyframes fail-open {
  from { opacity: 0; transform: translateY(-8px) scaleY(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .fail-toggle:checked ~ .fail-panel, .other-toggle:checked ~ .fail-other { animation: none; }
  .toast { animation: toast-fade 3.2s linear; }
}

.break, .finish { padding: 12px 14px; border-radius: var(--radius); font-weight: 600; }
.break { border: 1.5px dashed var(--ink-soft); }
.finish { border: 2px solid var(--ink); background: var(--surface); }
.run-finish { display: grid; gap: 10px; margin-top: 24px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.run-finish h2 { font-size: 18px; }
.run-finish form { display: grid; gap: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 480px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (forced-colors: active) {
  .seg[aria-pressed="true"] { border-width: 3px; }
}
