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

/* === Install banner (visible only when running in browser, never when standalone) === */
#install-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #4f6df5, #6f4ff5);
  color: #fff;
  font-size: 13px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(79, 109, 245, .3);
}
#install-banner.hidden { display: none; }
#install-banner .ib-ico { font-size: 18px; flex-shrink: 0; }
#install-banner .ib-text { flex: 1; line-height: 1.3; font-weight: 500; }
#install-banner button {
  background: #fff; color: #4f6df5;
  border: none; padding: 6px 14px;
  border-radius: 6px; font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
  transition: transform .1s, box-shadow .1s;
}
#install-banner button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.18); }
#install-banner #ib-close {
  background: transparent; color: #fff; opacity: .7;
  padding: 4px 8px; font-size: 18px; line-height: 1;
}
#install-banner #ib-close:hover { opacity: 1; transform: none; box-shadow: none; }
@media (max-width: 480px) {
  #install-banner .ib-text { font-size: 12px; }
}

/* === Install instructions modal === */
.ih-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 22, 50, .55); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
}
.ih-overlay.hidden { display: none; }
.ih-modal {
  background: #fff; width: 100%; max-width: 460px;
  border-radius: 14px 14px 0 0;
  max-height: 85vh; overflow-y: auto;
  display: flex; flex-direction: column;
  animation: ih-slide .2s ease-out;
}
@keyframes ih-slide { from { transform: translateY(100%); } to { transform: translateY(0); } }
.ih-modal header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #eef0f5;
}
.ih-modal h2 { font-size: 17px; font-weight: 700; color: #1a1d29; margin: 0; }
.ih-modal #ih-close {
  background: #f4f6fa; border: 1px solid #e5e7eb; color: #4a5168;
  width: 32px; height: 32px; border-radius: 8px;
  font-size: 18px; cursor: pointer; line-height: 1; padding: 0;
}
#ih-body {
  padding: 18px 22px; font-size: 14px; line-height: 1.6; color: #1a1d29;
}
#ih-body h3 { font-size: 14px; font-weight: 700; margin: 14px 0 8px; color: #4f6df5; }
#ih-body h3:first-child { margin-top: 0; }
#ih-body ol { padding-left: 22px; margin: 4px 0 12px; }
#ih-body ol li { margin-bottom: 6px; }
#ih-body kbd {
  background: #eef0fb; color: #4f6df5;
  padding: 1px 8px; border-radius: 5px;
  font-family: -apple-system, sans-serif; font-size: 13px; font-weight: 600;
  border: 1px solid #d6dcfb;
}
#ih-body .ih-already {
  background: #ecfdf5; color: #047857;
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; margin-top: 12px; line-height: 1.5;
}

/* In standalone (installed PWA) — hide both banner + modal completely */
@media (display-mode: standalone) {
  #install-banner, .ih-overlay { display: none !important; }
}

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f6fa; color: #1a1d29;
  font-size: 16px; line-height: 1.4;
}
body { padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
input, select {
  width: 100%; padding: 12px 14px;
  border: 1px solid #d0d4dc; border-radius: 8px; background: #fff;
  font-size: 16px;
}
input:focus, select:focus { outline: 2px solid #4f6df5; outline-offset: -1px; border-color: #4f6df5; }

.app-header {
  position: sticky; top: 0; z-index: 10;
  background: #4f6df5; color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.app-header h1 { margin: 0; font-size: 17px; font-weight: 600; }
.app-header .who { font-size: 12px; opacity: 0.85; }
.app-header button {
  background: rgba(255,255,255,0.18); color: #fff; border: none;
  padding: 6px 12px; border-radius: 6px; font-size: 13px;
}
.app-header button:active { background: rgba(255,255,255,0.3); }

#bell-btn { font-size: 18px; padding: 4px 10px; transition: background 0.15s; }
#bell-btn.bell-on  { background: #ffd54a; color: #1a1d29; box-shadow: 0 0 0 1px #fff inset; }
#bell-btn.bell-off { background: rgba(255,255,255,0.10); opacity: 0.65; }
#bell-btn.bell-on:hover  { background: #ffce2d; }
#bell-btn.bell-off:hover { opacity: 1; background: rgba(255,255,255,0.22); }

main { padding: 16px 14px 80px; max-width: 720px; margin: 0 auto; }

/* === Login screen === */
.login-screen {
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 24px; gap: 16px; background: linear-gradient(160deg, #4f6df5 0%, #6f4ff5 100%); color: #fff;
}
.login-screen h1 { font-size: 28px; font-weight: 700; margin: 0; }
.login-screen .sub { opacity: 0.85; margin-top: -8px; }
.login-card {
  width: 100%; max-width: 360px; background: #fff; color: #1a1d29;
  border-radius: 16px; padding: 24px 20px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.login-card label { font-size: 13px; font-weight: 500; color: #4a5168; display: block; }
.login-card input, .login-card select { margin-top: 4px; }
.login-card button.primary {
  background: #4f6df5; color: #fff; border: none; padding: 14px;
  border-radius: 8px; font-size: 16px; font-weight: 600; margin-top: 4px;
}
.login-card button.primary:disabled { opacity: 0.5; }
.login-error { color: #d9534f; font-size: 14px; padding: 8px 12px; background: #fdecec; border-radius: 6px; }

/* === Task list === */
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #7a8095;
  font-weight: 600; padding: 16px 4px 8px; }
.empty-state { text-align: center; padding: 48px 16px; color: #7a8095; }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

.task {
  background: #fff; border-radius: 12px; padding: 14px;
  margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex; gap: 12px; align-items: stretch;
  border-left: 4px solid #b8bdcc;
  cursor: pointer;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0.4; } to { opacity: 1; } }
.task:active { transform: scale(0.99); }
.task.s-Oczekuje      { border-left-color: #f9b94e; }
.task.s-W-realizacji  { border-left-color: #4f6df5; background: #f4f6ff; }
.task.s-Zakończone    { border-left-color: #5cb85c; opacity: 0.7; }
.task.s-Zablokowane   { border-left-color: #d9534f; background: #fdecec; }

.task-time { display: flex; flex-direction: column; align-items: center; min-width: 56px; padding-top: 2px; }
.task-time .h { font-size: 18px; font-weight: 700; line-height: 1; }
.task-time .d { font-size: 11px; color: #7a8095; margin-top: 4px; text-transform: uppercase; }
.task-time .dur { font-size: 10px; color: #7a8095; margin-top: 6px; padding: 2px 6px; background: #eef0f5; border-radius: 4px; }

.task-body { flex: 1; min-width: 0; }
.task-body .title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.task-body .meta { font-size: 12px; color: #7a8095; margin-top: 4px; }
.task-body .badges { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: #eef0f5; color: #4a5168; }
.badge.warn { background: #fff4d6; color: #8a6d00; }
.badge.bad  { background: #fdecec; color: #8a2c2a; }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0));
  width: 56px; height: 56px; border-radius: 28px;
  background: #4f6df5; color: #fff; border: none;
  font-size: 28px; font-weight: 300; line-height: 1;
  box-shadow: 0 4px 16px rgba(79,109,245,0.4);
  z-index: 20;
}
.fab:active { transform: scale(0.95); }

/* === Task detail / sheet === */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 30;
  display: flex; align-items: flex-end;
}
.sheet {
  background: #fff; width: 100%; max-height: 90vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
  display: flex; flex-direction: column; gap: 14px;
  animation: slideup 0.2s ease-out;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.sheet .close { background: transparent; border: none; font-size: 24px; padding: 4px 12px; }
.sheet .info { display: grid; grid-template-columns: 100px 1fr; gap: 6px 10px; font-size: 14px; }
.sheet .info dt { color: #7a8095; }
.sheet .info dd { margin: 0; font-weight: 500; }
.sheet textarea {
  width: 100%; min-height: 80px; padding: 10px 12px;
  border: 1px solid #d0d4dc; border-radius: 8px; resize: vertical;
  font-family: inherit; font-size: 15px;
}
.sheet .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet .actions button {
  flex: 1; min-width: 120px; padding: 14px; border-radius: 8px; border: none;
  font-size: 15px; font-weight: 600;
}
.btn-primary { background: #4f6df5; color: #fff; }
.btn-success { background: #5cb85c; color: #fff; }
.btn-secondary { background: #eef0f5; color: #1a1d29; }
.btn-danger { background: #fdecec; color: #d9534f; }
.btn-primary:disabled, .btn-success:disabled { opacity: 0.5; }

.parts-list { list-style: none; padding: 0; margin: 0; }
.parts-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: 10px 12px;
  background: #f5f6fa;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}
.parts-list .p-name { grid-column: 1; grid-row: 1; font-weight: 500; color: #1a1d29; }
.parts-list .p-qty  { grid-column: 2; grid-row: 1; font-weight: 600; color: #4f6df5; white-space: nowrap; }
.parts-list .p-lok  { grid-column: 1; grid-row: 2; font-size: 12px; color: #4a5168; }
.parts-list .p-stock { grid-column: 2; grid-row: 2; font-size: 12px; color: #5cb85c; white-space: nowrap; }
.parts-list .p-stock.low { color: #d9534f; font-weight: 600; }

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #1a1d29; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; z-index: 50; max-width: 90vw;
  animation: fadein 0.2s;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
