/* Papírna PoC — design dle mocku „Sběr vad“: cream + tmavá zelená + serif. */

:root {
  --cream: #F4EEE1;
  --card: #FBF7EC;
  --border: #E3D9C4;
  --green: #1C3B2D;
  --green-soft: #2E5743;
  --ink: #20301F;
  --muted: #8C846E;
  --danger: #A4452F;
  --ok: #3C6E47;
  --radius: 18px;
  --serif: ui-serif, "Iowan Old Style", "Palatino", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* zabij double-tap zoom na iOS (rychlé ťukání vad) */
html, body, button, a, input, select, label { touch-action: manipulation; }

html, body { height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* ---------- header ---------- */
.hdr {
  background: var(--green);
  color: #F2EAD8;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 14px;
  display: flex; align-items: baseline; gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.hdr { align-items: center; }
.hdr .brand { height: 42px; width: auto; flex: 0 0 auto; display: block; }
.hdr .meta { font-family: var(--mono); font-size: 13px; opacity: .85; margin-left: auto; text-align: right; }
.hdr-logout {
  background: rgba(242, 234, 216, .12); border: none; border-radius: 12px;
  width: 40px; height: 40px; display: grid; place-items: center;
  color: #F2EAD8; cursor: pointer; flex: 0 0 auto; margin-left: 12px;
}
.hdr-logout svg { width: 20px; height: 20px; }
.hdr .back {
  background: none; border: none; color: #F2EAD8; font-size: 17px; font-family: var(--sans);
  padding: 4px 10px 4px 0; cursor: pointer; flex: 0 0 auto;
}

/* ---------- layout ---------- */
.page { flex: 1; padding: 18px 16px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 14px; }
.spacer { flex: 1; }

.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.kicker b { color: var(--green-soft); font-weight: 600; }
.linehead { display: flex; align-items: baseline; gap: 10px; }
.linehead .name { font-family: var(--serif); font-size: 24px; color: var(--green); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.card.flat { background: transparent; border-style: dashed; }

h2.section { font-family: var(--serif); font-size: 20px; color: var(--green); font-weight: 600; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; border: none; border-radius: 16px; cursor: pointer;
  font-family: var(--sans); font-size: 18px; font-weight: 600; padding: 16px;
  transition: transform .06s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green); color: #F2EAD8; }
.btn.ghost { background: transparent; color: var(--green); border: 1.5px solid var(--green); }
.btn.subtle { background: #EFE7D4; color: var(--ink); font-weight: 500; }
.btn.danger { background: var(--danger); color: #FFF6EC; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.small { width: auto; padding: 9px 16px; font-size: 15px; border-radius: 12px; display: inline-block; }

/* ---------- login ---------- */
.login-title { font-family: var(--serif); font-size: 34px; color: var(--green); line-height: 1.15; margin-top: 8px; }
.account {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; font-family: var(--sans);
}
.account:active { transform: scale(.99); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
  color: #F2EAD8; display: grid; place-items: center;
  font-family: var(--serif); font-size: 19px; font-weight: 600;
}
.account .who { flex: 1; }
.account .who .nm { font-size: 18px; font-weight: 600; }
.account .who .rl { font-size: 13px; color: var(--muted); }
.account .chev { color: var(--muted); font-size: 20px; }

/* PIN pad */
.pin-dots { display: flex; gap: 14px; justify-content: center; padding: 10px 0 4px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--green); }
.pin-dots span.on { background: var(--green); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  font-size: 24px; font-family: var(--serif); color: var(--ink); padding: 16px 0; cursor: pointer;
}
.pinpad button:active { background: #EFE7D4; }
.pinpad button.fn { font-family: var(--sans); font-size: 15px; color: var(--muted); }
.pin-err { color: var(--danger); font-size: 14px; text-align: center; min-height: 20px; }

/* ---------- defect grid (worker home) ---------- */
.defect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.defect {
  position: relative;
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 22px 12px 18px; text-align: center; cursor: pointer; font-family: var(--sans);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 128px; justify-content: center;
}
.defect:active { background: #EFE7D4; transform: scale(.97); }
.defect svg { width: 30px; height: 30px; stroke: var(--green); }
.defect .dn { font-size: 17px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.defect .count {
  position: absolute; top: 10px; right: 12px;
  background: var(--green); color: #F2EAD8; border-radius: 999px;
  font-family: var(--mono); font-size: 13px; min-width: 24px; padding: 3px 7px;
}
.defect .count.zero { display: none; }
.defect.bump { animation: bump .25s ease; }
@keyframes bump { 40% { transform: scale(1.05); } }

.tallybar {
  display: flex; align-items: center; gap: 12px;
  border-top: 1px solid var(--border); padding-top: 14px;
}
.tallybar .total { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.tallybar .total small { font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 14px; }
.tallybar .undo {
  margin-left: auto; background: #EFE7D4; border: none; border-radius: 12px;
  font-size: 15px; color: var(--ink); padding: 9px 16px; cursor: pointer;
}
.tallybar .undo[disabled] { opacity: .4; }
.empty-hint { text-align: center; color: var(--muted); font-size: 16px; padding: 14px 0 4px; }

/* ---------- submit (end of shift) ---------- */
.prod-row { display: flex; flex-direction: column; gap: 12px; }
.prod-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 9px 16px; font-size: 15px; cursor: pointer; font-family: var(--sans); color: var(--ink);
}
.chip.on { border-color: var(--green); background: var(--green); color: #F2EAD8; }

.bigval { text-align: center; padding: 6px 0 2px; }
.bigval .v { font-family: var(--serif); font-size: 56px; font-weight: 600; color: var(--green); line-height: 1; }
.bigval .u { color: var(--muted); font-size: 15px; }

input[type="range"] {
  width: 100%; appearance: none; -webkit-appearance: none; height: 38px; background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 999px; background: #E7DEC9; border: 1px solid var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--green); margin-top: -13px; border: 3px solid #F2EAD8;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; }
.stepper button {
  width: 52px; height: 44px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--card); font-size: 22px; color: var(--green); cursor: pointer;
}
.stepper input {
  width: 110px; text-align: center; font-family: var(--serif); font-size: 24px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 14px; padding: 8px; background: var(--card); color: var(--ink);
}

.defrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.defrow:last-child { border-bottom: none; }
.defrow .nm { flex: 1; font-size: 16px; }
.defrow .ministep { display: flex; align-items: center; gap: 8px; }
.defrow .ministep button {
  width: 38px; height: 36px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--card); font-size: 18px; color: var(--green); cursor: pointer;
}
.defrow .ministep .n { font-family: var(--mono); font-size: 17px; min-width: 34px; text-align: center; }

/* ---------- status / done ---------- */
.status-icon { font-size: 54px; text-align: center; }
.status-title { font-family: var(--serif); font-size: 28px; color: var(--green); text-align: center; font-weight: 600; }

.summary { font-size: 16px; }
.summary .row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.summary .row:last-child { border-bottom: none; }
.summary .row b { font-family: var(--mono); font-weight: 600; }

/* ---------- foreman ---------- */
.lane { display: flex; flex-direction: column; gap: 10px; }
.lane-card { display: flex; align-items: center; gap: 12px; }
.lane-card .lbl { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--green); width: 44px; }
.lane-card .info { flex: 1; min-width: 0; }
.lane-card .info .machine { font-size: 13px; color: var(--muted); font-family: var(--mono); }
.lane-card .info .who { font-size: 17px; font-weight: 600; }
.lane-card .info .who.none { color: var(--muted); font-weight: 400; font-style: italic; }
.lane-card .stat { text-align: right; }
.lane-card .stat .n { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.lane-card .stat .t { font-size: 12px; color: var(--muted); }

.pill { display: inline-block; border-radius: 999px; font-size: 12px; padding: 4px 10px; font-weight: 600; }
.pill.work { background: #E4EBE2; color: var(--ok); }
.pill.wait { background: #F3E3C8; color: #8A6210; }
.pill.sent { background: var(--green); color: #F2EAD8; }
.pill.idle { background: #EBE4D2; color: var(--muted); }

.tabs { display: flex; gap: 8px; }
.tabs .tab {
  flex: 1; text-align: center; padding: 11px; border-radius: 13px; cursor: pointer;
  background: transparent; border: 1.5px solid var(--border); font-size: 15px; color: var(--muted); font-family: var(--sans);
}
.tabs .tab.on { border-color: var(--green); background: var(--green); color: #F2EAD8; font-weight: 600; }
.badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 5px; }

.assign-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.assign-row:last-child { border-bottom: none; }
.assign-row .who { flex: 1; font-weight: 600; }
.assign-row select {
  font-size: 16px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--ink); font-family: var(--sans);
}

/* notification banner */
#banner-root { position: fixed; top: 0; left: 0; right: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.banner {
  pointer-events: auto;
  margin-top: calc(env(safe-area-inset-top) + 8px);
  background: var(--ink); color: #F6F1E4; border-radius: 16px; padding: 13px 18px;
  width: min(92vw, 480px); box-shadow: 0 6px 24px rgba(0,0,0,.35);
  display: flex; gap: 12px; align-items: center; font-size: 15px;
  animation: slidein .3s ease;
}
.banner b { font-weight: 600; }
.banner .x { margin-left: auto; background: none; border: none; color: #cfc7b2; font-size: 18px; cursor: pointer; }
@keyframes slidein { from { transform: translateY(-130%); } }

.toast { position: fixed; bottom: calc(env(safe-area-inset-bottom) + 18px); left: 50%; transform: translateX(-50%);
  background: var(--green); color: #F2EAD8; padding: 11px 20px; border-radius: 999px; font-size: 15px; z-index: 60;
  animation: fadein .25s ease; white-space: nowrap; }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } }

/* bottom sheet (zadání počtu / popis Jiné) */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(20, 30, 22, .45); z-index: 70;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--cream); border-radius: 22px 22px 0 0; width: 100%; max-width: 560px;
  padding: 22px 18px calc(env(safe-area-inset-bottom) + 18px);
  display: flex; flex-direction: column; gap: 12px;
  animation: sheetup .25s ease;
  transition: transform .18s ease; /* plynulé zvednutí nad klávesnici */
}
@keyframes sheetup { from { transform: translateY(40%); opacity: .5; } }
.sheet h3 { font-family: var(--serif); font-size: 22px; color: var(--green); font-weight: 600; }
.sheet-input {
  width: 100%; font-size: 17px; padding: 13px 14px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--card); color: var(--ink); font-family: var(--sans);
}
.sheet .btn { margin-top: 2px; }

/* poznámky k „Jiné“ */
.notechips { display: flex; flex-wrap: wrap; gap: 6px; }
.notechips span {
  background: #EFE7D4; border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; padding: 5px 12px; color: var(--ink);
}
.notechips span::before { content: 'Jiné: '; color: var(--muted); }

/* psatelné počty vad (submit + review) */
.ministep input.cnt {
  width: 64px; text-align: center; font-family: var(--mono); font-size: 17px;
  border: 1px solid var(--border); border-radius: 11px; padding: 7px 4px;
  background: var(--card); color: var(--ink);
}

/* badge se zadaným množstvím na chipu výrobku */
.chip { position: relative; }
.chip .cnt-badge {
  margin-left: 7px; background: #F2EAD8; color: var(--green);
  border-radius: 999px; font-family: var(--mono); font-size: 12px; padding: 2px 8px; font-weight: 600;
}
.chip:not(.on) .cnt-badge { background: var(--green); color: #F2EAD8; }

.footer-note { text-align: center; color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.linklike { background: none; border: none; color: var(--muted); text-decoration: underline; font-size: 13px; cursor: pointer; }

@media (min-width: 700px) {
  body { background: #E9E1CE; }
  #app { box-shadow: 0 0 60px rgba(0,0,0,.12); background: var(--cream); min-height: 100vh; }
}

/* portrait lock: na telefonu naležato překryj appku výzvou (manifest orientation
   řeší jen nainstalovanou PWA na Androidu; iOS tohle neumí, proto overlay) */
#rotate-lock {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: var(--green); color: #F2EAD8;
  font-family: var(--serif); font-size: 24px; text-align: center;
  align-items: center; justify-content: center; line-height: 1.5;
}
@media (orientation: landscape) and (max-height: 520px) {
  #rotate-lock { display: flex; }
}
