/* =====================================================================
   FinPal — Auth / "Bright Pocket", MOBILE ONLY

   Neo-bank onboarding: pastel wash, a stack of coloured wallet cards, and
   one white sheet that floats over the bottom of the screen. One CTA, one
   switch link, no bars.

   Wireframe (390 x 844)
   +----------------------------------+
   | [F] FinPal                      |  brand row
   | Tien cua gia dinh,              |  2-line proposition
   | ro trong mot cho.               |
   |                    [cards]      |  mint / butter / coral stack
   +----------------------------------+
     +------------------------------+  sheet floats, radius 28
     | Dang nhap                    |
     | Vi, giao dich...             |
     | Email                        |
     | [ name@email.com           ] |
     | Mat khau              [eye]  |
     | [ ................         ] |
     | [ ] Ghi nho    Quen?         |
     | [       Dang nhap          ] |  ONE coral CTA
     | Chua co tai khoan? Dang ky   |
     | (c) 2026 FinPal              |
     +------------------------------+

   Depth: one shadow on the sheet, one on the front card.
   Spacing: 4px base. One accent: coral (CTA, mark, focus, links).
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Tokens & reset
   --------------------------------------------------------------------- */
.auth-page {
  --wash-1: #EAF7F0;
  --wash-2: #FFF4E9;
  --wash-3: #FFE7DE;
  --sheet: #FFFFFF;
  --ink: #10231F;
  --ink-2: #3A4A45;
  --muted: #5C6B66;
  --line: #E2E9E5;
  --field: #F3F6F5;
  /* 3:1 on white — the field's boundary is the control's only edge. */
  --field-border: #7F908A;
  --accent: #FF5A3C;
  --accent-deep: #D63B22; /* 4.66:1 with white, so the CTA can carry text */
  --accent-ink: #B93815;
  --accent-soft: #FFF0EB;
  --mint: #CFF3E3;
  --butter: #FFE9A8;
  --danger: #B42318;
  --danger-soft: #FEF3F2;
  --success: #067647;
  --success-soft: #ECFDF3;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --font-ui: 'Be Vietnam Pro', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --gutter: 20px;

  color-scheme: light;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(165deg, var(--wash-1) 0%, var(--wash-2) 58%, var(--wash-3) 100%);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
}

.auth-page *,
.auth-page *::before,
.auth-page *::after {
  box-sizing: border-box;
}

.auth-page button,
.auth-page input {
  font: inherit;
}

.auth-page a {
  color: var(--accent-ink);
}

.auth-page :focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Phone-width column, even on a large window. */
.auth-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}

.auth-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.auth-skip:focus {
  left: var(--gutter);
  top: 10px;
}

/* ---------------------------------------------------------------------
   2. Masthead — brand, proposition, card stack
   --------------------------------------------------------------------- */
.auth-hero {
  position: relative;
  flex: 0 0 auto;
  padding: 18px var(--gutter) 158px;
}

.auth-hero__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  padding-bottom: 2px;
  box-shadow: 0 6px 14px -8px rgba(16, 35, 31, .5);
}

.auth-wordmark {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.035em;
  color: var(--ink);
}

.auth-hero__line {
  max-width: 15ch;
  margin: 16px 0 0;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -.035em;
  color: var(--ink);
  text-wrap: balance;
}

/* Long forms (registration) get a compact masthead: brand + one line, no
   decorative stack, so the CTA stays above the fold. */
.auth-hero.auth-hero--compact {
  padding-bottom: 34px;
}

.auth-hero--compact .auth-hero__line {
  max-width: 24ch;
  margin-top: 12px;
  font-size: 19px;
  line-height: 1.35;
}

/* Decorative wallet stack. No numbers, no chip, no fake data. */
.auth-cards {
  position: absolute;
  right: 22px;
  bottom: 28px; /* sits exactly on the sheet's top edge, never sliced */
  width: 202px;
  height: 114px;
  pointer-events: none;
}

.auth-card {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  transform-origin: 50% 100%;
}

.auth-card--back {
  background: var(--butter);
  transform: rotate(8deg) translate(6px, -4px);
}

.auth-card--mid {
  background: var(--mint);
  transform: rotate(4deg) translate(3px, -2px);
}

.auth-card--front {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--accent);
  /* Ink on coral is 5.29:1; white would only reach 3.1:1. */
  color: var(--ink);
  box-shadow: 0 16px 30px -18px rgba(16, 35, 31, .55);
}

.auth-card__brand {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.auth-card__name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .92;
}

.auth-card__dot {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 22px;
  height: 22px;
  border: 1.5px solid rgba(16, 35, 31, .38);
  border-radius: 50%;
}

/* ---------------------------------------------------------------------
   3. Sheet
   --------------------------------------------------------------------- */
.auth-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: -28px 16px 0;
  padding: 22px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  border-radius: 28px 28px 0 0;
  background: var(--sheet);
  box-shadow: 0 -18px 44px -30px rgba(16, 35, 31, .55);
}

.auth-head {
  margin-bottom: 20px;
}

.auth-title {
  margin: 0 0 6px;
  font-size: clamp(26px, 7.6vw, 30px);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -.035em;
  color: var(--ink);
  text-wrap: balance;
}

.auth-subtitle {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted);
  text-wrap: pretty;
}

/* ---------------------------------------------------------------------
   4. Fields
   --------------------------------------------------------------------- */
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.55;
}

.auth-alert.success {
  background: var(--success-soft);
  color: var(--success);
}

.auth-alert svg {
  flex: 0 0 16px;
  margin-top: 2px;
}

.auth-alert a {
  color: inherit;
  font-weight: 700;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin: 0;
  min-width: 0;
}

.auth-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.auth-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.auth-input {
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--field-border);
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 500;
  letter-spacing: -.01em;
  outline: none;
  transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease);
}

.auth-input-wrap--toggle .auth-input {
  padding-right: 52px;
}

.auth-input::placeholder {
  color: var(--muted);
  font-weight: 400;
  opacity: 1;
}

.auth-input:focus {
  background: var(--sheet);
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.auth-input:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 3px;
}

.auth-input.is-invalid,
.auth-input.is-invalid:focus {
  border-color: var(--danger);
  background: var(--danger-soft);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent);
}

.auth-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .16s var(--ease), background .16s var(--ease);
}

.auth-toggle:hover {
  color: var(--ink);
  background: rgba(16, 35, 31, .05);
}

.auth-toggle[aria-pressed="true"] {
  color: var(--accent-ink);
}

.auth-toggle__on { display: none; }
.auth-toggle[aria-pressed="true"] .auth-toggle__on { display: block; }
.auth-toggle[aria-pressed="true"] .auth-toggle__off { display: none; }

.auth-hint,
.auth-error {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}

.auth-hint { color: var(--muted); }
.auth-error { color: var(--danger); font-weight: 600; }

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: -2px;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  cursor: pointer;
}

.auth-check input {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  margin: 0;
  border: 1.5px solid var(--field-border);
  border-radius: 7px;
  background: var(--sheet);
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}

.auth-check input::after {
  content: "";
  width: 11px;
  height: 6px;
  margin-top: -2px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  transition: transform .16s var(--ease);
}

.auth-check input:checked {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.auth-check input:checked::after {
  transform: rotate(-45deg) scale(1);
}

.auth-check input:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 3px;
}

.auth-link,
.auth-inline-btn {
  color: var(--accent-ink);
  font-weight: 600;
  font-size: inherit;
  text-decoration: none;
  text-underline-offset: 3px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.auth-link:hover,
.auth-inline-btn:hover {
  text-decoration: underline;
}

.auth-inline-btn {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* ---------------------------------------------------------------------
   5. One coral CTA
   --------------------------------------------------------------------- */
.auth-submit {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: var(--accent-deep);
  color: #fff;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform .14s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
}

.auth-submit:hover {
  background: #C0331C;
}

.auth-submit:active {
  transform: scale(.985);
}

.auth-submit svg {
  transition: transform .18s var(--ease);
}

.auth-submit:hover svg {
  transform: translateX(3px);
}

.auth-submit.is-submitting {
  color: transparent;
  cursor: progress;
  transform: none;
}

.auth-submit.is-submitting svg { opacity: 0; }

.auth-submit.is-submitting::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin .68s linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------
   6. Notes, meters, switch link, dialog
   --------------------------------------------------------------------- */
.auth-meter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.auth-meter > span {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background .2s var(--ease);
}

.auth-meter[data-level="1"] > span:nth-child(1) { background: var(--danger); }
.auth-meter[data-level="2"] > span:nth-child(-n+2) { background: var(--accent); }
.auth-meter[data-level="3"] > span { background: var(--success); }
.auth-meter[data-level="0"] { opacity: .7; }

.auth-meter-text {
  min-height: 18px;
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.auth-meter-text.is-ok { color: var(--success); }
.auth-meter-text.is-bad { color: var(--danger); }

.auth-meter-text--match {
  min-height: 0;
}

.auth-note {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.6;
}

.auth-note strong {
  color: var(--ink);
  font-weight: 700;
}

.auth-note ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.auth-terms__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 4px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

.auth-terms .auth-check {
  min-height: 44px;
  margin-right: 0;
}

.auth-terms .auth-error[hidden] { display: none; }

/* One switch link, never a second button. */
.auth-secondary {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.auth-secondary p {
  margin: 0;
}

.auth-secondary__extra {
  width: 100%;
  padding-top: 2px;
  text-align: center;
}

.auth-submit--link {
  margin-top: 0;
}

.auth-legal {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 22px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.auth-legal__sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #B6C2BD;
}

.auth-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 30px 80px -30px rgba(16, 35, 31, .55);
  overscroll-behavior: contain;
}

.auth-dialog::backdrop {
  background: rgba(16, 35, 31, .42);
  backdrop-filter: blur(2px);
}

.auth-dialog-body {
  padding: 24px;
}

.auth-dialog h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.025em;
}

.auth-dialog p,
.auth-dialog li {
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.7;
}

.auth-dialog ul {
  padding-left: 18px;
}

.auth-dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.auth-dialog-close {
  min-height: 44px;
  padding: 0 4px;
  font-size: 14px;
  background: transparent;
  border: 0;
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
}

.auth-dialog-close:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------------------------------------------------------------------
   7. Motion & small-screen tuning
   --------------------------------------------------------------------- */
@keyframes auth-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(14px) rotate(0deg); }
}

@keyframes auth-sheet-in {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-hero__brand,
.auth-hero__line {
  animation: auth-rise .42s var(--ease) both;
}

.auth-hero__brand { animation-delay: .02s; }
.auth-hero__line { animation-delay: .08s; }

.auth-card--back { animation: auth-card-in .5s var(--ease) both .12s; }
.auth-card--mid { animation: auth-card-in .5s var(--ease) both .17s; }
.auth-card--front { animation: auth-card-in .5s var(--ease) both .22s; }

.auth-main {
  animation: auth-sheet-in .5s var(--ease) both .06s;
}

.auth-head > *,
.auth-form > *,
.auth-secondary,
.auth-note {
  animation: auth-rise .4s var(--ease) both;
}

.auth-head > *:nth-child(1) { animation-delay: .18s; }
.auth-head > *:nth-child(2) { animation-delay: .22s; }
.auth-form > *:nth-child(1) { animation-delay: .25s; }
.auth-form > *:nth-child(2) { animation-delay: .28s; }
.auth-form > *:nth-child(3) { animation-delay: .31s; }
.auth-form > *:nth-child(4) { animation-delay: .34s; }
.auth-form > *:nth-child(5) { animation-delay: .37s; }
.auth-form > *:nth-child(6) { animation-delay: .4s; }
.auth-form > *:nth-child(7) { animation-delay: .43s; }

@media (prefers-reduced-motion: reduce) {
  .auth-page *,
  .auth-page *::before,
  .auth-page *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  .auth-submit.is-submitting::after {
    animation: none !important;
    border-top-color: #fff;
  }
}

@media (max-width: 360px) {
  .auth-page { --gutter: 18px; }
  .auth-hero { padding-bottom: 148px; }
  .auth-hero__line { font-size: 23px; }
  .auth-cards { width: 184px; height: 104px; }
  .auth-main { margin-inline: 12px; padding-inline: 18px; }
  .auth-title { font-size: 25px; }
}

/* Short phones: keep the CTA reachable. */
@media (max-height: 720px) {
  /* Short phones cannot afford the decorative stack: the form wins. */
  .auth-hero { padding-bottom: 28px; }
  .auth-hero__line { margin-top: 12px; font-size: 22px; }
  .auth-cards { display: none; }
  .auth-main { padding-top: 20px; }
  .auth-head { margin-bottom: 16px; }
  .auth-form { gap: 12px; }
  .auth-note { margin-bottom: 12px; padding: 10px 12px; }
  .auth-secondary { margin-top: 12px; }
  .auth-legal { padding-top: 16px; }
}
