/* Paleta: grafit warsztatowy + akcent zależny od strefy.
   Produkcja = kolor sklejki brzozowej, Magazyn = niebieska kreda traserska.
   Cała aplikacja „przebarwia się” po przełączeniu strefy, żeby nigdy nie pomylić miejsca pracy. */
:root {
  --ink: 20 23 28;        /* #14171C tło */
  --panel: 29 33 40;      /* #1D2128 */
  --raise: 38 43 52;      /* #262B34 */
  --line: 51 58 69;       /* #333A45 */
  --paper: 232 228 220;   /* #E8E4DC tekst */
  --muted: 154 159 168;   /* #9A9FA8 */
  --danger: 229 114 106;  /* #E5726A */
  --accent: 224 184 114;  /* #E0B872 sklejka */
  --on-accent: 36 26 10;
  color-scheme: dark;
}
html[data-zone="magazyn"] {
  --accent: 141 184 217;  /* #8DB8D9 kreda */
  --on-accent: 10 24 36;
}

html, body {
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
body { min-height: 100dvh; }
button, a, label { touch-action: manipulation; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, textarea, select { font-size: 16px; }

:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; border-radius: 10px; }

.ico { display: inline-block; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }

.bottombar {
  position: fixed; inset: auto 0 0 0; z-index: 25; background: rgb(var(--panel));
  border-top: 1px solid rgb(var(--line)); padding-bottom: env(safe-area-inset-bottom);
}

.pt-safe { padding-top: env(safe-area-inset-top); }
.pb-safe { padding-bottom: env(safe-area-inset-bottom); }

#toast-root { bottom: calc(88px + env(safe-area-inset-bottom)); }

/* Dotyk jak w Androidzie: lekkie wciśnięcie zamiast efektu hover */
.tap { transition: transform .12s ease, background-color .15s ease, opacity .15s ease; user-select: none; }
.tap:active { transform: scale(.97); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 999px; color: rgb(var(--paper));
}
.icon-btn:active { background: rgb(var(--raise)); }
.icon-btn svg { width: 24px; height: 24px; }

.field {
  width: 100%; background: rgb(var(--panel)); border: 1px solid rgb(var(--line));
  border-radius: 14px; padding: 12px 14px; color: rgb(var(--paper));
}
.field::placeholder { color: rgb(var(--muted)); }
.field:focus { outline: none; border-color: rgb(var(--accent)); box-shadow: 0 0 0 1px rgb(var(--accent)); }
textarea.field { resize: vertical; line-height: 1.5; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 999px; font-weight: 600;
}
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: rgb(var(--accent)); color: rgb(var(--on-accent)); }
.btn-tonal { background: rgb(var(--raise)); color: rgb(var(--paper)); }
.btn-ghost { color: rgb(var(--accent)); }
.btn-danger { background: rgb(var(--danger)); color: rgb(var(--ink)); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 500;
  background: rgb(var(--raise)); border: 1px solid rgb(var(--line)); color: rgb(var(--paper));
  white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; }
.chip-warn { color: rgb(var(--accent)); }
.chip-accent { background: rgb(var(--accent) / .15); border-color: rgb(var(--accent) / .3); color: rgb(var(--accent)); font-weight: 600; }

.section-title { font-family: "Barlow Condensed", Barlow, sans-serif; font-weight: 600; font-size: 22px; line-height: 1.15; }

/* Dolna nawigacja w stylu Material 3 */
.navtab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 12px; color: rgb(var(--muted)); }
.navpill { display: grid; place-items: center; width: 64px; height: 32px; border-radius: 999px; transition: background-color .2s ease; }
.navpill svg { width: 22px; height: 22px; }
.navtab.is-active { color: rgb(var(--paper)); }
.navtab.is-active .navpill { background: rgb(var(--accent) / .22); color: rgb(var(--accent)); }

/* Przełącznik strefy — jedyny „głośny” element interfejsu */
.zone-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 18px; background: rgb(var(--panel)); border: 1px solid rgb(var(--line)); }
.zone-switch button { height: 44px; border-radius: 14px; font-family: "Barlow Condensed", sans-serif; font-weight: 600; font-size: 19px; color: rgb(var(--muted)); transition: background-color .2s ease, color .2s ease; }
.zone-switch button[aria-selected="true"] { background: rgb(var(--accent)); color: rgb(var(--on-accent)); }

/* Ekran wyboru strefy — duże kafle w kolorach stref */
.zone-tile { position: relative; transition: transform .12s ease; box-shadow: 0 10px 30px rgb(0 0 0 / .35); }
.zone-tile--produkcja { background: rgb(224 184 114); color: rgb(36 26 10); }
.zone-tile--magazyn { background: rgb(141 184 217); color: rgb(10 24 36); }
.zone-tile__badge { position: absolute; top: 16px; right: 16px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: rgb(0 0 0 / .14); }

.zone-chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px; border-radius: 999px;
  background: rgb(var(--accent)); color: rgb(var(--on-accent)); font-family: "Barlow Condensed", sans-serif; font-weight: 600; font-size: 18px; white-space: nowrap; }
.zone-chip svg { width: 18px; height: 18px; }

.stepper { display: flex; align-items: center; height: 44px; border: 1px solid rgb(var(--line)); border-radius: 14px; background: rgb(var(--ink)); }
.stepper button { width: 40px; height: 100%; display: grid; place-items: center; color: rgb(var(--paper)); }
.stepper button svg { width: 18px; height: 18px; }
.stepper input { width: 52px; height: 100%; text-align: center; background: transparent; border: 0; color: rgb(var(--paper)); font-weight: 600; }
.stepper input:focus { outline: none; }

.segmented { display: flex; gap: 6px; }
.segmented button { flex: 1; height: 40px; border-radius: 999px; border: 1px solid rgb(var(--line)); color: rgb(var(--muted)); font-weight: 600; font-size: 15px; }
.segmented button[aria-selected="true"] { background: rgb(var(--paper)); color: rgb(var(--ink)); border-color: transparent; }

.fab {
  position: fixed; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 25;
  display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 22px 0 18px;
  border-radius: 18px; background: rgb(var(--accent)); color: rgb(var(--on-accent)); font-weight: 600;
  box-shadow: 0 8px 24px rgb(0 0 0 / .45);
}
.fab svg { width: 24px; height: 24px; }

.actionbar {
  position: fixed; inset: auto 0 0 0; z-index: 25; background: rgb(var(--panel));
  border-top: 1px solid rgb(var(--line)); padding-bottom: env(safe-area-inset-bottom);
}
.actionbar button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 12px; font-size: 12px; font-weight: 500; color: rgb(var(--paper)); }
.actionbar button svg { width: 22px; height: 22px; }
.actionbar .danger { color: rgb(var(--danger)); }

.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery > * { flex: 0 0 100%; scroll-snap-align: center; }

.bom-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.bom-table th { text-align: left; font-size: 13px; font-weight: 600; color: rgb(var(--muted)); padding: 0 6px 6px; }
.bom-table td { padding: 3px; vertical-align: top; }
.bom-table input { width: 100%; background: rgb(var(--panel)); border: 1px solid rgb(var(--line)); border-radius: 10px; padding: 9px 9px; color: rgb(var(--paper)); }
.bom-table input:focus { outline: none; border-color: rgb(var(--accent)); }

.check-row input[type="checkbox"] { appearance: none; width: 24px; height: 24px; border-radius: 7px; border: 2px solid rgb(var(--muted)); display: grid; place-items: center; flex: none; }
.check-row input[type="checkbox"]:checked { background: rgb(var(--accent)); border-color: rgb(var(--accent)); }
.check-row input[type="checkbox"]:checked::after { content: ""; width: 7px; height: 12px; border: solid rgb(var(--on-accent)); border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }

.spinner { width: 22px; height: 22px; border-radius: 999px; border: 2.5px solid rgb(var(--line)); border-top-color: rgb(var(--accent)); animation: spin .8s linear infinite; display: inline-block; flex: none; }
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }

.skeleton { background: linear-gradient(90deg, rgb(var(--panel)), rgb(var(--raise)), rgb(var(--panel))); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; border-radius: 12px; }

.sheet { animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1); max-height: 88dvh; overflow-y: auto; }
.fade-in { animation: fade .2s ease; }
.toast { animation: toast-in .2s ease; }
.toast-out { opacity: 0; transform: translateY(8px); transition: all .2s ease; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
