/* ===========================================================
   Postod PWA — design system (granat #1B2A4A, żółty #FFC933)
   Mobile-first, wg mockupów screen-01/03/08
   =========================================================== */

:root {
  --navy: #1B2A4A;
  --navy-2: #24365C;
  --yellow: #FFC933;
  --yellow-soft: #FFF3CF;
  --bg: #F4F5F8;
  --card: #FFFFFF;
  --ink: #1B2A4A;
  --muted: #6E7687;
  --line: #E7E9EF;
  --red: #D92D20;
  --red-soft: #FEEBEA;
  --green: #12805C;
  --green-soft: #E7F6EF;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 14px rgba(27, 42, 74, .07);
  --nav-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-head: 'Poppins', 'Inter', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
img { max-width: 100%; }

/* ---------- wordmark ---------- */
.wordmark {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -.5px;
  color: var(--navy);
}
.wordmark .dot { color: var(--yellow); }
.wordmark--sm { font-size: 19px; }
.wordmark--lg { font-size: 34px; }
.wordmark--xl { font-size: 42px; }
.wordmark--light { color: #fff; }

/* ---------- layout ---------- */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(env(safe-area-inset-top), 16px) 20px 24px;
  max-width: 560px;
  margin: 0 auto;
}
.screen--center { align-items: center; justify-content: center; gap: 12px; }
.screen--sub { padding: 0; max-width: none; }
.screen--dark { background: #101C33; max-width: none; padding: 0; }

.splash-sub { color: var(--muted); font-size: 15px; }

/* ---------- znak wodny (ekran powitalny + blokada) ----------
   Duotone jak filigran na banknocie: obraz w skali szarości (asset już
   szary) wtopiony w granat przez soft-light przy niskiej nieprzezroczystości.
   UI leży NAD winietą przyciemniającą — pełny kontrast PIN-u i logo. */
.screen--watermark {
  position: relative;
  background: var(--navy);
  isolation: isolate;
}
.screen--watermark::before {
  content: '';
  position: absolute; inset: 0;
  background: url('../assets/watermark.jpg') center / cover no-repeat;
  mix-blend-mode: soft-light;
  opacity: .12;
  pointer-events: none;
  z-index: 0;
}
.screen--watermark::after {
  /* delikatna winieta pod elementami UI */
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 95% 70% at 50% 44%, rgba(13, 21, 40, .55), rgba(13, 21, 40, 0) 72%);
  pointer-events: none;
  z-index: 0;
}
.screen--watermark > * { position: relative; z-index: 1; }

/* ciemny wariant elementów na ekranach ze znakiem wodnym */
.screen--watermark .wordmark { color: #fff; }
.screen--watermark .splash-sub,
.screen--watermark .lock-sub { color: rgba(255, 255, 255, .72); }
.screen--watermark .pin-dots i { border-color: rgba(255, 255, 255, .38); }
.screen--watermark .pin-dots i.on { background: var(--yellow); border-color: var(--yellow); }
.screen--watermark .pinpad button {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  box-shadow: none;
}
.screen--watermark .pinpad button:active { background: rgba(255, 201, 51, .28); }
.screen--watermark .pinpad button.pad-empty { background: transparent; }
.screen--watermark .pinpad button.pad-back { background: transparent; }
.screen--watermark .form-err { color: #FFB4A9; }
.screen--watermark .btn--bio { color: #fff; }
.screen--watermark .btn--primary { background: var(--yellow); color: var(--navy); }
.screen--watermark .input {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .2);
  color: #fff;
}
.screen--watermark .input::placeholder { color: rgba(255, 255, 255, .45); }
.screen--watermark .input:focus { border-color: var(--yellow); }

#tab-content {
  max-width: 560px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 14px) 20px calc(var(--nav-h) + var(--safe-b) + 24px);
}
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 4px; }
.page-title {
  font-family: var(--font-head);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -1px;
  margin: 14px 0 18px;
}

/* ---------- przyciski ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px;
  font-weight: 600;
  padding: 13px 20px;
  transition: transform .08s ease, opacity .15s ease;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn, a.btn { text-decoration: none; }
.btn--primary { background: var(--navy); color: #fff; }
.btn--yellow { background: var(--yellow); color: var(--navy); }
.btn--light { background: rgba(255,255,255,.14); color: #fff; }
.btn--outline { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--big { width: 100%; padding: 16px 20px; font-size: 17px; border-radius: 16px; }
.btn--slim { padding: 10px 16px; font-size: 14.5px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--navy); background: var(--card); box-shadow: var(--shadow);
}
.icon-btn--light { background: rgba(255,255,255,.12); color: #fff; box-shadow: none; }
.icon-btn--danger { color: var(--red); }

/* ---------- formularze ---------- */
.form-col { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.input {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
}
.input:focus { border-color: var(--navy); }
textarea.input { resize: vertical; }
/* input[type=date] na iOS bywa zapadnięty i wyśrodkowany — wyrównanie do lewej
   i stała wysokość, by pasował do reszty pól. */
input[type="date"].input { min-height: 48px; text-align: left; -webkit-appearance: none; appearance: none; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--muted); margin: 18px 0 6px; display: block; }
.form-err { color: var(--red); font-size: 14px; font-weight: 500; }

/* ---------- onboarding ---------- */
.onb-step { display: flex; flex-direction: column; flex: 1; gap: 8px; padding-top: 5vh; }
.onb-hero { display: flex; flex-direction: column; align-items: center; gap: 18px; margin: 24px 0; text-align: center; }
.onb-bigico { font-size: 64px; }
.onb-title {
  font-family: var(--font-head);
  font-size: 32px; font-weight: 700; letter-spacing: -.8px;
  text-align: center; line-height: 1.2;
}
.onb-title--sm { font-size: 26px; margin-bottom: 4px; }
.onb-sub { color: var(--muted); text-align: center; max-width: 320px; margin: 0 auto 10px; }
.onb-points { list-style: none; display: flex; flex-direction: column; gap: 16px; margin: 18px 4px; }
.onb-points li {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); font-size: 15px;
}
.onb-points strong { font-size: 16px; }
.onb-ico { font-size: 24px; line-height: 1.2; }
.onb-actions { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 24px; }
.choose-cards { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.choose-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  text-align: left; border: 2px solid transparent;
}
.choose-card:active { border-color: var(--yellow); }
.choose-card strong { font-size: 18px; font-family: var(--font-head); }
.choose-card span:last-child { color: var(--muted); font-size: 14px; }
.choose-ico { font-size: 28px; }

/* ---------- PIN pad ---------- */
.lock-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; width: 100%; max-width: 340px; margin: 0 auto;
}
.lock-sub { color: var(--muted); }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 10px 0 4px; min-height: 16px; }
.pin-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  background: transparent; border: 2px solid #C4CAD6; transition: all .12s ease;
}
.pin-dots i.on { background: var(--navy); border-color: var(--navy); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.pinpad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  width: 100%; max-width: 300px; margin: 8px auto;
}
.pinpad button {
  height: 64px; border-radius: 50%; font-size: 24px; font-weight: 600;
  background: var(--card); box-shadow: var(--shadow); font-family: var(--font-head);
}
.pinpad button:active { background: var(--yellow-soft); }
.pinpad button.pad-empty { background: transparent; box-shadow: none; pointer-events: none; }
.pinpad button.pad-back { font-size: 20px; background: transparent; box-shadow: none; }
.btn--bio { color: var(--navy); font-weight: 600; gap: 8px; }

/* ---------- karty pism (screen-01) ---------- */
.card-list { display: flex; flex-direction: column; gap: 14px; }
.doc-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: grid; grid-template-columns: 72px 1fr auto;
  grid-template-rows: auto auto; gap: 4px 14px; align-items: center;
  text-align: left; width: 100%;
}
.doc-card__thumb {
  grid-row: 1 / 3;
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; background: var(--bg); border: 1px solid var(--line);
}
.doc-card__body { min-width: 0; align-self: end; }
.doc-card__title {
  font-family: var(--font-head); font-weight: 600; font-size: 17px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-card__sub {
  color: var(--muted); font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-card__chev { grid-row: 1 / 3; color: var(--navy); font-size: 22px; font-weight: 600; }
.doc-card__foot {
  grid-column: 2 / 4; align-self: start;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px;
}
.doc-card__date { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 5px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 12px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.badge--warn { background: var(--yellow-soft); color: #8A6400; border: 1px solid #F5DEA0; }
.badge--danger { background: var(--red-soft); color: var(--red); border: 1px solid #F8C9C5; }
.badge--done { background: var(--green-soft); color: var(--green); border: 1px solid #BFE7D2; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state h2 { font-family: var(--font-head); color: var(--ink); margin: 12px 0 8px; }
.empty-ico { font-size: 52px; }

/* ---------- terminy (screen-03) ---------- */
.guard-card {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  padding: 26px 20px; display: flex; flex-direction: column; align-items: center;
  gap: 8px; margin-bottom: 18px; text-align: center;
}
.guard-card h2 { font-family: var(--font-head); font-size: 21px; }
.guard-ring { position: relative; width: 200px; height: 200px; margin: 8px 0; }
.guard-ring svg { transform: rotate(-90deg); }
.guard-ring__num {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1;
}
.guard-ring__num strong { font-family: var(--font-head); font-size: 56px; font-weight: 700; }
.guard-ring__num span { font-size: 19px; color: var(--ink); margin-top: 2px; }
.guard-date { font-weight: 700; font-size: 18px; display: flex; gap: 8px; align-items: center; }
.guard-desc { color: var(--muted); font-size: 14.5px; }

/* ---------- widok pisma ---------- */
.sub-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(env(safe-area-inset-top), 12px) 16px 10px;
  background: linear-gradient(var(--bg) 75%, transparent);
}
.doc-body { padding: 6px 20px calc(40px + var(--safe-b)); max-width: 560px; margin: 0 auto; width: 100%; }
.doc-scans { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.doc-scan-img {
  width: 100%; border-radius: var(--radius); box-shadow: var(--shadow);
  background: #fff; cursor: zoom-in; display: block;
}
.deadline-box {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-top: 18px; display: flex; flex-direction: column; gap: 12px;
}
.deadline-box.is-set { background: var(--yellow-soft); box-shadow: none; border: 1px solid #F5DEA0; }
.deadline-head { display: flex; align-items: center; gap: 10px; font-size: 15.5px; }
.deadline-ico { font-size: 20px; }
.deadline-fields { display: flex; flex-direction: column; gap: 10px; }
.doc-meta { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 18px; }
#doc-done-btn { margin-top: 24px; }
#doc-done-btn.is-done { background: var(--green-soft); color: var(--green); }

/* ---------- nawigacja dolna ---------- */
#bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + var(--safe-b));
  width: min(calc(100% - 24px), 536px);
  background: var(--card); border-radius: 24px; box-shadow: 0 6px 24px rgba(27,42,74,.14);
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  align-items: center; padding: 10px 6px; z-index: 20;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 4px 0;
}
.nav-item.is-active { color: var(--navy); }
.nav-item.is-active span { box-shadow: 0 2px 0 var(--yellow); }
.nav-scan {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 600; color: var(--navy);
  margin-top: -30px;
}
.nav-scan svg {
  width: 58px; height: 58px; padding: 16px; border-radius: 50%;
  background: var(--navy); color: var(--yellow);
  box-shadow: 0 6px 16px rgba(27,42,74,.35); box-sizing: border-box;
}
.nav-scan:active svg { transform: scale(.95); }

/* ---------- skaner (screen-08) ---------- */
#screen-scan { display: flex; flex-direction: column; position: relative; }
.scan-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(env(safe-area-inset-top), 14px) 16px 12px;
}
.scan-header-spacer { width: 42px; }
.scan-stage { position: relative; flex: 1; overflow: hidden; background: #000; }
#scan-video, #scan-result {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
#scan-video { object-fit: cover; }
.scan-frame { position: absolute; inset: 7% 8%; pointer-events: none; }
.scan-frame .c { position: absolute; width: 42px; height: 42px; border: 4px solid var(--yellow); }
.c--tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.c--tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.c--bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.c--br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.scan-msg {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: rgba(16,28,51,.88); color: #fff; border-radius: 14px;
  padding: 12px 18px; font-size: 14.5px; width: max-content; max-width: 88%; text-align: center;
}
.scan-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 44px 6px;
}
.scan-side { color: rgba(255,255,255,.85); width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%;
  border: 4px solid #fff; display: flex; align-items: center; justify-content: center;
}
.shutter i { width: 58px; height: 58px; border-radius: 50%; background: var(--yellow); display: block; transition: transform .1s; }
.shutter:active i { transform: scale(.9); }
.scan-hint { text-align: center; color: rgba(255,255,255,.65); font-size: 14px; padding: 4px 0 calc(18px + var(--safe-b)); }
.scan-review {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 12px; padding: 16px 20px calc(20px + var(--safe-b));
  background: linear-gradient(transparent, rgba(16,28,51,.95) 40%);
}
.scan-review .btn { flex: 1; }

/* ---------- zoom ---------- */
#zoom-overlay { position: fixed; inset: 0; background: #101C33; z-index: 60; }
#zoom-overlay .icon-btn { position: absolute; top: max(env(safe-area-inset-top), 14px); right: 14px; z-index: 2; }
#zoom-pane { position: absolute; inset: 0; overflow: hidden; touch-action: none; display: flex; align-items: center; justify-content: center; }
#zoom-img { max-width: 100%; max-height: 100%; transform-origin: 0 0; will-change: transform; user-select: none; -webkit-user-drag: none; }

/* ---------- ustawienia ---------- */
.settings-h { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 22px 0 8px; }
.settings-group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.settings-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px; font-size: 15.5px; font-weight: 500; text-align: left;
  border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.settings-row:last-child { border-bottom: 0; }
.settings-row:active { background: var(--bg); }
.settings-row--static:active { background: transparent; }
.settings-row--danger { color: var(--red); }
.settings-val { color: var(--muted); font-size: 14px; }
.chev { color: #B7BECB; font-size: 20px; }
.settings-foot { text-align: center; color: var(--muted); font-size: 13px; margin: 26px 0 8px; line-height: 1.6; }

/* ---------- baner instalacji ---------- */
#install-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  width: min(calc(100% - 24px), 536px);
  background: var(--navy); color: #fff; border-radius: 18px;
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px;
  box-shadow: 0 8px 28px rgba(16,28,51,.35); z-index: 30;
}
.install-txt { flex: 1; display: flex; flex-direction: column; font-size: 13px; line-height: 1.35; }
.install-txt strong { font-size: 15px; font-family: var(--font-head); }
#install-banner .icon-btn { background: transparent; color: rgba(255,255,255,.7); box-shadow: none; width: 34px; height: 34px; }

/* ---------- modale / toast ---------- */
#modal-root {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16,28,51,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 24px 24px 0 0; padding: 22px 20px calc(26px + var(--safe-b));
  display: flex; flex-direction: column; gap: 14px;
  animation: slideup .22s ease;
  /* Ograniczenie wysokości + własne przewijanie: przy otwartej klawiaturze
     ekranowej i w landscape treść (np. formularz eksportu) pozostaje osiągalna. */
  max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } }
.modal h2 { font-family: var(--font-head); font-size: 21px; letter-spacing: -.4px; }
.modal p { color: var(--muted); font-size: 14.5px; }
.modal .pinpad button { height: 58px; }
.modal-btns { display: flex; gap: 10px; margin-top: 6px; }
.modal-btns .btn { flex: 1; }
.btn--danger { background: var(--red); color: #fff; }
.strength { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.strength i { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s, background .2s; }

.muted-note { color: var(--muted); font-size: 13.5px; min-height: 1.2em; }
.privacy-text { margin: 22px 4px; color: var(--muted); line-height: 1.7; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 20px);
  background: var(--navy); color: #fff; border-radius: 14px;
  padding: 12px 20px; font-size: 14.5px; font-weight: 500;
  box-shadow: 0 8px 28px rgba(16,28,51,.35); z-index: 70;
  max-width: calc(100% - 40px); text-align: center;
  animation: slideup .2s ease;
}

@media (min-width: 700px) {
  body { background: #E9EBF1; }
  .page-title { font-size: 34px; }
}
