/* Login page: shared tokens, form controls, feedback, responsive layout. */
:root {
  color-scheme: light;
  --background: #f9fafb;
  --surface: #fff;
  --text: #161616;
  --text-muted: #384250;
  --primary: #1b8354;
  --primary-hover: #166a45;
  --primary-dark: #14573a;
  --border: #d2d6db;
  --subtle: #f3f4f6;
  --success-surface: #ecfdf3;
  --error: #b42318;
  --error-surface: #fef3f2;
  --focus: #161616;
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--background);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary-dark); text-underline-offset: 4px; }
a:hover { color: var(--primary-hover); }
img { display: block; max-width: 100%; }
button, a, input { -webkit-tap-highlight-color: transparent; }
::selection { background: var(--success-surface); color: var(--primary-dark); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.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; }
.hidden { display: none !important; }
.skip-link { position: fixed; top: 12px; right: 12px; z-index: 1000; padding: 12px 16px; border-radius: var(--radius); background: var(--primary); color: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: none; }

.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 80px;
  padding: 16px max(24px, calc((100vw - 1200px) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.top-brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-size: 24px; font-weight: 700; text-decoration: none; }
.top-brand img { width: 48px; height: 48px; object-fit: contain; border-radius: 4px; }
.home-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 12px; border-radius: 4px; color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none; }
.home-link svg { width: 20px; height: 20px; flex: none; }
.home-link:hover { background: var(--subtle); color: var(--text); }

.login-layout { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; padding: 48px 24px; }
.auth-panel { width: 100%; max-width: 600px; padding: 40px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.auth-heading { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 32px; text-align: center; }
.form-eyebrow { color: var(--primary-dark); font-size: 14px; font-weight: 500; }
.login-title { margin: 0; color: var(--text); font-size: 32px; font-weight: 700; line-height: 1.4; }
.auth-heading p { margin: 0; color: var(--text-muted); font-size: 16px; line-height: 1.5; }

.auth-fields { display: flex; flex-direction: column; gap: 24px; margin-bottom: 24px; }
.input-group { position: relative; display: flex; flex-direction: column; gap: 8px; }
.floating-label { order: -1; display: flex; align-items: center; gap: 4px; color: var(--text); font-size: 16px; font-weight: 500; line-height: 24px; }
.required-mark { color: var(--error); }
.floating-input {
  width: 100%;
  height: 40px;
  min-width: 0;
  padding: 8px 12px 8px 48px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  text-align: right;
  caret-color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.floating-input:hover { border-color: var(--text-muted); }
.floating-input:focus { outline: none; border-color: var(--text); box-shadow: 0 2px 0 var(--text); }
.floating-input:-webkit-autofill, .floating-input:-webkit-autofill:hover, .floating-input:-webkit-autofill:focus { -webkit-text-fill-color: var(--text); -webkit-box-shadow: 0 0 0 1000px var(--surface) inset; caret-color: var(--text); }
.eye-toggle, .valid-check { position: absolute; inset-inline-end: 4px; top: 32px; display: grid; place-items: center; width: 36px; height: 40px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); }
.eye-toggle svg, .valid-check svg { width: 20px; height: 20px; }
.eye-toggle:hover { background: var(--subtle); color: var(--text); }
.valid-check { color: var(--primary); opacity: 0; pointer-events: none; }
.valid-check.show { opacity: 1; }
.floating-input.input-error, .input-error .floating-input { border-color: var(--error); box-shadow: 0 2px 0 var(--error); }
.caps-warn { display: none; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; }
.caps-warn.show { display: flex; }
.caps-warn svg { width: 16px; height: 16px; flex: none; }
.field-separator, .type-pill, .btn-shine, #bootGate { display: none !important; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; font-size: 14px; }
.remember { position: relative; display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); cursor: pointer; }
.remember input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.check-box { display: grid; place-items: center; width: 20px; height: 20px; flex: 0 0 20px; border: 1px solid var(--text-muted); border-radius: 4px; background: var(--surface); }
.check-box svg { width: 14px; height: 14px; color: var(--surface); opacity: 0; }
.remember input:checked ~ .check-box { border-color: var(--primary); background: var(--primary); }
.remember input:checked ~ .check-box svg { opacity: 1; }
.remember input:focus-visible ~ .check-box { outline: 2px solid var(--focus); outline-offset: 3px; }
.forgot-link { flex-shrink: 0; font-weight: 500; }

.btn-premium { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 40px; padding: 8px 16px; border: 1px solid transparent; border-radius: 4px; background: var(--primary); color: var(--surface); font-size: 16px; font-weight: 500; transition: background .15s ease; }
.btn-premium:hover { background: var(--primary-hover); }
.btn-premium:active { background: var(--primary-dark); }
.btn-premium:disabled { opacity: .65; cursor: wait; }
.submit-arrow { width: 20px; height: 20px; flex: none; }
.spinner { display: block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--surface); border-radius: 50%; animation: spin .7s linear infinite; }

.social-auth { margin-top: 24px; }
.divider { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; color: var(--text-muted); font-size: 14px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.social-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.app-icon-btn { display: flex; align-items: center; justify-content: center; width: 48px; height: 44px; padding: 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); transition: background .15s ease; }
.app-icon-btn:hover { background: var(--subtle); border-color: var(--text-muted); }
.app-icon-btn.telegram { color: var(--text-muted); }
.app-icon-glyph { display: block; width: 24px; height: 24px; }
.app-icon-btn.passkey.busy { pointer-events: none; opacity: .55; }
.register-prompt { margin: 24px 0 0; padding-top: 24px; border-top: 1px solid var(--border); color: var(--text-muted); text-align: center; font-size: 14px; }
.register-prompt a { font-weight: 500; }

.form-message { margin: 16px 0 0; padding: 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; line-height: 1.6; }
.success-message { border-color: var(--primary); background: var(--success-surface); color: var(--primary-dark); }
.error-message { border-color: var(--error); background: var(--error-surface); color: var(--error); }
.login-footer { padding: 16px 24px 24px; color: var(--text-muted); text-align: center; font-size: 12px; }
.login-footer p { margin: 0; }
.offline-bar, .online-bar { position: fixed; inset: 0 0 auto; z-index: 80; padding: 8px 16px; background: var(--error); color: var(--surface); text-align: center; font-size: 14px; transform: translateY(-110%); transition: transform .2s ease; }
.online-bar { background: var(--primary-dark); }
.offline-bar.show, .online-bar.show { transform: translateY(0); }
#progressBar { position: fixed; inset: 0 0 auto auto; z-index: 90; width: 0; height: 3px; background: var(--primary); transition: width .2s ease; }
#googleGsiHidden { position: fixed; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; clip-path: inset(50%); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .login-header { min-height: 72px; padding: 12px 16px; gap: 8px; }
  .top-brand { gap: 8px; font-size: 20px; }
  .top-brand img { width: 40px; height: 40px; }
  .home-link { padding: 8px; font-size: 12px; }
  .home-link svg { width: 16px; height: 16px; }
  .login-layout { align-items: flex-start; padding: 24px 16px; }
  .auth-panel { padding: 24px; }
  .auth-heading { margin-bottom: 24px; }
  .login-title { font-size: 28px; }
  .auth-heading p { font-size: 14px; }
  .row-between { font-size: 12px; gap: 8px; }
  .login-footer { padding: 0 16px 24px; }
}
@media (max-width: 360px) {
  .auth-panel { padding: 20px 16px; }
  .row-between { flex-wrap: wrap; gap: 12px; }
}
/* Page-scoped refinements preserve the shared field geometry and theme contracts. */
/* Inherit registration's shared light/dark palette rather than pinning login colors. */
.login-refined {
  --login-ease: cubic-bezier(.22, 1, .36, 1);
  width: 100%;
  min-width: 0;
}
/* Keep login's loading track full-width instead of moving a half-width overlay. */
html.login-page[data-platform-loading]::before {
  width: 100%;
  transform: none;
  background: linear-gradient(90deg, #14573a, #16a078, #14573a);
  background-size: 200% 100%;
  animation: login-loading-sweep 1s linear infinite;
}
@keyframes login-loading-sweep {
  from { background-position: 200% 0; }
  to { background-position: 0 0; }
}
.login-refined > :is(.login-header, .login-footer) {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  max-width: none;
}
html.code-design .login-refined .login-header {
  min-height: 72px;
  background: var(--code-canvas);
  border-bottom-color: color-mix(in srgb, var(--code-border) 55%, transparent);
}
.login-refined .login-layout {
  align-items: flex-start;
  flex: 1 0 auto;
  min-width: 0;
  padding: 56px 24px 32px;
  background: var(--code-canvas);
}
html.code-design .login-refined .auth-panel {
  flex: 0 1 620px;
  max-width: 620px;
  min-width: 0;
  padding: 40px;
  border-radius: 24px;
  border: 1px solid var(--code-border);
  box-shadow: 0 24px 64px rgb(0 0 0 / 7%);
  animation: login-arrive 650ms var(--login-ease) both;
}
.login-refined .auth-heading { gap: 12px; margin-bottom: 32px; }
.login-refined :is(.forgot-link, .register-prompt a, .login-legal a)::before,
.login-refined :is(.forgot-link, .register-prompt a, .login-legal a)::after { content: none !important; display: none !important; }
.login-refined :is(.forgot-link, .register-prompt a, .login-legal a) svg,
.login-refined label[for="password"] svg { display: none !important; }
.login-refined .eye-toggle { color: var(--code-muted); border-radius: 50%; }
/* Touch browsers retain hover after tapping; the eye must not leave a filled tile. */
.login-refined .eye-toggle:is(:hover, :active) { background: transparent; color: var(--code-text); }
.login-refined .eye-toggle:focus-visible { outline: 2px solid var(--code-link); outline-offset: -4px; }
.login-refined .login-title { font-size: 34px; font-weight: 600; line-height: 1.4; letter-spacing: -.7px; }
.login-refined .auth-heading p { font-size: 14px; line-height: 1.9; }
.login-refined .auth-fields { gap: 24px; margin-bottom: 24px; }
/* LTR inputs live in RTL wrappers: reserve the physical left, where the toggle/check sits. */
html.code-design .login-refined #loginForm .code-floating-field > .floating-input {
  padding: 12px 14px 12px 54px !important;
  text-align: right;
}
html.code-design .login-refined .auth-panel { background: var(--code-surface); }
html.code-design .login-refined #loginForm .floating-input {
  --control-height: 52px;
  background-color: var(--code-surface) !important;
}
html.code-design .login-refined #loginForm .code-floating-field > .eye-toggle { top: 34px !important; }
.login-refined .row-between { margin-bottom: 24px; font-size: 12px; }
.login-refined .remember { min-height: 32px; }
.login-refined .forgot-link { text-decoration: none; }
.login-refined .forgot-link:hover { text-decoration: underline; }
html.code-design .login-refined .btn-premium {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 52px;
  border-radius: 12px !important;
  font-size: 15px;
  font-weight: 600;
  box-shadow: none;
  transition: background 180ms ease, box-shadow 200ms ease, translate 200ms var(--login-ease);
}
.login-refined .btn-premium::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 25%, rgb(255 255 255 / 12%) 50%, transparent 75%);
  transform: translateX(110%);
  transition: transform 650ms var(--login-ease);
}
.login-refined .submit-arrow { transition: translate 220ms var(--login-ease); }
.login-refined .btn-premium:active:not(:disabled) { translate: 0 1px; }
.login-refined .social-auth { margin-top: 28px; }
.login-refined .divider { gap: 16px; font-size: 12px; margin-bottom: 18px; }
.login-refined .social-row { gap: 12px; }
.login-refined .app-icon-btn {
  width: 64px;
  height: 48px;
  border-radius: 12px;
  transition: translate 200ms var(--login-ease), border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.login-refined .app-icon-btn:active { translate: 0 1px; }
.login-refined .register-prompt {
  margin: 28px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
}
.login-refined .register-prompt a { font-weight: 700; text-decoration: none; }
.login-refined .register-prompt a:hover { text-decoration: underline; }
.login-refined .form-message { position: relative; margin-top: 20px; border-radius: 12px; }
html.code-design .login-refined .login-footer {
  padding: 24px;
  background: #14573a;
  color: #ffffff;
  font-size: 11px;
}
.login-refined .login-footer-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  text-align: right;
}
.login-refined .login-footer-about { display: flex; align-items: center; gap: 24px; flex: 1 1 100%; min-width: 0; }
.login-refined .login-footer-copy { flex: 1; min-width: 0; }
.login-refined .login-footer-social { display: flex; flex-wrap: wrap; align-items: center; flex-shrink: 0; gap: 16px; }
.login-refined .login-footer-social a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: #fff; font-size: 12px; font-weight: 500; text-decoration: none; }
.login-refined .login-footer-social a:hover span { text-decoration: underline; text-underline-offset: 4px; }
.login-refined .login-footer-social a:focus-visible { outline: 2px solid #fff; outline-offset: 4px; border-radius: 4px; }
.login-refined .login-footer-social img { display: block; width: 18px; height: 18px; filter: brightness(0) invert(1); }
@media (max-width: 600px) {
  .login-refined .login-footer-about { flex-wrap: wrap; gap: 8px; }
  .login-refined .login-footer-copy { flex-basis: 100%; }
  .login-refined .login-footer-social { justify-content: center; width: 100%; }
}
.login-refined .login-footer-description { margin: 8px 0 0; font-size: 13px; line-height: 1.8; }
.login-refined .login-footer-copyright { margin: 0; font-size: 11px; }
.login-refined .login-footer-brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 20px; font-weight: 500; }
.login-refined .login-footer-brand img { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; border: 1px solid rgb(255 255 255 / 20%); }
.login-refined .login-legal { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px 24px; }
.login-refined .login-legal a { display: inline-flex; align-items: center; min-height: 32px; color: #fff; font-size: 13px; text-decoration: none; }
.login-refined .login-legal a:hover { text-decoration: underline; }
.login-refined .login-footer p { color: #d1e6da; }
@media (min-width: 900px) {
  .login-refined .login-footer-inner { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
}
.login-refined .animate-fade-up:not(.auth-panel) { animation: login-arrive 550ms var(--login-ease) both; }
.login-refined .stagger-2 { animation-delay: 70ms !important; }
.login-refined .stagger-3 { animation-delay: 120ms !important; }
.login-refined .stagger-4 { animation-delay: 170ms !important; }
.login-refined .stagger-5 { animation-delay: 220ms !important; }
.login-refined .stagger-6 { animation-delay: 270ms !important; }
.login-refined .msg-pop { animation: login-arrive 220ms var(--login-ease) both; }
@keyframes login-arrive {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (hover: hover) and (pointer: fine) {
  .login-refined .btn-premium:hover:not(:disabled) { translate: 0 -2px; box-shadow: 0 8px 20px rgb(27 131 84 / 20%); }
  .login-refined .btn-premium:hover:not(:disabled)::before { transform: translateX(-110%); }
  .login-refined .btn-premium:hover:not(:disabled) .submit-arrow { translate: -3px 0; }
  .login-refined .app-icon-btn:hover { translate: 0 -3px; border-color: var(--code-link); box-shadow: 0 4px 12px rgb(0 0 0 / 6%); }
}
@media (max-width: 600px) {
  html.code-design .login-refined .login-header { min-height: 64px; background: var(--code-surface); }
  .login-refined .login-layout {
    flex: 0 0 auto;
    min-height: 0;
    padding: 0;
  }
  html.code-design .login-refined .auth-panel {
    padding: 32px 24px 24px;
    border: 0;
    border-radius: 0;
    background: var(--code-canvas);
    box-shadow: none;
  }
  html.code-design .login-refined .login-footer { padding: 16px; }
  .login-refined .login-footer-inner { gap: 12px; text-align: center; }
  .login-refined .login-legal { justify-content: center; padding-top: 12px; border-top: 1px solid rgb(255 255 255 / 14%); }
  .login-refined .login-footer-copyright { font-size: 10px; }
  .login-refined .login-footer-brand { font-size: 18px; }
  .login-refined .login-footer-brand img { width: 32px; height: 32px; }
  .login-refined .login-footer-description { font-size: 12px; line-height: 1.6; }
  .login-refined .login-legal { column-gap: 16px; }
  .login-refined .login-legal a { font-size: 12px; }
  .login-refined .auth-heading { gap: 12px; margin-bottom: 28px; }
  .login-refined .login-title { font-size: 30px; }
  .login-refined .auth-heading p { font-size: 13px; }
  .login-refined .auth-fields { gap: 22px; }
  .login-refined .register-prompt { margin: 24px 0 0; padding: 0; border-radius: 0; }
  .login-refined .social-auth { margin-top: 24px; }
  .login-refined .row-between { gap: 8px; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html.login-page[data-platform-loading]::before { animation: none; background: #16a078; }
}
