/* ============================================================
   ICCU myeBranch – Mobile Authentication Page
   ============================================================ */

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

:root {
  --green:      #2e7d32;
  --green-dark: #1a5c1a;
  --green-pale: #eef5ee;
  --red:        #c0392b;
  --white:      #fff;
  --text:       #333;
  --text-mid:   #666;
}

/* ── Base: phone-first, no scroll ── */
html {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}
body {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-x pinch-zoom;
  font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--white);
}
a      { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
img    { display: block; }

/* ═══════════════════════════════════════
   THREE-DOT
═══════════════════════════════════════ */
.threedot {
  position: fixed;
  top: 36px;
  right: max(16px, calc(50% - 250px));
  z-index: 200;
}
.threedot__btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--green-pale);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background .15s;
}
.threedot__btn:hover { background: #dcedc8; }
.threedot__btn span {
  display: block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
}

/* ═══════════════════════════════════════
   BOTTOM SHEET OVERLAY
═══════════════════════════════════════ */
.sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 400;
}
.sheet-overlay.open { display: block; }

/* ═══════════════════════════════════════
   SHEET – bottom sheet on phone
═══════════════════════════════════════ */
.sheet--popup {
  position: fixed;
  bottom: 0; left: 0; right: 0; top: auto;
  width: auto;
  background: var(--white);
  border-radius: 22px 22px 0 0;
  padding: 12px 0 40px;
  z-index: 500;
  box-shadow: none;
  border: none;
  transform: translateY(100%);
  transform-origin: bottom center;
  opacity: 1;
  pointer-events: auto;
  transition: transform .32s cubic-bezier(.4,0,.2,1);
  max-height: 88vh;
  overflow-y: auto;
}
.sheet--popup.open { transform: translateY(0); }

.sheet__handle {
  width: 40px; height: 5px;
  background: #ccc;
  border-radius: 3px;
  margin: 0 auto 20px;
  display: block;
}

.sheet__nav { display: flex; flex-direction: column; }

.sheet__item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 28px;
  color: var(--text);
  font-size: 17px;
  font-weight: 500;
  transition: background .12s;
  text-decoration: none;
}
.sheet__item:hover { background: var(--green-pale); }
.sheet__icon { width: 26px; height: 26px; flex-shrink: 0; color: var(--green); }

/* ═══════════════════════════════════════
   PAGE MAIN – fixed, no scroll on phone
═══════════════════════════════════════ */
.page-main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  padding: 0 24px 40px;
  max-width: 500px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════
   LOGO – pushed down, close to inputs
═══════════════════════════════════════ */
.logo {
  margin-top: 48px;
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}
.logo__img {
  width: 78%;
  max-width: 300px;
  height: auto;
  object-fit: contain;
}

/* ═══════════════════════════════════════
   FORM
═══════════════════════════════════════ */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 1;
  min-height: 0;
}

/* ═══════════════════════════════════════
   FIELDS
═══════════════════════════════════════ */
.field { display: flex; flex-direction: column; }

.field__input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: 16px;
  font-size: 15px;
  color: var(--text);
  background: #efefef;
  outline: none;
  transition: background .15s;
}
.field__input::placeholder { color: #999; font-size: 15px; }
.field__input:focus { background: #e4e4e4; }
.field__input.is-err { background: #fff0f0; outline: 2px solid #e05252; }

.field__err {
  color: var(--red);
  font-size: 13px;
  margin-top: 5px;
  margin-left: 6px;
  display: none;
}
.field__err.visible { display: block; }

.field__pwrap { position: relative; }
.field__pwrap .field__input { padding-right: 56px; }
.field__eye {
  position: absolute;
  top: 50%; right: 18px;
  transform: translateY(-50%);
  color: #888; line-height: 0;
  transition: color .15s;
}
.field__eye:hover { color: var(--green); }
.field__eye svg { width: 24px; height: 24px; }

/* ═══════════════════════════════════════
   REMEMBER ME
═══════════════════════════════════════ */
.remember { display: flex; align-items: center; gap: 14px; margin: 0; }
.toggle { position: relative; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
  display: block; width: 50px; height: 28px;
  border-radius: 14px; background: #ccc;
  transition: background .2s; position: relative;
}
.toggle input:checked ~ .toggle__track { background: var(--green); }
.toggle__thumb {
  position: absolute; top: 4px; left: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .2s;
}
.toggle input:checked ~ .toggle__track .toggle__thumb { transform: translateX(22px); }
.remember__label { font-size: 16px; color: var(--text); user-select: none; }

/* ═══════════════════════════════════════
   CLOUDFLARE WIDGET
═══════════════════════════════════════ */
.cf-widget {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid #ddd; border-radius: 8px;
  background: #fafafa; padding: 10px 16px;
  width: 260px;
  align-self: center;
  margin: 0 auto;
}
.cf-widget__left { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.cf-widget__icon { width: 26px; height: 26px; flex-shrink: 0; }
.cf-widget__icon svg { width: 26px; height: 26px; display: block; }
.cf-spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cf-widget__text { font-size: 13px; color: var(--text-mid); }
.cf-widget__text.done { color: var(--green); font-weight: 600; }
.cf-widget__right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.cf-logo-img { width: 76px; height: auto; object-fit: contain; }
.cf-links { display: flex; align-items: center; gap: 4px; }
.cf-links a, .cf-links span { font-size: 10px; color: #aaa; }
.cf-links a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════
   LOGIN ERROR
═══════════════════════════════════════ */
.login-err {
  display: flex; align-items: center; gap: 10px;
  background: #fff0f0; border: 1px solid #f5c6c6;
  border-radius: 10px; padding: 12px 16px;
  color: var(--red); font-size: 14px;
}
.login-err svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ═══════════════════════════════════════
   LOG IN BUTTON
═══════════════════════════════════════ */
.btn-login {
  width: 100%; height: 48px;
  border-radius: 40px;
  background: var(--green); color: #fff;
  font-size: 17px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, transform .1s;
  letter-spacing: .3px;
  flex-shrink: 0;
}
.btn-login:hover:not(:disabled) { background: var(--green-dark); }
.btn-login:active:not(:disabled) { transform: scale(.99); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }
.btn-spin { width: 20px; height: 20px; animation: spin .8s linear infinite; }

/* ═══════════════════════════════════════
   LINKS
═══════════════════════════════════════ */
.forgot { text-align: center; margin-top: 4px; color: var(--green); font-size: 13px; }
.forgot__link { color: var(--green); font-size: 13px; }
.forgot__link:hover { text-decoration: underline; }
.enroll-link { display: block; text-align: center; margin-top: 4px; color: var(--green); font-weight: 800; font-size: 15px; }
.enroll-link:hover { text-decoration: underline; }
.join-link { display: block; text-align: center; margin-top: 4px; color: var(--green); font-size: 13px; }
.join-link:hover { text-decoration: underline; }

/* ═══════════════════════════════════════
   MODALS
═══════════════════════════════════════ */
.modal-wrap {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 700; display: flex;
  align-items: center; justify-content: center;
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--white);
  border-radius: 18px;
  padding: 32px 26px 28px;
  width: 92vw; max-width: 420px;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  animation: slideUp .2s ease;
}
.modal--wide { max-width: 460px; }
@keyframes slideUp { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { font-size: 20px; font-weight: 700; color: var(--green); margin-bottom: 8px; }
.modal p  { font-size: 14px; color: var(--text-mid); margin-bottom: 16px; }
.modal__close { position: absolute; top: 14px; right: 18px; font-size: 20px; color: #aaa; line-height: 1; }
.modal__close:hover { color: var(--text); }
.modal__success { margin-top: 14px; padding: 10px 14px; background: var(--green-pale); border-radius: 8px; color: var(--green); font-size: 14px; font-weight: 500; }
.enroll-grid { display: flex; flex-direction: column; gap: 12px; }

/* ═══════════════════════════════════════
   SHAKE
═══════════════════════════════════════ */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.shake { animation: shake .45s ease; }

/* ═══════════════════════════════════════
   SMALL PHONES (short viewport ≤ 800px)
   Scale down spacing so nothing overflows
═══════════════════════════════════════ */
@media (max-height: 800px) {
  .logo {
    margin-top: 36px;
    margin-bottom: 6px;
  }
  .logo__img { width: 74%; }
  .form { gap: 13px; }
  .field__input { height: 50px; font-size: 15px; }
  .btn-login { height: 50px; font-size: 16px; }
  .remember__label { font-size: 15px; }
  .cf-widget { padding: 9px 14px; }
  .enroll-link { font-size: 14px; margin-top: 3px; }
  .join-link   { font-size: 13px; margin-top: 3px; }
  .forgot      { font-size: 13px; margin-top: 3px; }
  .page-main   { padding: 0 22px 32px; }
}

/* ═══════════════════════════════════════
   VERY SMALL PHONES (≤ 580px tall, e.g. iPhone SE)
═══════════════════════════════════════ */
@media (max-height: 580px) {
  .logo {
    margin-top: 24px;
    margin-bottom: 8px;
  }
  .logo__img { width: 42%; }
  .form { gap: 6px; }
  .field__input { height: 40px; font-size: 13px; border-radius: 12px; }
  .btn-login { height: 40px; font-size: 15px; }
  .toggle__track { width: 42px; height: 24px; border-radius: 12px; }
  .toggle__thumb { width: 16px; height: 16px; }
  .toggle input:checked ~ .toggle__track .toggle__thumb { transform: translateX(18px); }
  .remember__label { font-size: 13px; }
  .cf-widget { padding: 6px 10px; }
  .cf-logo-img { width: 60px; }
  .enroll-link { font-size: 13px; margin-top: 1px; }
  .join-link   { font-size: 11px; margin-top: 1px; }
  .forgot      { font-size: 11px; margin-top: 1px; }
  .page-main   { padding: 0 18px 28px; }
  .threedot    { top: 20px; }
}

/* ═══════════════════════════════════════
   DESKTOP OVERRIDES (≥600px)
   Allow scrolling and centre the column
═══════════════════════════════════════ */
@media (min-width: 600px) {
  html { height: auto; overflow: auto; }
  body {
    position: static;
    height: auto;
    overflow: auto;
    touch-action: auto;
  }
  .page-main {
    position: static;
    height: auto;
    overflow: visible;
    min-height: 100vh;
    justify-content: center;
    padding: 80px 28px 80px;
  }
  .logo { margin-top: 0; margin-bottom: 40px; }
  .logo__img { width: 260px; max-width: 260px; }
  .field__input { height: 58px; font-size: 16px; }
  .btn-login { height: 58px; font-size: 18px; }
  .cf-widget { width: 300px; }
  /* popup menu on desktop */
  .sheet--popup {
    position: fixed;
    bottom: auto; top: 88px;
    left: auto;
    right: max(16px, calc(50% - 250px));
    width: 240px;
    border-radius: 14px;
    padding: 8px 0 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    border: 1px solid #eee;
    transform: scale(.92) translateY(-10px);
    transform-origin: top right;
    opacity: 0;
    pointer-events: none;
    transition: transform .2s ease, opacity .2s ease;
    max-height: none;
    overflow-y: visible;
  }
  .sheet--popup.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .sheet--popup .sheet__handle { display: none; }
  .sheet__item { padding: 14px 24px; font-size: 15px; gap: 16px; }
  .sheet__icon { width: 22px; height: 22px; }
}
