:root {
  --blue: #0052a5;
  --blue-dark: #003f80;
  --blue-soft: #eef3f9;
  --text: #1b1b1b;
  --muted: #5c5c5c;
  --border: #c7c7c7;
  --line: #e0e0e0;
  --error: #d4213d;
  --ok: #2e7d32;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: #fff;
}

/* --- Układ ---------------------------------------------------------------- */

.topbar {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

/* --- Przełącznik języka --------------------------------------------------- */

.login-top {
  width: 100%;
  max-width: calc(550px + 32px);
  margin: 0 auto;
  padding: 18px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.login-top-end {
  justify-content: flex-end;
}

.login-logo {
  display: inline-flex;
  line-height: 0;
}

.login-logo img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.lang-switch {
  position: relative;
}

.lang-switch > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  color: var(--blue);
  font-weight: 700;
  font-size: 1rem;
  user-select: none;
}

.lang-switch > summary::-webkit-details-marker { display: none; }
.lang-switch > summary:hover { text-decoration: underline; }

.lang-globe {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.lang-chevron {
  width: 12px;
  height: 8px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.lang-switch[open] > summary .lang-chevron {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.lang-menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.lang-menu button:hover,
.lang-menu button[aria-selected="true"] {
  background: var(--blue-soft);
  color: var(--blue);
}

#site-header[hidden] { display: none !important; }

.brand {
  display: block;
  max-width: 550px;
  margin: 0 auto;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--blue);
  text-decoration: none;
}

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: calc(550px + 32px);
  margin: 0 auto;
  padding: 32px 16px 40px;
}

h1 { margin: 0 0 28px; font-size: 1.75rem; line-height: 1.25; }
h2 { margin: 0 0 16px; font-size: 1.25rem; }

a { color: var(--blue); }

/* --- Pasek postępu -------------------------------------------------------- */

.progress { --progress: 20%; margin-bottom: 28px; }

.progress-label {
  width: var(--progress);
  min-width: 3em;
  text-align: right;
  font-size: 0.95rem;
  margin-bottom: 4px;
  transition: width 0.3s ease;
}

.progress-track {
  height: 4px;
  background: #f0f2f5;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: var(--progress);
  background: var(--blue);
  transition: width 0.3s ease;
}

/* --- Formularz ------------------------------------------------------------ */

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

legend {
  display: block;
  width: 100%;
  padding: 0 0 14px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  font-size: 1.4rem;
  font-weight: 700;
}

.field { margin-bottom: 24px; }

label { display: block; margin-bottom: 8px; }
.optional { color: var(--muted); }

input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font: inherit;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}

input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 82, 165, 0.15);
}

input.invalid { border-color: var(--error); }
input.invalid:focus { box-shadow: 0 0 0 3px rgba(212, 33, 61, 0.15); }

.field-error {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--error);
}
.field-error:empty { display: none; }

.form-error { margin: 0 0 16px; color: var(--error); }
.form-error:empty { display: none; }

/* Pole hasła z przyciskami */
.input-wrap { position: relative; }
.input-wrap input { padding-right: 88px; }
.input-wrap .icon-btn:nth-of-type(1) { right: 44px; }
.input-wrap .icon-btn:nth-of-type(2) { right: 6px; }

.icon-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--blue);
  cursor: pointer;
}
.icon-btn:hover { background: var(--blue-soft); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn.active svg circle { fill: currentColor; }

/* Lista wymagań hasła */
.rules { list-style: none; margin: 16px 0 0; padding: 0; }
.rules li {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
}
.rules svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; opacity: 0.35; }
.rules li.ok { color: var(--ok); font-weight: 600; }
.rules li.ok svg { opacity: 1; }

/* Podpowiedź rozwijana */
.hint { margin: -8px 0 32px; }
.hint summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--blue);
  list-style: none;
}
.hint summary::-webkit-details-marker { display: none; }
.hint summary:hover { text-decoration: underline; }
.hint ul { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.hint code { background: var(--blue-soft); padding: 0 4px; border-radius: 3px; }

/* --- Przyciski ------------------------------------------------------------ */

.actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  height: 56px;
  padding: 0 20px;
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }

.btn-secondary { background: var(--blue-soft); color: var(--blue); }
.btn-secondary:hover { background: #dde7f3; }

.btn-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn-link[hidden] { display: none; }

.btn:disabled { opacity: 0.6; cursor: default; }

.switch { margin-top: 28px; color: var(--muted); }
.switch a { font-weight: 700; }

/* --- Panel ---------------------------------------------------------------- */

.panel {
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 20px;
  margin: 0;
}
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

@media (max-width: 440px) {
  .details { grid-template-columns: 1fr; gap: 2px; }
  .details dd { margin-bottom: 10px; }
}

/* --- Etap 5: kod od administratora --------------------------------------- */

body:has(.page-qr) { background: #f5f6f8; }
.page.page-qr { max-width: calc(1046px + 32px); }

.qr-panel {
  display: grid;
  grid-template-columns: 350px 1fr;
  padding: 48px 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}

/* Lewa kolumna: kod QR */
.qr-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 48px;
  border-right: 1px solid var(--line);
}

.qr-card {
  width: 252px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.qr {
  height: 250px;
  padding: 36px;
  display: grid;
  place-items: center;
  transition: opacity 0.3s ease;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr.ready { animation: reveal 0.4s ease-out; }
.qr.expired { opacity: 0.12; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--blue-soft);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.page.page-qr { display: flex; flex-direction: column; }

.qr-loading {
  flex: 1;
  min-height: 320px;
  display: grid;
  place-items: center;
}
.qr-loading[hidden] { display: none; }

.spinner-lg {
  width: 72px;
  height: 72px;
  border-width: 6px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.qr-number {
  padding: 9px 0 10px;
  background: #000;
  color: #fff;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}

.final-status { margin: 24px 0 0; max-width: 252px; text-align: center; color: var(--muted); }
.final-status[hidden] { display: none; }

.qr-timer { width: 252px; margin-top: 30px; text-align: center; }
.qr-timer[hidden] { display: none; }
.qr-timer-text { margin: 0 0 4px; }

.qr-timer-track {
  height: 8px;
  overflow: hidden;
  border: 1px solid #b9bec7;
  border-radius: 4px;
  background: #e4e6ea;
}
.qr-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--blue);
  border-radius: 3px;
  transition: width 1s linear;
}

.qr-refresh {
  margin-top: 18px;
  padding: 2px 4px;
  font: inherit;
  font-weight: 700;
  color: var(--blue);
  background: none;
  border: 0;
  cursor: pointer;
}
.qr-refresh:hover { text-decoration: underline; }
.qr-refresh:disabled { opacity: 0.6; cursor: default; }

/* Prawa kolumna: instrukcja */
.qr-info { padding: 0 48px; }

.final-title { margin: 0 0 22px; font-size: 1.15rem; font-weight: 700; }

.qr-steps { margin: 0 0 30px; padding-left: 24px; color: var(--muted); }
.qr-steps li { margin-bottom: 16px; padding-left: 2px; }
.qr-steps li::marker { color: var(--muted); }
.qr-steps strong { color: #3a3a3a; }

.qr-help { display: flex; align-items: flex-start; gap: 16px; margin: 0; }
.qr-help svg { flex: none; width: 22px; height: 22px; margin-top: 1px; fill: none; stroke: var(--blue); stroke-width: 1.6; stroke-linecap: round; }
.qr-help svg .dot { fill: var(--blue); }
.qr-help a { font-weight: 700; }

@media (max-width: 760px) {
  .qr-panel { grid-template-columns: 1fr; padding: 32px 0; }
  .qr-col { padding: 0 20px 32px; border-right: 0; border-bottom: 1px solid var(--line); }
  .qr-info { padding: 28px 20px 0; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .qr.ready { animation: none; }
  .qr-timer-fill { transition: none; }
  .spinner { animation-duration: 3s; }
}

/* --- Wybór metody rejestracji --------------------------------------------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 28px;
  font-weight: 700;
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.back-link svg {
  width: 14px;
  height: 14px;
}

.back-link:hover {
  color: var(--blue-dark);
}

.method-title {
  margin-bottom: 10px;
}

.method-lead {
  margin: 0 0 28px;
  color: var(--text);
}

.method-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.method-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px 18px;
  border-radius: 8px;
  background: #eef2f6;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}

.method-card:hover {
  background: #e4ebf2;
}

.method-card:focus-visible {
  outline: 3px solid rgba(0, 82, 165, 0.35);
  outline-offset: 2px;
}

.method-card-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--blue);
}

.method-card-icon svg {
  width: 44px;
  height: 44px;
}

.method-card-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.method-card-text strong {
  font-size: 1.05rem;
  color: var(--blue-dark);
}

.method-card-text span {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.method-card-chevron {
  flex: none;
  width: 10px;
  height: 16px;
  color: var(--blue);
}

.method-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 28px 0 0;
  color: var(--blue);
  font-weight: 600;
  line-height: 1.4;
}

.method-info svg {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

/* --- Stopka logowania ----------------------------------------------------- */

.login-footer {
  width: 100%;
  max-width: calc(550px + 32px);
  margin: auto auto 0;
  padding: 0 16px 48px;
}

.login-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
}

.login-footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.login-footer-links a:hover {
  color: var(--blue);
  text-decoration: underline;
}

/* --- Stopka --------------------------------------------------------------- */

.site-footer {
  padding: 40px 16px 44px;
  background: #fff;
}
.site-footer[hidden] { display: none; }

.footer-inner {
  max-width: 1046px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px 32px;
}

.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li + li { margin-top: 8px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--blue); text-decoration: underline; }

.footer-apps-title { margin: 0 0 16px; }

.store-badges { display: flex; flex-wrap: wrap; gap: 10px; }

.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 12px 0 10px;
  color: #fff;
  text-decoration: none;
  background: #000;
  border: 1px solid #a6a6a6;
  border-radius: 8px;
}
.store-badge:hover { background: #222; }
.store-badge svg { width: 26px; height: 26px; flex: none; }
.store-badge span { display: flex; flex-direction: column; font-size: 1.3rem; font-weight: 500; line-height: 1; letter-spacing: -0.01em; }
.store-badge small { margin-bottom: 2px; font-size: 0.6rem; font-weight: 400; letter-spacing: 0.02em; }

@media (max-width: 760px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-apps { grid-column: 1 / -1; }
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--wds-spacing-100);
  font-size: 1.375rem;
  font-weight: 700;
  color: #1b1b1b;
  text-decoration: none;
  background-color: white;
}