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

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: #f0f4ff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOP BAR */
.topbar {
  background-color: #1a3c8f;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.btn-back-marketplace {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  transition: background 0.15s;
}
.btn-back-marketplace:hover { background: rgba(255, 255, 255, 0.12); }
.btn-back-marketplace:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }

@media (max-width: 480px) {
  .topbar { padding: 12px 16px; }
  .btn-back-marketplace { font-size: 12px; padding: 6px 10px; }
}

.topbar .logo-circle {
  width: 42px;
  height: 42px;
  background-color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  color: #1a3c8f;
  letter-spacing: -1px;
}

.topbar .app-name {
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

.topbar .app-subtitle {
  color: #a8c0f0;
  font-size: 12px;
  margin-top: 2px;
}

/* MAIN CONTENT */
.main {
  flex: 1;
  padding: 40px 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(26, 60, 143, 0.12);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
}

.card h2 {
  color: #1a3c8f;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

/* Account line: "Cont: user@example.com" */
.account-line {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
}

.account-prefix {
  font-weight: 600;
  color: #374151;
}

.account-email {
  color: #374151;
}

.card p.subtitle {
  color: #6b7280;
  font-size: 14px;
  margin-bottom: 24px;
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  /* AA upgrade: #9ca3af is 3.06:1 against #fff — passes the 3:1 UI-control rule */
  border: 1.5px solid #9ca3af;
  border-radius: 8px;
  font-size: 14px;
  color: #111827;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #1a3c8f;
}

/* AA focus-visible upgrade: explicit outline for keyboard navigation */
.form-group input:focus-visible,
.btn-login:focus-visible {
  outline: 2px solid #1a3c8f;
  outline-offset: 2px;
}

/* TOTP code input — large monospace single field (D-165) */
.code-input {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border: 1.5px solid #9ca3af;
  border-radius: 8px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 28px;
  font-weight: 700;
  color: #111827;
  letter-spacing: 8px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.code-input:focus {
  border-color: #1a3c8f;
  outline: 2px solid #1a3c8f;
  outline-offset: 2px;
}

/* Countdown row */
.countdown {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 24px;
  font-size: 13px;
  color: #6b7280;
}

.countdown-ring {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  transform: rotate(-90deg);
}

.countdown-track {
  fill: none;
  stroke: #e5e7eb;
  stroke-width: 4;
}

.countdown-progress {
  fill: none;
  stroke: #1a3c8f;
  stroke-width: 4;
  stroke-linecap: round;
  /* circumference = 2 * π * 18 ≈ 113.1 */
  stroke-dasharray: 113.1;
  /* stroke-dashoffset updated each rAF tick */
  stroke-dashoffset: 0;
}

/* Inline error region — single role="alert" per form (D-170) */
[role="alert"] {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

[role="alert"][hidden] {
  display: none;
}

.btn-login {
  width: 100%;
  padding: 13px;
  min-height: 48px;
  background-color: #1a3c8f;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-login:hover {
  background-color: #142f72;
}

/* Disabled state during loading */
.btn-login:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

/* Loading spinner — 16x16 ring */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

/* The `hidden` attribute must win over the display rule above, or the spinner
   shows permanently (the markup ships it `hidden` and reveals it during fetch). */
.btn-spinner[hidden] {
  display: none !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* FOOTER — AA upgrade: #6b7280 is 5.04:1 against #f0f4ff background */
footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: #6b7280;
}

/* Mobile reductions */
@media (max-width: 767px) {
  .topbar {
    padding: 16px 20px;
  }

  .main {
    padding: 24px 16px;
  }

  .card {
    padding: 32px 24px;
  }
}

/* Reduce-motion: hide SVG ring; spinner stops; numeric tick via setInterval (D-168) */
@media (prefers-reduced-motion: reduce) {
  .countdown-ring {
    display: none;
  }
  .btn-spinner {
    animation: none;
    border-top-color: transparent;
  }
}

/* round-88 — the „Am uitat parola" line under the login form. */
.forgot-line { text-align: center; margin: 14px 0 0; font-size: 13px; }
.forgot-line a { color: #1a3c8f; text-decoration: none; font-weight: 600; }
.forgot-line a:hover { text-decoration: underline; }

/* round-99 — „Nu ai acces la aplicație?" toggle under the submit button.
   A link, not a second field: the recovery path is the rare one, and a visible
   second code box invites burning a single-use code needlessly. */
.link-button {
  display: block;
  margin: 14px auto 0;
  background: none;
  border: none;
  padding: 0;
  color: #1a3c8f;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.link-button:hover { color: #12285e; }
.link-button:focus-visible { outline: 2px solid #1a3c8f; outline-offset: 2px; border-radius: 2px; }
