/* ==========================================================================
   XANDER1LOANS — Design Tokens
   Palette: paper white + warm-grey surfaces, deep ledger green primary,
   muted brass accent used sparingly for emphasis only.
   Type: 'Sora' (headings/brand) + 'Inter' (body/UI) + 'IBM Plex Mono' (figures).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --paper: #ffffff;
  --surface: #f6f7f4;
  --surface-alt: #eef1ec;

  --ink-900: #10190f;
  --ink-700: #2b362a;
  --ink-500: #5c6b58;
  --ink-400: #8b9686;
  --ink-300: #c3cbbf;
  --border: #dfe3da;
  --border-soft: #ebeee7;

  --green-900: #0d2e21;
  --green-800: #123f2d;
  --green-700: #145c3f;
  --green-600: #1c7a52;
  --green-500: #269166;
  --green-100: #e5f2e9;
  --green-050: #f1f7f2;

  --brass-600: #8a6a28;
  --brass-500: #9c7a34;
  --brass-100: #f4ecd8;

  --danger: #b4392e;
  --danger-bg: #fbebe9;
  --success: #1d7a4c;
  --success-bg: #e9f5ee;
  --warn: #9a6710;
  --warn-bg: #fbf1de;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --font-display: 'Sora', 'Inter', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --shadow-sm: 0 1px 2px rgba(16, 25, 15, 0.05);
  --shadow-md: 0 6px 20px -8px rgba(16, 25, 15, 0.14);
  --shadow-lift: 0 20px 44px -18px rgba(16, 25, 15, 0.22);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink-900);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--green-100); color: var(--green-900); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0; letter-spacing: -0.015em; color: var(--ink-900); }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); }
.eyebrow {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--green-700);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ==========================================================================
   Brand mark
   ========================================================================== */
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 100px; height: 100px; border-radius: 9px; box-shadow: var(--shadow-sm); }
.brand-name { font-family: var(--font-display); font-size: 50px; font-weight: 700; color: var(--ink-900); }
.brand-name em { font-style: normal; color: var(--green-600); }

/* ==========================================================================
   Layout shells
   ========================================================================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
@media (max-width: 900px) { .auth-shell { grid-template-columns: 1fr; } }

.auth-visual {
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, var(--green-900), var(--green-800) 75%);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-visual::before {
  content: "";
  position: absolute; inset: -20%;
  background-image:
    linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 25% 25%, black, transparent 68%);
}

.auth-visual .brand-name,
.auth-visual .brand-name em { color: #fff; }
.auth-visual p, .auth-visual span { color: rgba(255,255,255,0.72); }

/* Auth cover slider — 1200x1200 source images, crossfading, autoplaying */
.auth-slider {
  position: relative; z-index: 1;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  max-height: 100vh;
  margin: 24px auto 0;
}
.auth-slide {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  transition: opacity 0.7s var(--ease);
}
.auth-slide.is-active { opacity: 1; visibility: visible; }
.auth-slide img {
  width: 100%; height: 100%; object-fit: cover; object-position: center;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  display: block;
}
.auth-slide-caption {
  position: relative; z-index: 1;
  margin-top: 18px;
  min-height: 44px;
  text-align: center;
}
.auth-slide-caption p { margin: 0 auto; }
.slider-dots { justify-content: center; }
.auth-slide-caption p {
  font-size: 14px; line-height: 1.55; color: rgba(255,255,255,0.78);
  max-width: 46ch;
}
.slider-dots { position: relative; z-index: 1; display: flex; gap: 8px; margin-top: 16px; }
.slider-dot {
  width: 22px; height: 4px; border-radius: 4px; border: none; padding: 0;
  background: rgba(255,255,255,0.22); cursor: pointer;
  transition: background 0.2s var(--ease), width 0.2s var(--ease);
}
.slider-dot.is-active { background: var(--green-500); width: 34px; }
.slider-dot:hover { background: rgba(255,255,255,0.4); }

.auth-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
  background: var(--paper);
}
.auth-card { width: 100%; max-width: 400px; }

/* ==========================================================================
   Form elements
   ========================================================================== */
.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: 13px; font-weight: 600; color: var(--ink-700);
  margin-bottom: 7px; letter-spacing: 0;
}
.field .hint { font-size: 12px; color: var(--ink-400); margin-top: 6px; }
.field .hint.field-error { color: var(--danger); font-weight: 500; }
.field input.field-invalid { border-color: var(--danger); }
.field input.field-invalid:focus { box-shadow: 0 0 0 3.5px var(--danger-bg); }
input, select, textarea {
  width: 100%;
  background: var(--paper);
  border: 1.5px solid var(--border);
  color: var(--ink-900);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14.5px;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%235c6b58' stroke-width='1.5'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green-600);
  box-shadow: 0 0 0 3.5px var(--green-100);
}
input::placeholder { color: var(--ink-400); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

/* Password visibility toggle — injected by initPasswordToggles() in app.js */
.password-field { position: relative; }
.password-field input { padding-right: 44px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: none; background: transparent; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-400); cursor: pointer; border-radius: 7px;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.password-toggle:hover { color: var(--ink-700); background: var(--surface); }

/* "Check your email" verification-link state */
.verify-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green-050); color: var(--green-700);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}

.otp-row { display: flex; gap: 10px; }
.otp-row input {
  width: 46px; height: 54px; text-align: center; font-size: 20px;
  font-family: var(--font-mono); padding: 0;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  padding: 12px 22px; font-family: var(--font-body); font-weight: 600; font-size: 14.5px;
  cursor: pointer; transition: background 0.16s var(--ease), border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), transform 0.1s var(--ease);
  width: 100%;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--green-700);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--green-800); box-shadow: var(--shadow-md); }
.btn-ghost {
  background: var(--paper); color: var(--ink-900);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--ink-400); background: var(--surface); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #96271d; }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }
.btn-block-row { display: flex; gap: 12px; }

.link-row { text-align: center; margin-top: 20px; font-size: 13.5px; color: var(--ink-500); }
.link-row a { color: var(--green-700); font-weight: 600; }
.link-row a:hover { text-decoration: underline; }

/* Signed document download + upload pairing (e.g. loan agreement) */
.agreement-box {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.agreement-download {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.agreement-download:hover { border-color: var(--green-600); background: var(--green-050); }
.agreement-download-icon {
  flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--green-100); color: var(--green-700);
}
.agreement-download-title { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-900); }
.agreement-download-sub { display: block; font-size: 12px; color: var(--ink-500); margin-top: 2px; }

/* ==========================================================================
   Cards / surfaces
   ========================================================================== */
.card {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 19px; margin-bottom: 4px; }
.card-sub { color: var(--ink-500); font-size: 13.5px; margin-bottom: 22px; }

/* Steps indicator */
.steps { display: flex; align-items: center; gap: 6px; margin-bottom: 28px; }
.step-dot {
  flex: 1; height: 4px; border-radius: 4px; background: var(--border);
  transition: background 0.3s var(--ease);
}
.step-dot.done, .step-dot.active { background: var(--green-600); }

/* ==========================================================================
   App shell (dashboard/admin)
   ========================================================================== */
.app-shell { display: grid; grid-template-columns: 258px 1fr; min-height: 100vh; }
@media (max-width: 880px) { .app-shell { grid-template-columns: 1fr; } }

.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--border-soft);
  padding: 24px 18px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
@media (max-width: 880px) { .sidebar { position: static; height: auto; } }

.side-profile { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-md); background: var(--surface); }
.side-profile img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--paper); box-shadow: 0 0 0 2px var(--green-500); background: var(--green-100); }
.side-profile .name { font-size: 14px; font-weight: 600; color: var(--ink-900); }
.side-profile .role { font-size: 11.5px; color: var(--ink-400); }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--ink-500); cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  border-left: 2.5px solid transparent;
}
.nav-item:hover { background: var(--surface); color: var(--ink-900); }
.nav-item.active { background: var(--green-050); color: var(--green-800); font-weight: 600; border-left-color: var(--green-600); }
.nav-item .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.55; }

.main { padding: 32px 40px; max-width: 1180px; }
@media (max-width: 640px) { .main { padding: 20px 16px; } }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.page-title { font-size: 24px; }
.page-sub { color: var(--ink-500); font-size: 14px; margin-top: 4px; }

/* Stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { padding: 18px 20px; }
.stat-card .eyebrow { margin-bottom: 10px; display: block; }
.stat-card .value { font-family: var(--font-display); font-size: 27px; font-weight: 700; }
.stat-card .delta { font-size: 12.5px; color: var(--success); margin-top: 6px; font-weight: 500; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--ink-500); font-weight: 600; font-size: 12px; letter-spacing: 0.01em; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
td { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; color: var(--ink-700); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; }
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-disbursed { background: var(--brass-100); color: var(--brass-600); }
.badge-closed { background: var(--surface-alt); color: var(--ink-500); }

/* Interest tier chips */
.tier-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 640px) { .tier-grid { grid-template-columns: repeat(2, 1fr); } }
.tier-chip {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 10px; text-align: center; cursor: pointer; background: var(--paper);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.tier-chip:hover { border-color: var(--ink-400); }
.tier-chip .pct { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--ink-900); }
.tier-chip .lbl { font-size: 10.5px; color: var(--ink-400); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }
.tier-chip.selected { border-color: var(--green-600); background: var(--green-050); }
.tier-chip.selected .pct { color: var(--green-700); }

/* Camera capture box */
.capture-box {
  position: relative; width: 100%; max-width: 320px; aspect-ratio: 3/4;
  border-radius: var(--radius-md); overflow: hidden; background: var(--ink-900);
  border: 1px solid var(--border); margin: 0 auto 14px;
}
.capture-box video, .capture-box img.capture-preview { width: 100%; height: 100%; object-fit: cover; display: block; }
.capture-box .frame-guide {
  position: absolute; inset: 12%; border: 2px dashed rgba(255,255,255,0.55); border-radius: 50% / 40%;
  pointer-events: none;
}

/* File dropzones */
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius-md);
  padding: 22px; text-align: center; cursor: pointer; transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
  font-size: 13px; color: var(--ink-500); background: var(--surface);
}
.dropzone:hover { border-color: var(--green-600); background: var(--green-050); }
.dropzone.has-file { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.dropzone input[type=file] { display: none; }

/* Progress / repayment tracker */
.progress-track { height: 9px; border-radius: 20px; background: var(--surface-alt); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 20px; background: var(--green-600); transition: width 0.6s var(--ease); }

.repay-schedule { display: flex; flex-direction: column; gap: 10px; }
.repay-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--border-soft); }
.repay-row.paid { opacity: 0.55; }
.repay-row .idx { font-family: var(--font-mono); color: var(--ink-400); font-size: 12px; width: 34px; }

/* Toast */
#toast-stack { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink-900); color: #fff; border: 1px solid rgba(255,255,255,0.1);
  padding: 13px 18px; border-radius: var(--radius-sm); font-size: 13.5px; box-shadow: var(--shadow-lift);
  animation: toastIn 0.3s var(--ease);
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }

/* Empty state */
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-500); }
.empty-state .glyph { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--green-600); margin-bottom: 10px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 25, 15, 0.45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.22s var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal-box { width: 100%; max-width: 480px; transform: translateY(12px) scale(0.98); transition: transform 0.24s var(--ease); }
.modal-backdrop.open .modal-box { transform: translateY(0) scale(1); }

/* ==========================================================================
   X1 page transition — the one signature motion moment, kept deliberately
   ========================================================================== */
#x1-transition {
  position: fixed; inset: 0; z-index: 3000; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--green-900);
  opacity: 0; visibility: hidden;
}
#x1-transition.run { opacity: 1; visibility: visible; animation: x1Fade 0.55s var(--ease) forwards; }
#x1-transition .x1-mark {
  font-family: var(--font-display); font-weight: 800; font-size: 13vw; color: #fff;
  opacity: 0; transform: scale(0.75);
}
#x1-transition.run .x1-mark { animation: x1Pop 0.55s var(--ease) forwards; }
#x1-transition .x1-bar {
  position: absolute; left: 0; right: 0; height: 2px; background: var(--green-500);
  top: 50%; transform: scaleX(0); transform-origin: left;
}
#x1-transition.run .x1-bar { animation: x1Sweep 0.55s var(--ease) forwards; }

@keyframes x1Fade {
  0% { opacity: 0; }
  15% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes x1Pop {
  0% { opacity: 0; transform: scale(0.7); }
  35% { opacity: 1; transform: scale(1.03); }
  55% { transform: scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.08); }
}
@keyframes x1Sweep {
  0% { transform: scaleX(0); opacity: 0.9; }
  50% { transform: scaleX(1); opacity: 0.9; }
  100% { transform: scaleX(1); opacity: 0; }
}

.page-enter { animation: pageEnter 0.4s var(--ease) both; }
@keyframes pageEnter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Utility */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .mt-24 { margin-top: 24px; }
.text-muted { color: var(--ink-500); }
.divider { height: 1px; background: var(--border-soft); margin: 22px 0; }

/* ==========================================================================
   Responsive — from the smallest feasible screens up to large desktops.
   Rules cascade from largest breakpoint to smallest so later, more specific
   overrides win on narrower viewports.
   ========================================================================== */

/* ≤1200px — slightly tighten the app shell's max width usage */
@media (max-width: 1200px) {
  .main { max-width: none; }
}

/* ≤1024px — auth visual shrinks before the layout stacks at 900px */
@media (max-width: 1024px) {
  .auth-visual { padding: 44px; }
  .auth-slider { max-width: 380px; }
}

/* ≤900px: .auth-shell stacks (defined above) */
@media (max-width: 900px) {
  .auth-visual { padding: 32px 28px 40px; }
  .auth-slider { max-width: 300px; max-height: 300px; margin-top: 20px; }
  .auth-panel { padding: 32px 20px; }
}

/* ≤880px: .app-shell / .sidebar stack (defined above) — refine the stacked nav */
@media (max-width: 880px) {
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px; padding: 16px 18px; }
  .side-profile { flex: 1 1 auto; }
  .nav-group { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav-item { border-left: none; border-bottom: 2.5px solid transparent; }
  .nav-item.active { border-left-color: transparent; border-bottom-color: var(--green-600); }
}

/* ≤768px — general form / card breathing room */
@media (max-width: 768px) {
  .card { padding: 22px; }
  .page-title { font-size: 21px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  table { font-size: 12.5px; }
  th, td { padding: 10px 12px; }
  .auth-slide img {
    width: 100%; height: 100%; object-fit: cover; object-position: center;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    display: block;
  }
  .auth-slider {
    position: relative; z-index: 1;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 1 / 1;
    max-height: 100vh;
    margin: 24px auto 0;
  }
}

/* ≤640px: .main padding tightens, .tier-grid goes to 2 columns (defined above) */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .btn-block-row { flex-direction: column; }
  .field-row { grid-template-columns: 1fr; }
  .agreement-download { flex-direction: column; align-items: flex-start; text-align: left; }
}

/* ≤520px: .field-row already 1 col (defined above) */
@media (max-width: 520px) {
  .auth-card { max-width: 100%; }
  .card-title { font-size: 18px; }
  .otp-row input { width: 40px; height: 48px; font-size: 18px; }
}

/* ≤480px — smallest common phones */
@media (max-width: 480px) {
  .brand-name { font-size: 46px; }
  .brand img { width: 60px; height: 60px; }
  .auth-visual { padding: 24px 18px 32px; }

  .auth-slide img {
    width: 100%; height: 100%; object-fit: cover; object-position: center;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    display: block;
  }
  .auth-slider {
    position: relative; z-index: 1;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 1 / 1;
    max-height: 100vh;
    margin: 24px auto 0;
  }
  .auth-slide-caption p { font-size: 13px; max-width: 32ch; }
  .auth-panel { padding: 26px 16px; }
  .card { padding: 18px; border-radius: var(--radius-md); }
  .main { padding: 16px 12px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .value { font-size: 22px; }
  .tier-grid { grid-template-columns: repeat(2, 1fr); }
  .otp-row { gap: 6px; }
  .otp-row input { width: 34px; height: 42px; font-size: 16px; }
  #x1-transition .x1-mark { font-size: 22vw; }
  #toast-stack { left: 12px; right: 12px; top: 12px; }
  .toast { max-width: none; }
}

/* ≤360px — very narrow phones */
@media (max-width: 360px) {
  .auth-slider { max-width: 180px; max-height: 180px; }
  .stat-grid { grid-template-columns: 1fr; }
  .tier-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .btn { padding: 11px 16px; font-size: 14px; }
  input, select, textarea { padding: 10px 12px; font-size: 14px; }
}

/* ≤300px — compressed layout: strip decorative chrome, keep everything usable */
@media (max-width: 300px) {
  .auth-visual { display: none; }
  .auth-panel { padding: 18px 12px; }
  .card { padding: 14px; }
  .card-title { font-size: 16px; }
  .card-sub { font-size: 12px; margin-bottom: 16px; }
  .field { margin-bottom: 14px; }
  .otp-row input { width: 28px; height: 36px; font-size: 14px; }
  .sidebar { padding: 12px; gap: 10px; }
  .nav-item { font-size: 13px; padding: 8px 10px; }
  .main { padding: 12px 10px; }
  .auth-slide img {
    width: 100%; height: 100%; object-fit: cover; object-position: center;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    display: block;
  }
  .auth-slider {
    position: relative; z-index: 1;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 1 / 1;
    max-height: 100vh;
    margin: 24px auto 0;
  }
}

/* ≤200px — minimum viable rendering; single column, no ornamentation */
@media (max-width: 200px) {
  .card { padding: 10px; border-radius: var(--radius-sm); }
  .stat-grid, .tier-grid { grid-template-columns: 1fr; }
  .btn { font-size: 12.5px; padding: 9px 10px; }
  .brand-name { font-size: 13px; }
  .page-title { font-size: 16px; }
  th, td { padding: 6px 8px; font-size: 11px; }
  .auth-slide img {
    width: 100%; height: 100%; object-fit: cover; object-position: center;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    display: block;
  }
  .auth-slider {
    position: relative; z-index: 1;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 1 / 1;
    max-height: 100vh;
    margin: 24px auto 0;
  }
}
