:root {
  --primary:       #0F4C81;
  --primary-light: #2E628F;
  --primary-dark:  #003D73;
  --error:         #9C2822;
  --success:       #229C6B;
  --warning:       #A8922D;

  --surface:       #FFFFFF;
  --on-surface:    rgba(0,0,0,.87);
  --on-surface-2:  rgba(0,0,0,.60);
  --on-surface-3:  rgba(0,0,0,.38);
  --outline:       rgba(0,0,0,.23);
  --outline-soft:  rgba(0,0,0,.12);

  --radius:        5px;
  --shadow-2:      0 2px 4px -1px rgba(0,0,0,.10), 0 4px 5px rgba(0,0,0,.07), 0 1px 10px rgba(0,0,0,.06);
  --shadow-elev:   0 11px 15px -7px rgba(0,0,0,.18), 0 24px 38px 3px rgba(0,0,0,.12), 0 9px 46px 8px rgba(0,0,0,.10);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: Roboto, "Open Sans", Helvetica, "Segoe UI", Arial, sans-serif;
  font-weight: 450;
  letter-spacing: .01091em;
  color: var(--on-surface);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, var(--primary-light) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Language bar */
.lang-bar {
  position: fixed;
  top: 20px;
  right: 24px;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
  border: 1px solid var(--outline-soft);
  z-index: 100;
}
.lang-bar a {
  font: 500 12px Roboto, sans-serif;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  color: var(--on-surface-2);
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.lang-bar a.active { background: var(--primary); color: #fff; }
.lang-bar a:not(.active):hover { background: rgba(0,0,0,.04); color: var(--on-surface); }

/* Shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

/* Card */
.form-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 56px 40px;
  box-shadow: var(--shadow-elev);
}
body[data-page="reset-success"] .form-card,
body[data-page="email-sent"] .form-card { text-align: center; }

/* Brand */
.centered-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.centered-brand .logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-2);
}
.centered-brand .logo .material-symbols-outlined { font-size: 32px; }
.centered-brand .name {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--on-surface);
}

/* Back link inside card (forgot password) */
.card-back {
  display: inline-flex; align-items: center;
  gap: 4px;
  color: var(--on-surface-2);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  padding: 6px 10px 6px 6px;
  margin: -4px 0 14px -6px;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}
.card-back:hover { background: rgba(0,0,0,.04); color: var(--on-surface); }
.card-back .material-symbols-outlined { font-size: 18px; }

/* Form header */
.eyebrow {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 12px;
}
.form-card h2 {
  font-size: 28px;
  font-weight: 400;
  margin: 0 0 8px;
  letter-spacing: -0.2px;
}
.form-card .sub {
  color: var(--on-surface-2);
  font-size: 14px;
  margin: 0 0 32px;
  line-height: 1.55;
}
body[data-page="reset-success"] .form-card .sub,
body[data-page="email-sent"] .form-card .sub {
  margin: 0 auto 24px;
  max-width: 380px;
}
.form-card .sub-tip {
  color: var(--on-surface-2);
  font-size: 13px;
  margin: 0 auto 4px;
  max-width: 400px;
  line-height: 1.55;
}

/* Error / warning alert */
.alert {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(156,40,34,.08);
  color: var(--error);
  border-left: 3px solid var(--error);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.45;
  margin: 0 0 16px;
}
.alert .material-symbols-outlined { font-size: 20px; flex-shrink: 0; }
.alert ul { margin: 0; padding: 0; list-style: none; }
.alert[hidden] { display: none; }
.alert--warning {
  background: rgba(168,146,45,.08);
  color: var(--warning);
  border-left-color: var(--warning);
}

/* MudTextField clone (outlined) */
.mud-field { position: relative; margin-top: 18px; }

.mud-field .wrap {
  position: relative;
  display: flex;
  align-items: center;
  height: 56px;
  border-radius: var(--radius);
  border: 1px solid var(--outline);
  background: var(--surface);
  transition: border-color .15s;
}
.mud-field .wrap:hover { border-color: var(--on-surface); }
.mud-field:focus-within .wrap { border-color: var(--primary); }
.mud-field.has-error .wrap { border-color: var(--error); }

/* Inner reinforcement ring — drawn as a pseudo-element instead of an inset box-shadow
   on the wrap. Chrome's :-webkit-autofill paints a 1000px-spread white inset box-shadow
   on the input itself (to mask the yellow autofill background), and because the input
   is a child of .wrap, that shadow paints ABOVE the wrap's own inset shadow — so an
   inset-shadow ring would be visible at the lead/trail/label regions but masked behind
   the input, looking like the focus border has uneven thickness. ::after paints after
   children in tree order, and z-index: 1 keeps it above the input's autofill paint so
   the ring stays a uniform 1px on all four sides. inset: 0 sits it at the padding-box
   edge (1px inside the wrap's outer border), and the radius is the outer radius minus
   1px to stay concentric on rounded corners. */
.mud-field .wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 1px);
  z-index: 1;
  transition: border-color .15s;
}
.mud-field:focus-within .wrap::after { border-color: var(--primary); }
.mud-field.has-error .wrap::after { border-color: var(--error); }

.mud-field .lead {
  display: grid;
  place-items: center;
  width: 48px;
  color: var(--on-surface-2);
  flex-shrink: 0;
}
.mud-field .lead .material-symbols-outlined { font-size: 22px; }
.mud-field:focus-within .lead { color: var(--primary); }
.mud-field.has-error .lead { color: var(--error); }

.mud-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  height: 100%;
  outline: none;
  font-family: Roboto, "Open Sans", Helvetica, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  font-weight: 450;
  letter-spacing: .01091em;
  line-height: 1.4;
  color: var(--on-surface);
  padding: 0 14px 0 0;
}

.mud-field input:-webkit-autofill,
.mud-field input:-webkit-autofill:hover,
.mud-field input:-webkit-autofill:focus,
.mud-field input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
  box-shadow:         0 0 0 1000px var(--surface) inset !important;
  -webkit-text-fill-color: var(--on-surface) !important;
  caret-color: var(--on-surface);
  transition: background-color 9999s ease-in-out 0s;
}

/* Float label: pure CSS — input carries placeholder=" " so :not(:placeholder-shown)
   triggers the floated state when the user types, autofill fills, or the input is
   pre-populated server-side. :focus-within on .wrap floats on focus. */
.mud-field label {
  position: absolute;
  pointer-events: none;
  left: 48px;
  top: 50%;
  transform: translateY(-50%);
  /* Sits above the .wrap::after reinforcement ring (z-index: 1) so the label's white
     background masks both the outer border and the inner ring at the floated position —
     creating the Material Design "label cuts a notch in the border" effect. */
  z-index: 2;
  color: var(--on-surface-2);
  font-size: 16px;
  background: var(--surface);
  padding: 0 4px;
  transition: top .15s, transform .15s, font-size .15s, color .15s, left .15s;
}
.mud-field:focus-within label,
.mud-field input:not(:placeholder-shown) + label {
  top: 0;
  transform: translateY(-50%);
  font-size: 12px;
  left: 44px;
}
.mud-field:focus-within label { color: var(--primary); }
.mud-field.has-error label { color: var(--error); }

.mud-field .trail {
  display: grid;
  place-items: center;
  padding-right: 6px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--on-surface-2);
  display: grid;
  place-items: center;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(0,0,0,.04); }
.icon-btn .material-symbols-outlined { font-size: 22px; }

.mud-field .helper {
  font-size: 12px;
  color: var(--on-surface-2);
  padding: 4px 14px 0;
  min-height: 18px;
  line-height: 1.4;
}
.mud-field.has-error .helper { color: var(--error); }

/* Row: remember me + forgot */
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 24px;
  min-height: 36px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--on-surface);
  font-size: 14px;
  user-select: none;
}
.checkbox input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.checkbox .box {
  width: 18px;
  height: 18px;
  border: 2px solid var(--on-surface-2);
  border-radius: 3px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.checkbox .box .material-symbols-outlined {
  font-size: 16px;
  color: #fff;
  opacity: 0;
  transition: opacity .12s;
}
.checkbox input[type="checkbox"]:checked + .box { background: var(--primary); border-color: var(--primary); }
.checkbox input[type="checkbox"]:checked + .box .material-symbols-outlined { opacity: 1; }
.checkbox:hover .box { border-color: var(--on-surface); }

/* Link (text-style) — used as anchor and as button */
.link {
  color: var(--primary);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background .15s;
  display: inline-flex;
  align-items: center;
  font-family: inherit;
}
.link:hover { background: rgba(15,76,129,.06); text-decoration: underline; }
.link:disabled { color: var(--on-surface-3); cursor: not-allowed; }
.link:disabled:hover { background: transparent; text-decoration: none; }

/* Primary action button */
.btn {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: var(--radius);
  font: 500 14px/1 Roboto, system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .15s, box-shadow .15s, transform .05s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}
.btn-primary:hover { background: var(--primary-light); box-shadow: var(--shadow-2); }
.btn-primary:disabled {
  background: rgba(0,0,0,.12);
  color: rgba(0,0,0,.38);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.btn .btn-icon { font-size: 20px; }

/* Top margin variant for buttons that follow input groups */
body[data-page="reset-password"] .btn,
body[data-page="forgot-password"] .btn { margin-top: 8px; }
body[data-page="email-sent"] .btn { margin-top: 24px; }

/* Spinner */
.spin {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Password strength meter (reset-password) */
.pw-strength { margin: 4px 0 8px; }
.pw-strength .bars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.pw-strength .bar {
  height: 4px;
  border-radius: 2px;
  background: var(--outline-soft);
  transition: background .2s;
}
.pw-strength[data-score="1"] .bar:nth-child(-n+1),
.pw-strength[data-score="2"] .bar:nth-child(-n+2),
.pw-strength[data-score="3"] .bar:nth-child(-n+3) { background: currentColor; }
.pw-strength[data-score="1"] { color: var(--error); }
.pw-strength[data-score="2"] { color: var(--warning); }
.pw-strength[data-score="3"] { color: var(--success); }
.pw-strength .label {
  display: flex; justify-content: space-between;
  font-size: 12px;
  color: var(--on-surface-2);
}
.pw-strength .label strong { font-weight: 500; color: currentColor; }

/* Requirements checklist (reset-password) */
.pw-req {
  list-style: none;
  padding: 0;
  margin: 8px 0 20px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.pw-req li {
  display: flex; gap: 6px; align-items: center;
  font-size: 12.5px;
  color: var(--on-surface-2);
  transition: color .15s;
}
.pw-req li .material-symbols-outlined {
  font-size: 16px;
  color: var(--on-surface-3);
  transition: color .15s;
}
.pw-req li.met { color: var(--success); }
.pw-req li.met .material-symbols-outlined { color: var(--success); }

/* Secondary text button (reset-password "Back to sign in") */
.btn-secondary-text {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  margin: 16px auto 0;
  font-size: 13.5px;
  color: var(--on-surface-2);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: transparent; border: 0;
  cursor: pointer;
  width: fit-content;
}
.btn-secondary-text:hover { background: rgba(0,0,0,.04); color: var(--on-surface); }
.btn-secondary-text .material-symbols-outlined { font-size: 18px; }

.secondary-row {
  display: flex; justify-content: center;
  margin-top: 4px;
}

/* Icon halo (success / info circle on confirmation pages) */
.icon-halo {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: grid; place-items: center;
  margin: 4px auto 18px;
}
.icon-halo .material-symbols-outlined { font-size: 36px; }
body[data-page="reset-success"] .icon-halo {
  background: rgba(34,156,107,.12);
  color: var(--success);
}
body[data-page="email-sent"] .icon-halo {
  background: rgba(15,76,129,.10);
  color: var(--primary);
}

/* Email pill (email-sent) */
.email-pill {
  display: inline-flex; align-items: center;
  gap: 8px;
  background: rgba(15,76,129,.06);
  color: var(--primary);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px; font-weight: 500;
  margin: 0 0 24px;
}
.email-pill .material-symbols-outlined { font-size: 18px; }

/* Resend row (email-sent) */
.resend-row {
  display: flex; justify-content: center; align-items: center;
  gap: 6px;
  margin: 16px 0 0;
  font-size: 13.5px;
  color: var(--on-surface-2);
}
.resend-row .countdown { font-variant-numeric: tabular-nums; }

@media (max-width: 600px) {
  .form-card { padding: 36px 28px 32px; }
}
