/* ═══════════════════════════════════════════════════════════════════════
   Předávání vozidel — styl (základ převzatý z Předávacího protokolu)
   Cílové zařízení: Android tablet se stylusem, na výšku i na šířku.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --navy:        #123a63;
  --navy-dark:   #0d2b4a;
  --navy-soft:   #e8eef5;
  --ink:         #16202b;
  --ink-soft:    #5a6b7c;
  --line:        #d7dee6;
  --bg:          #f2f4f7;
  --surface:     #ffffff;
  --danger:      #b3261e;
  --danger-bg:   #fdeceb;
  --warn-bg:     #fff5e0;
  --warn-ink:    #7a5200;
  --ok:          #1b7f4b;
  --radius:      12px;
  --shadow:      0 1px 2px rgba(16, 32, 48, .06), 0 6px 18px rgba(16, 32, 48, .07);
  --tap:         48px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

/* ── horní lišta ─────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 10px rgba(16, 32, 48, .18);
}
.topbar[hidden] { display: none; }

.topbar__title { font-weight: 600; font-size: 17px; color: #fff; text-decoration: none; }

.topbar__user { display: flex; align-items: center; gap: 10px; min-width: 0; }

.topbar__email {
  font-size: 13px;
  opacity: .85;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── přihlašovací obrazovka ──────────────────────────────────────────── */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 20px;
}
.gate[hidden] { display: none; }

.gate__card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 28px 30px;
  text-align: center;
}

.gate__mark {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  letter-spacing: .14em;
  font-size: 20px;
}

.gate__title { margin: 20px 0 6px; font-size: 24px; }
.gate__lead  { margin: 0 0 26px; color: var(--ink-soft); }

.gate__note {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.gate__config {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 13px;
  text-align: left;
  white-space: pre-line;
}
.gate__config[hidden] { display: none; }

.gicon { width: 18px; height: 18px; flex: none; }

/* ── tlačítka ────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid #7aa7d6; outline-offset: 2px; }

.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:not(:disabled):active { background: var(--navy-dark); }

.btn--soft { background: var(--navy-soft); color: var(--navy); }
.btn--soft:not(:disabled):active { background: #dae4ef; }

.btn--ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, .45);
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

.btn--tiny {
  min-height: 40px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  border-color: var(--line);
}

.btn--big { width: 100%; min-height: 54px; font-size: 17px; }

.btn--icon {
  min-height: var(--tap);
  width: var(--tap);
  flex: none;
  padding: 0;
  border-color: var(--line);
  color: var(--ink-soft);
  font-size: 22px;
  line-height: 1;
}
.btn--icon:not(:disabled):active { background: var(--danger-bg); color: var(--danger); }

/* ── layout formuláře ────────────────────────────────────────────────── */

.sheet {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 56px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--navy);
}

.card__count { font-size: 13px; font-weight: 500; color: var(--ink-soft); letter-spacing: 0; text-transform: none; }

.card__body { padding: 18px; display: grid; gap: 16px; }

.card--send .card__body { gap: 12px; }

/* ── pole ────────────────────────────────────────────────────────────── */

.field { display: grid; gap: 6px; }

.field__label { font-size: 14px; font-weight: 600; color: var(--ink); }
.field__label em { color: var(--danger); font-style: normal; }

.field__hint { margin: 0; font-size: 13px; color: var(--ink-soft); }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(18, 58, 99, .12); }
.input.is-invalid { border-color: var(--danger); background: var(--danger-bg); }

.input--readonly {
  display: flex;
  align-items: center;
  background: #f6f8fa;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.party { display: grid; gap: 4px; }
.party__label { font-size: 14px; font-weight: 600; }
.party__fixed {
  padding: 10px 14px;
  border-radius: 10px;
  background: #f6f8fa;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

/* ── opakovatelné řádky ──────────────────────────────────────────────── */

.rows { display: grid; gap: 10px; }

.row { display: flex; gap: 8px; align-items: center; }
.row .input { flex: 1 1 auto; min-width: 0; }

/* ── fotografie ──────────────────────────────────────────────────────── */

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

.filepick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 84px;
  padding: 12px 8px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
  color: var(--navy);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
}
.filepick:active { background: var(--navy-soft); border-color: var(--navy); }
.filepick__icon { width: 26px; height: 26px; flex: none; }

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}
.thumbs:empty { display: none; }

.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eceff3; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb__del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(16, 24, 32, .68);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

/* ── podpisy ─────────────────────────────────────────────────────────── */

.signatures { display: grid; gap: 16px; }

@media (min-width: 620px) {
  .signatures { grid-template-columns: 1fr 1fr; }
}

.sig { display: grid; gap: 8px; }

.sig__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sig__label { font-size: 14px; font-weight: 600; }
.sig__label em { color: var(--danger); font-style: normal; }

.sig__pad {
  position: relative;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.sig__pad.is-invalid { border-color: var(--danger); background: var(--danger-bg); }

/* touch-action: none je nutnost — bez toho gesto při podepisování odscrolluje stránku */
.sig__canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.sig__baseline {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 46px;
  border-bottom: 1px dashed #c4ccd6;
  pointer-events: none;
}

.sig__ghost {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20px;
  text-align: center;
  font-size: 13px;
  color: #a9b3bf;
  pointer-events: none;
  transition: opacity .15s;
}
.sig__pad.has-ink .sig__ghost,
.sig__pad.has-ink .sig__baseline { opacity: 0; }

/* ── hlášky ──────────────────────────────────────────────────────────── */

.alert {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
}
.alert[hidden] { display: none; }

.alert--error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f2c4c1; }
.alert--warn  { background: var(--warn-bg);  color: var(--warn-ink); border: 1px solid #f0dcb0; }
.alert--info  { background: var(--navy-soft); color: var(--navy); border: 1px solid #cfdcea; }

/* ── hotovo ──────────────────────────────────────────────────────────── */

.done {
  max-width: 520px;
  margin: 40px auto;
  padding: 40px 28px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.done__mark {
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #e4f4ea;
  color: var(--ok);
  font-size: 34px;
  line-height: 66px;
}

.done__title { font-size: 22px; margin-bottom: 10px; }
.done__lead  { margin: 0 0 6px; color: var(--ink-soft); }
.done__file  { margin: 0 0 26px; font-size: 13px; color: var(--ink-soft); word-break: break-all; }

/* ── překryv při práci ───────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(16, 24, 32, .5);
  backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }

.overlay__box {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 30px 34px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 220px;
}

.overlay__text { margin: 0; font-weight: 600; text-align: center; }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--navy-soft);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  * { transition-duration: .01ms !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Předávání vozidel — doplňky
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --orange:     #a35a00;
  --orange-bg:  #fff1dc;
}

.muted { color: var(--ink-soft); }
.prewrap { white-space: pre-wrap; }

/* ── stránka ─────────────────────────────────────────────────────────── */

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 16px 56px;
  display: grid;
  gap: 16px;
}

.page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  font-size: 24px;
}

.page__sub { font-size: 17px; font-weight: 500; color: var(--ink-soft); }
.page__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.back {
  justify-self: start;
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
  padding: 6px 0;
}

.sheet--flat { max-width: none; margin: 0; padding: 0; }

.toolbar { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.select { width: auto; min-width: 140px; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:disabled { background: #f6f8fa; color: var(--ink-soft); }

.grid2 { grid-template-columns: 1fr; }
@media (min-width: 620px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid2 > .alert { grid-column: 1 / -1; }
}

.btn--danger-soft { background: var(--danger-bg); color: var(--danger); }

.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 4px;
  color: var(--ink-soft);
}
.loading .spinner { width: 22px; height: 22px; border-width: 2px; }

.empty {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--surface);
  border-radius: var(--radius);
}

/* ── odznaky ─────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e6eaef;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  vertical-align: middle;
}
.badge--warn { background: var(--danger-bg); color: var(--danger); }

.tyre { font-variant-numeric: tabular-nums; }
.tyre--soon    { color: var(--orange); background: var(--orange-bg); padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.tyre--overdue { color: var(--danger); background: var(--danger-bg); padding: 2px 8px; border-radius: 6px; font-weight: 600; }

/* ── seznam vozidel ──────────────────────────────────────────────────── */

.vlist {
  display: grid;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.vlist:has(> .empty), .vlist:has(> .loading) { background: none; box-shadow: none; }

.vrow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.vrow:first-child { border-top: 0; }
.vrow:not(.vrow--head):active { background: var(--navy-soft); }
.vrow:focus-visible { outline: 3px solid #7aa7d6; outline-offset: -3px; }

.vrow__spz { font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.vrow__car { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; grid-column: 1 / -1; color: var(--ink-soft); }
.vrow__holder { color: var(--ink); }
.vrow__km { font-variant-numeric: tabular-nums; text-align: right; }
.vrow__tyre { grid-column: 1 / -1; font-size: 14px; }
.vrow--retired { opacity: .65; }
.vrow--head { display: none; }

@media (min-width: 760px) {
  .vrow {
    grid-template-columns: 120px minmax(0, 1.4fr) minmax(0, 1fr) 120px 170px;
    gap: 12px;
  }
  .vrow__car, .vrow__tyre { grid-column: auto; }
  .vrow__label { display: none; }
  .vrow--head {
    display: grid;
    min-height: 0;
    padding-block: 10px;
    background: #f6f8fa;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    cursor: default;
  }
  .vrow--head span:nth-child(4) { text-align: right; }
}

/* ── karta vozidla ───────────────────────────────────────────────────── */

.info { margin: 0; padding: 6px 18px; display: grid; }
.info__row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.info__row:first-child { border-top: 0; }
.info dt { color: var(--ink-soft); font-size: 14px; }
.info dd { margin: 0; }

/* ═══════════════════════════════════════════════════════════════════════
   M2 — protokol, fotky, rozpracované
   ═══════════════════════════════════════════════════════════════════════ */

.alert--danger { background: var(--danger); color: #fff; font-weight: 600; border: 0; }
.alert--ok     { background: #e4f4ea; color: var(--ok); border: 1px solid #bfe3cc; }
.alert--inline { display: block; margin-top: 6px; padding: 8px 10px; font-size: 13px; }
.alert p { margin: 0 0 8px; }

.subhead {
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--navy);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* ── stav ukládání ───────────────────────────────────────────────────── */

.savestate {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: #e6eaef;
  color: var(--ink-soft);
}
.savestate--saved  { background: #e4f4ea; color: var(--ok); }
.savestate--saving,
.savestate--dirty  { background: var(--navy-soft); color: var(--navy); }
.savestate--error  { background: var(--danger-bg); color: var(--danger); }

/* ── zaškrtávátka ────────────────────────────────────────────────────── */

.checkgroup { display: grid; gap: 8px; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }

.check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--navy); }
.alert .check { background: rgba(255, 255, 255, .7); }

.checks { display: grid; gap: 8px; grid-column: 1 / -1; }
.checks[hidden] { display: none; }

/* ── dlaždice fotek ──────────────────────────────────────────────────── */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.tiles--damage { grid-template-columns: repeat(auto-fill, minmax(110px, 140px)); }

.tile {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 4px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
  color: inherit;
  font: inherit;
  text-align: left;
  min-width: 0;
}
.tile--required.tile--missing { border-style: dashed; }
.tile--done  { border-color: #9fd4b4; background: #f4fbf6; }
.tile--busy  { border-color: #9dbbe0; }
.tile--error { border-color: var(--danger); background: var(--danger-bg); }
.tile--add   { cursor: pointer; border-style: dashed; place-items: center; min-height: 120px; touch-action: manipulation; }

.tile__shot {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #eceff3;
  cursor: pointer;
  touch-action: manipulation;
}
.tile__img, .tile__img img { display: block; width: 100%; height: 100%; }
.tile__img img { object-fit: cover; }
.tile__img img.is-broken { opacity: .3; }
.tile__cam { font-size: 26px; color: var(--ink-soft); line-height: 1; }

.tile__spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, .7);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.tile__label { font-size: 13px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.tile__label em { color: var(--danger); font-style: normal; }
.tile__state { font-size: 12px; color: var(--ink-soft); }
.tile__state--done { color: var(--ok); font-weight: 600; }
.tile__state--busy { color: var(--navy); font-weight: 600; }
.tile__state--error { color: var(--danger); font-weight: 600; }
.tile__error { font-size: 11px; color: var(--danger); line-height: 1.3; overflow-wrap: anywhere; }

.tile__del {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 24, 32, .68);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

/* ── poškození ───────────────────────────────────────────────────────── */

.damages { display: grid; gap: 12px; }
.damage {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.damage--known { background: #f6f8fa; }
.damage__head { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; justify-content: space-between; }
.damage .thumbs { grid-template-columns: repeat(auto-fill, minmax(90px, 110px)); }

/* ── rozpracované protokoly ──────────────────────────────────────────── */

.drafts {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  border: 1px solid #f0dcb0;
}
.drafts[hidden] { display: none; }
.drafts__title { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--warn-ink); }
.drafts__list { display: grid; gap: 8px; }

.draft {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
}
.draft__main { min-width: 0; }
.draft__meta { font-size: 13px; color: var(--ink-soft); }
.draft__actions { display: flex; gap: 8px; }

.vrow--pick { grid-template-columns: 120px 1fr auto; }
.summary { display: grid; gap: 8px; }
