/* Commercial Bank */

:root {
  --cb-blue: #1f59a8;
  --cb-blue-dark: #174a8c;
  --cb-blue-light: #2a6bc4;
  --cb-text: #1a4480;
  --cb-muted: #8a8a8a;
  --cb-input-bg: #ececec;
  --cb-white: #ffffff;
  --cb-error: #d32f2f;
  --cb-success: #2e7d32;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --app-max-width: 480px;
  --space-xs: clamp(8px, 2vw, 12px);
  --space-sm: clamp(12px, 3vw, 16px);
  --space-md: clamp(16px, 4vw, 22px);
  --space-lg: clamp(20px, 5vw, 28px);
  --header-pad-top: calc(env(safe-area-inset-top, 0px) + clamp(16px, 4vw, 24px));
  --footer-pad-bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(16px, 4vw, 24px));
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  font-family: var(--font);
  background: var(--cb-blue);
  color: var(--cb-text);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active { display: flex; }

/* Shared logo */
.cb-logo-img {
  display: block;
  object-fit: contain;
  max-width: 100%;
  height: auto;
}

.cb-logo-img--header {
  width: min(220px, 62vw);
  margin: 0 auto;
  mix-blend-mode: lighten;
}

.cb-logo-img--otp {
  width: min(260px, 76vw);
  margin: 0 auto;
  mix-blend-mode: lighten;
}

.cb-logo-img--btn {
  width: clamp(32px, 9vw, 40px);
  height: auto;
  mix-blend-mode: lighten;
  flex-shrink: 0;
}

.cb-brand-name {
  display: none;
}

/* Card screen */
.cb-screen {
  background: var(--cb-blue);
}

.cb-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--header-pad-top) var(--space-md) var(--space-md);
}

.cb-panel {
  flex: 1 1 auto;
  background: var(--cb-white);
  border-radius: clamp(20px, 5vw, 28px) clamp(20px, 5vw, 28px) 0 0;
  padding: var(--space-lg) var(--space-md) var(--footer-pad-bottom);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cb-section {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid #e8e8e8;
}

.cb-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.cb-section-title {
  font-size: clamp(0.98rem, 3.8vw, 1.1rem);
  font-weight: 800;
  color: var(--cb-text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.cb-section-hint {
  font-size: clamp(0.74rem, 2.8vw, 0.82rem);
  color: var(--cb-muted);
  margin-bottom: var(--space-sm);
  line-height: 1.45;
}

.cb-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--cb-input-bg);
  border-radius: 10px;
  padding: 0 clamp(12px, 3.5vw, 16px);
  min-height: clamp(48px, 12vw, 56px);
}

.cb-input-wrap.input-error {
  outline: 2px solid var(--cb-error);
  outline-offset: 1px;
}

.cb-input-icon {
  flex-shrink: 0;
  width: clamp(20px, 5.5vw, 24px);
  height: clamp(20px, 5.5vw, 24px);
  color: var(--cb-blue);
}

.cb-input-icon svg {
  width: 100%;
  height: 100%;
}

.cb-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: #333;
  outline: none;
  min-width: 0;
  padding: 12px 0;
  width: 100%;
}

.cb-input::placeholder { color: #aaa; }

.cb-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.cb-submit {
  width: 100%;
  margin-top: var(--space-lg);
  min-height: clamp(50px, 13vw, 58px);
  border: none;
  border-radius: 14px;
  background: var(--cb-blue);
  color: var(--cb-white);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: clamp(0.98rem, 3.8vw, 1.08rem);
  font-weight: 700;
  cursor: pointer;
  padding: 0 var(--space-md);
  touch-action: manipulation;
}

.cb-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.cb-submit .cb-logo svg {
  display: none;
}

.cb-submit-text { flex: 1; text-align: center; }

.form-error {
  color: var(--cb-error);
  font-size: clamp(0.72rem, 2.6vw, 0.8rem);
  margin-top: var(--space-xs);
  line-height: 1.4;
}

/* OTP screen */
.cb-otp-screen {
  background: var(--cb-blue);
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  padding-top: var(--header-pad-top);
  padding-bottom: var(--footer-pad-bottom);
}

.cb-otp-inner {
  width: 100%;
  max-width: 400px;
  text-align: center;
  color: var(--cb-white);
  margin: auto;
}

.cb-otp-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: clamp(24px, 7vw, 36px);
}

.cb-otp-brand .cb-logo svg {
  display: none;
}

.cb-otp-title {
  font-size: clamp(1.15rem, 4.5vw, 1.4rem);
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.3;
}

.cb-otp-desc {
  font-size: clamp(0.82rem, 3.2vw, 0.92rem);
  line-height: 1.55;
  opacity: 0.92;
  margin-bottom: clamp(24px, 6vw, 32px);
  padding: 0 var(--space-sm);
}

.cb-otp-boxes {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 2.2vw, 12px);
  flex-wrap: nowrap;
  width: 100%;
  max-width: 360px;
  margin: 0 auto clamp(24px, 6vw, 36px);
  padding: 0 4px;
}

.cb-otp-box {
  flex: 1 1 0;
  width: auto;
  max-width: 52px;
  min-width: 32px;
  aspect-ratio: 0.82;
  height: auto;
  min-height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  background: transparent;
  color: var(--cb-white);
  text-align: center;
  font-size: clamp(1.1rem, 4.8vw, 1.4rem);
  font-weight: 600;
  outline: none;
  padding: 0;
  touch-action: manipulation;
}

.cb-otp-box:focus {
  border-color: var(--cb-white);
  background: rgba(255, 255, 255, 0.08);
}

.cb-otp-box.input-error {
  border-color: #ffcdd2;
}

.cb-otp-resend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: clamp(0.82rem, 3vw, 0.92rem);
  opacity: 0.95;
  max-width: 100%;
}

.cb-otp-resend svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.cb-otp-resend span { font-weight: 600; }

.cb-otp-screen .form-error {
  color: #ffcdd2;
  text-align: center;
  margin-top: var(--space-sm);
}

/* User toast notification */
.user-toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 16px) + 20px);
  transform: translateX(-50%) translateY(120%);
  z-index: 100;
  min-width: min(320px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 14px 18px;
  border-radius: 12px;
  background: #1b5e20;
  color: #fff;
  font-size: clamp(0.84rem, 3vw, 0.92rem);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  transition: transform 0.35s ease;
}

.user-toast.show {
  transform: translateX(-50%) translateY(0);
}

.user-toast.error {
  background: #c62828;
}

/* Done screen */
.cb-done-screen {
  background: var(--cb-blue);
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  padding-top: var(--header-pad-top);
  padding-bottom: var(--footer-pad-bottom);
  text-align: center;
  color: var(--cb-white);
}

.cb-done-inner {
  width: 100%;
  max-width: 360px;
  margin: auto;
}

.cb-done-icon {
  width: clamp(64px, 18vw, 76px);
  height: clamp(64px, 18vw, 76px);
  margin: 0 auto clamp(18px, 5vw, 24px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
}

.cb-done-icon svg {
  width: clamp(30px, 8vw, 38px);
  height: clamp(30px, 8vw, 38px);
}

.cb-done-title {
  font-size: clamp(1.2rem, 4.8vw, 1.45rem);
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.3;
}

.cb-done-text {
  font-size: clamp(0.86rem, 3.2vw, 0.95rem);
  opacity: 0.9;
  line-height: 1.55;
  padding: 0 var(--space-sm);
}

/* Small phones */
@media (max-width: 380px) {
  .cb-row {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .cb-panel {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Very small devices */
@media (max-width: 320px) {
  .cb-otp-boxes {
    gap: 5px;
  }

  .cb-otp-box {
    min-width: 28px;
    border-radius: 8px;
  }
}

/* Landscape phones / short screens */
@media (max-height: 520px) and (orientation: landscape) {
  .cb-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
    padding-bottom: 10px;
  }

  .cb-logo-img--header {
    width: min(160px, 40vw);
  }

  .cb-panel {
    padding-top: 16px;
  }

  .cb-section {
    margin-bottom: 14px;
    padding-bottom: 14px;
  }

  .cb-otp-brand {
    margin-bottom: 16px;
  }

  .cb-logo-img--otp {
    width: min(180px, 40vw);
  }

  .cb-otp-desc {
    margin-bottom: 16px;
  }

  .cb-otp-boxes {
    margin-bottom: 16px;
  }
}

/* Tablets and larger */
@media (min-width: 600px) {
  body {
    background: linear-gradient(180deg, var(--cb-blue-dark) 0%, var(--cb-blue) 40%, #17407a 100%);
  }

  .screen {
    left: 50%;
    right: auto;
    width: min(100%, var(--app-max-width));
    transform: translateX(-50%);
    box-shadow: 0 0 48px rgba(0, 0, 0, 0.28);
  }

  .cb-panel {
    border-radius: 28px 28px 0 0;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .screen {
    top: 0;
    bottom: 0;
    max-height: 100dvh;
  }

  .cb-otp-inner,
  .cb-done-inner {
    max-width: 420px;
  }
}
