*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --accent: #1a73e8;
  --text: #eaeaea;
  --text2: #a0a0b0;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.logo { font-size: 28px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.logo span { color: var(--text); }
.subtitle { color: var(--text2); font-size: 14px; margin-bottom: 40px; }

.form-group { width: 100%; margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.form-group input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 18px;
  padding: 14px 16px;
  outline: none;
  transition: border-color .2s;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text2); font-size: 14px; }

.btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  padding: 16px;
  cursor: pointer;
  transition: opacity .2s;
  margin-top: 8px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { opacity: .8; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--bg3);
  color: var(--text2);
}

.error-msg {
  background: rgba(233,69,96,.15);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  width: 100%;
  display: none;
}
.error-msg.show { display: block; }

/* Ekran startowy — siatka skilli */
.greeting { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.greeting-sub { color: var(--text2); font-size: 14px; margin-bottom: 32px; }

.skills-grid {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.skill-btn {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 17px;
  font-weight: 500;
  padding: 20px 20px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background .2s, border-color .2s;
}
.skill-btn:active { background: var(--bg3); border-color: var(--accent); }
.skill-btn:disabled { opacity: .5; cursor: not-allowed; }
.skill-btn:disabled:active { background: var(--bg2); border-color: var(--bg3); }
.skill-hint { font-size: 13px; color: var(--text2); margin: -6px 0 4px 50px; }
.skill-icon { font-size: 24px; width: 36px; text-align: center; flex-shrink: 0; }

.logout-btn {
  margin-top: 24px;
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
}

/* Czat */
.chat-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--bg3);
  flex-shrink: 0;
}
.chat-back { background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; padding: 0; }
.chat-title { font-size: 16px; font-weight: 600; flex: 1; }
.chat-exit {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  min-height: 0;
}

.msg { display: flex; flex-direction: column; gap: 4px; }
.msg-bot .bubble {
  background: var(--bg2);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 12px 16px;
  font-size: 15px;
  max-width: 85%;
  align-self: flex-start;
}
.msg-user .bubble {
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 var(--radius);
  padding: 12px 16px;
  font-size: 15px;
  max-width: 85%;
  align-self: flex-end;
  color: #fff;
}

.chat-input-area {
  background: var(--bg2);
  border-top: 1px solid var(--bg3);
  width: 100%;
  flex-shrink: 0;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.chat-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chat-btn {
  background: var(--bg3);
  border: none;
  border-radius: 20px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background .2s;
}
.chat-btn:active { background: var(--accent); }
.chat-btn-skip { background: transparent; border: 1px solid var(--bg3); color: var(--text2); }
.chat-btn-primary { background: var(--accent); color: #fff; }

.chat-text-input-row { display: flex; gap: 8px; align-items: center; }
.chat-text-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
}
.chat-text-input:focus { border-color: var(--accent); }
.mic-btn {
  background: var(--bg3);
  border: none;
  border-radius: 50%;
  color: var(--text);
  font-size: 20px;
  width: 46px;
  height: 46px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mic-btn.recording { background: var(--accent); }
.send-btn {
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  width: 46px;
  height: 46px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Foto preview */
.photo-preview {
  width: 100%;
  border-radius: var(--radius);
  margin-top: 8px;
  max-height: 200px;
  object-fit: cover;
}
.photo-count { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* Potwierdzenie końcowe */
.success-screen {
  text-align: center;
  padding: 40px 20px;
}
.success-icon { font-size: 64px; margin-bottom: 16px; }
.success-title { font-size: 22px; font-weight: 700; color: #4caf50; margin-bottom: 8px; }
.success-nr { font-size: 28px; font-weight: 700; color: var(--accent); margin-bottom: 24px; }
.success-sub { color: var(--text2); font-size: 15px; }

/* Spinner */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--bg3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Detekcja jakości zdjęcia */
.quality-warning {
  background: rgba(255,152,0,.15);
  border: 1px solid #ff9800;
  border-radius: var(--radius);
  color: #ff9800;
  font-size: 13px;
  padding: 10px 14px;
  margin-top: 8px;
}

@media (max-width: 360px) {
  .skill-btn { font-size: 15px; padding: 16px; }
  .logo { font-size: 24px; }
}

/* Ekran potwierdzenia */
.confirm-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--bg3); font-size: 14px; }
.confirm-row:last-child { border-bottom: none; }
/* Etykieta bierze szerokość treści (maks. 48%), wartość resztę — krótkie słowa
   (np. „Uwagi”, numery) nie łamią się, długie zawijają się w ramce. */
.confirm-key { color: var(--text2); flex: 0 0 auto; max-width: 48%; min-width: 0; overflow-wrap: break-word; }
.confirm-val { color: var(--text); text-align: right; flex: 1 1 0; min-width: 0; overflow-wrap: break-word; }
.confirm-sekcja { font-weight: 600; margin: 10px 0 2px; overflow-wrap: break-word; }

/* Baner instalacji PWA */
#pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--bg3);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.35s ease;
  max-width: 480px;
  margin: 0 auto;
}
#pwa-install-banner.show {
  transform: translateY(0);
}
#pwa-install-banner img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}
.pwa-banner-text {
  flex: 1;
  min-width: 0;
}
.pwa-banner-text strong {
  display: block;
  font-size: 14px;
  color: var(--text);
}
.pwa-banner-text span {
  font-size: 12px;
  color: var(--text2);
}
#pwa-install-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font);
}
#pwa-dismiss-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
  line-height: 1;
}

/* Opcja podpowiedziana z poprzedniego raportu tego pojazdu — wyróżniona
   ramką, żeby kierowca widział, co system uważa za stan zastany. */
.chat-btn-default {
  border: 2px solid #1a73e8;
}

/* Ekran stanu naczepy (krok czatu 'stan_naczepy') */
.stan-ekran { max-height: 72vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 4px; }
.stan-naglowek { font-weight: 600; font-size: 16px; }
.stan-info { color: var(--text2); font-size: 13px; }
.stan-przelacznik { display: flex; gap: 8px; border-radius: var(--radius); }
.stan-przelacznik .chat-btn { flex: 1; min-height: 44px; }
.chat-btn.aktywny { background: var(--accent); color: #fff; }
.stan-czystosc-przyciski .chat-btn { font-weight: 700; }
.chat-btn.stan-czysta.aktywny { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.chat-btn.stan-brudna.aktywny { background: #c62828; border-color: #c62828; color: #fff; }
.stan-podpowiedz { color: #f0ad4e; font-size: 13px; }
.stan-wiersz { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius); background: var(--bg2); }
.stan-lista { flex-direction: column; align-items: stretch; }
.zmieniony { outline: 2px solid var(--accent); }
.stan-etykieta { flex: 1; }
.stan-krok { width: 44px; height: 44px; font-size: 22px; padding: 0; }
.stan-liczba { width: 64px; height: 44px; text-align: center; font-size: 18px; background: var(--bg); color: var(--text); border: 1px solid var(--bg3); border-radius: 8px; }
.stan-liczba.blad { border-color: #e53935; }
.stan-chipy { display: flex; flex-wrap: wrap; gap: 6px; }
.stan-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 16px; background: var(--bg3); }
.stan-chip-usun { background: none; border: none; color: var(--text2); font-size: 16px; min-width: 28px; min-height: 28px; }
.stan-dodaj { display: flex; gap: 6px; }
.stan-dodaj input { flex: 1; height: 44px; padding: 0 10px; background: var(--bg); color: var(--text); border: 1px solid var(--bg3); border-radius: 8px; font-size: 16px; }
.stan-blad { color: #ff6b6b; font-size: 13px; }
.stan-czystosc { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; border-radius: var(--radius); background: var(--bg2); }
.stan-sekcja { font-weight: 600; }
.stan-podtytul { color: var(--text2); font-size: 13px; margin-top: 4px; }
.stan-check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.stan-check input { width: 22px; height: 22px; }
.stan-zapisz { width: 100%; min-height: 52px; font-size: 17px; position: sticky; bottom: 0; }
