:root {
  --auth-ink: #172033;
  --auth-muted: #5e687a;
  --auth-line: #cfd6e2;
  --auth-navy: #1e3a5f;
  --auth-navy-dark: #132a46;
  --auth-navy-soft: #eef3f9;
  --auth-admin: #5b4b8a;
  --auth-admin-soft: #f3f0fb;
}

html.fontscale-large { font-size: 118%; }

body.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 10% 0, rgba(30,58,95,.13), transparent 28rem),
    #f3f5f8;
  color: var(--auth-ink);
}

.auth-shell .page {
  width: 100%;
  flex: 1;
  display: flex;
  margin: 0;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           12px max(16px, env(safe-area-inset-left));
}

.auth-card {
  width: min(540px, 100%);
  margin: auto;
  border: 1px solid var(--auth-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(23,32,51,.1);
  padding: clamp(24px, 5vw, 34px);
}

.auth-heading { margin-bottom: 22px; }
.auth-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--auth-navy);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .16em;
}
.auth-heading h1 { margin: 0 0 7px; font-size: clamp(1.45rem, 4vw, 1.75rem); line-height: 1.25; }
.auth-heading p { margin: 0; color: var(--auth-muted); font-size: .9rem; line-height: 1.55; }

.auth-error {
  margin-bottom: 18px;
  border: 1px solid #ff9b95;
  border-radius: 10px;
  background: #ffebe9;
  color: #a40e26;
  padding: 12px 14px;
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.5;
}

.login-form { display: grid; gap: 20px; }
.role-picker { min-width: 0; margin: 0; border: 0; padding: 0; }
.role-picker > legend,
.password-label {
  display: block;
  margin-bottom: 9px;
  color: var(--auth-muted);
  font-size: .84rem;
  font-weight: 700;
}
.role-groups { display: grid; gap: 12px; }
.role-group {
  border: 1px solid var(--auth-line);
  border-radius: 12px;
  background: #fafbfc;
  padding: 12px;
}
.role-group-title { display: flex; align-items: center; gap: 8px; margin: 0 0 9px; font-size: .9rem; }
.role-group-mark {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--auth-navy-soft);
  color: var(--auth-navy-dark);
  font-weight: 800;
}
.role-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.role-choice { position: relative; display: block; cursor: pointer; }
.role-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.role-option {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 2px solid #d8dee8;
  border-radius: 10px;
  background: #fff;
  padding: 9px 12px;
  text-align: center;
  transition: border-color .12s, background-color .12s, box-shadow .12s, transform .12s;
}
.role-option-title { font-size: 1.02rem; font-weight: 800; }
.role-option-desc { color: var(--auth-muted); font-size: .72rem; line-height: 1.35; }
.role-choice:hover .role-option { border-color: #9dafc5; transform: translateY(-1px); }
.role-radio:checked + .role-option {
  border-color: var(--auth-navy);
  background: var(--auth-navy-soft);
  box-shadow: 0 0 0 2px rgba(30,58,95,.12);
  color: var(--auth-navy-dark);
}
.role-radio:focus-visible + .role-option { outline: 3px solid rgba(30,58,95,.26); outline-offset: 2px; }

.admin-choice .role-option {
  min-height: 58px;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  border-color: #d6cee8;
  background: #fcfbff;
  text-align: left;
}
.admin-mark {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--auth-admin-soft);
  color: var(--auth-admin);
  font-weight: 800;
}
.admin-choice .role-radio:checked + .role-option {
  border-color: var(--auth-admin);
  background: var(--auth-admin-soft);
  box-shadow: 0 0 0 2px rgba(91,75,138,.1);
  color: #493875;
}

.password-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.password-wrap input {
  min-width: 0;
  min-height: 50px;
  border: 1px solid var(--auth-line);
  border-radius: 10px 0 0 10px;
  padding: 11px 13px;
  color: var(--auth-ink);
  font-size: 1rem;
}
.password-wrap input:focus {
  position: relative;
  z-index: 1;
  outline: 3px solid rgba(30,58,95,.18);
  border-color: var(--auth-navy);
}
.password-toggle {
  min-width: 66px;
  min-height: 50px;
  margin-left: -1px;
  border: 1px solid var(--auth-line);
  border-radius: 0 10px 10px 0;
  background: #f1f3f6;
  color: #354157;
  padding: 8px 12px;
  font-size: .86rem;
  font-weight: 700;
}
.password-toggle:hover { background: #e5e9ef; }
.login-submit {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 10px;
  background: var(--auth-navy);
  color: #fff;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 800;
}
.login-submit:hover { background: var(--auth-navy-dark); }
.login-submit:focus-visible,
.password-toggle:focus-visible { outline: 3px solid rgba(30,58,95,.26); outline-offset: 2px; }

.login-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
  color: var(--auth-muted);
  font-size: .75rem;
}
.login-tools button {
  min-width: 50px;
  min-height: 40px;
  border: 1px solid var(--auth-line);
  border-radius: 6px;
  background: #fff;
  color: var(--auth-ink);
  padding: 5px 10px;
  font-size: .8125rem;
}
.login-tools button.active { border-color: var(--auth-navy); background: var(--auth-navy); color: #fff; }
.auth-shell .site-footer { padding: 0 18px max(14px, env(safe-area-inset-bottom)); color: #737e90; }

@media (orientation: landscape) and (min-width: 600px) and (max-height: 720px) {
  .auth-shell .page { padding-block: 10px 5px; }
  .auth-card { width: min(760px, 100%); border-radius: 14px; padding: 15px 22px 12px; }
  .auth-heading { margin-bottom: 9px; }
  .auth-kicker,
  .auth-heading p { display: none; }
  .auth-heading h1 { margin: 0; font-size: 1.35rem; }
  .auth-error { margin-bottom: 9px; padding: 8px 12px; }
  .login-form { gap: 9px; }
  .role-picker > legend,
  .password-label { margin-bottom: 5px; }
  .role-groups { grid-template-columns: minmax(0, 1fr) minmax(150px, .45fr); align-items: stretch; gap: 8px; }
  .role-group { padding: 8px; }
  .role-group-title { margin-bottom: 6px; }
  .role-options { gap: 6px; }
  .role-option { min-height: 54px; padding: 6px 8px; }
  .admin-choice .role-option {
    height: 100%;
    min-height: 0;
    grid-template-columns: 1fr;
    align-content: center;
    justify-items: center;
    gap: 3px;
    text-align: center;
  }
  .admin-choice .admin-mark { grid-row: auto; }
  .password-wrap input,
  .password-toggle { min-height: 46px; }
  .login-submit { min-height: 46px; padding-block: 9px; }
  .login-tools { margin-top: 7px; }
  .login-tools button { min-height: 34px; }
  .auth-shell .site-footer { padding-bottom: 7px; }
}

@media (max-width: 460px) {
  .auth-shell .page { padding-inline: 10px; }
  .auth-card { border-radius: 13px; padding: 22px 18px; }
  .role-option { padding-inline: 8px; }
  .role-option-desc { font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
  .role-option { transition: none; }
}
