/* =========================================================================
   Tatkal Loan — UI system (modern fintech, refined, light)
   Driven entirely by :root tokens + semantic class names. Templates are
   untouched: retuning tokens/spacing/typography here restyles every screen.
   ========================================================================= */

/* Inter, self-hosted (OFL). Google Fonts is blocked by our strict CSP and would
   leak a request to Google on every page load — not acceptable for an India-only,
   data-residency-bound lender. These are the @fontsource variable (wght 100–900)
   woff2 subsets served same-origin from /static/fonts. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* brand */
  --brand: #f4551b;          /* Tatkal Loan orange (sampled from logo) */
  --brand-dark: #d8420c;     /* hover / pressed */
  --brand-2: #d8420c;        /* accent links (AA-legible on white) */
  --brand-050: #fff4ef;      /* soft tint background */
  --brand-100: #ffe6da;      /* tint border */
  --brand-ring: rgba(244, 85, 27, .16);

  /* neutrals — cool, bank-grade */
  --ink: #101828;            /* primary text / headings */
  --ink-soft: #344054;       /* secondary text */
  --muted: #667085;          /* tertiary / labels */
  --faint: #98a2b3;          /* placeholders, hints */
  --bg: #f6f7f9;             /* app background */
  --card: #ffffff;
  --line: #e4e7ec;           /* borders */
  --line-soft: #f2f4f7;      /* hairlines / zebra */
  --field: #ffffff;
  --field-alt: #f9fafb;      /* input affix / disabled */

  /* semantic */
  --error-bg: #fef3f2; --error: #b42318; --error-line: #fecdca;
  --ok-bg: #ecfdf3;   --ok: #067647;    --ok-line: #abefc6;
  --warn-bg: #fffaeb; --warn: #b54708;

  /* geometry */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* elevation — layered, soft */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .12), 0 4px 10px rgba(16, 24, 40, .05);

  --ring: 0 0 0 4px var(--brand-ring);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
  font-feature-settings: "cv01", "cv03", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex; flex-direction: column; min-height: 100vh;
}
.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 20px; }
a { color: var(--brand-2); }

/* ============================ accessibility ============================= */
/* Screen-reader-only content (visually hidden, still announced). */
.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;
}
/* Keyboard skip-link: off-screen until focused, then pinned top-left. */
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 50;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-weight: 700; text-decoration: none; transition: top .15s ease;
}
.skip-link:focus { top: 8px; }
/* Respect reduced-motion: drop all transitions/animations app-wide. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* small utilities (CSP forbids inline style attributes: style-src 'self', no unsafe-inline) */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.referral-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px; font-weight: 700;
}
.mt-18 { margin-top: 18px; }

/* subtle brand wash behind the customer journey */
body:not(.admin) {
  background:
    radial-gradient(1200px 420px at 50% -180px, var(--brand-050), transparent 70%),
    var(--bg);
}

/* ============================ header / footer ============================ */
.site-header {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.header-inner { display: flex; align-items: center; gap: 16px; padding: 14px 20px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  border-radius: 9px; display: block;
  box-shadow: 0 2px 6px rgba(244, 85, 27, .28);
}
.brand-name { font-weight: 800; font-size: 21px; color: var(--ink); letter-spacing: -.5px; }
.brand-name span { color: var(--brand); }
.tagline {
  color: var(--muted); font-size: 12.5px; font-weight: 500;
  padding-left: 16px; margin-left: 4px; border-left: 1px solid var(--line);
}
.main { flex: 1; padding: 44px 20px; }
.site-footer {
  border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 13px;
}
.site-footer .container { padding: 18px 20px; display: flex; align-items: center; flex-wrap: wrap; }
.site-footer .dot { margin: 0 8px; color: var(--line); }

@media (max-width: 560px) {
  .tagline { display: none; }
  .main { padding: 28px 16px; }
  .container { padding: 0 16px; }
}

/* ================================ card =================================== */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 32px; max-width: 520px; margin: 0 auto;
}
.auth-card { max-width: 428px; }
.card h1 { font-size: 25px; line-height: 1.2; letter-spacing: -.5px; margin: 0 0 8px; font-weight: 800; }
.card h2 { font-size: 18px; letter-spacing: -.2px; margin: 0 0 4px; font-weight: 700; }
.muted { color: var(--muted); margin: 0 0 20px; }
.fineprint {
  color: var(--muted); font-size: 12.5px; margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
hr { border: none; border-top: 1px solid var(--line); margin: 24px 0; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.mt-24 { margin-top: 24px; }

/* ================================ forms ================================== */
label { display: block; font-weight: 600; font-size: 13.5px; color: var(--ink-soft); margin: 18px 0 7px; }
label .muted { font-weight: 500; }

input[type=text], input:not([type]), .otp-input, input[name=mobile], input[name=otp],
select, textarea,
input[type=date], input[type=email], input[type=number], input[type=tel],
input[type=password] {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: inherit;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--field); color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #d0d5dd; }
input:focus, select:focus, textarea:focus,
input[type=date]:focus, input[type=email]:focus, input[type=password]:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}

/* File inputs — styled to match the design system (replaces the bare native control, whose
   "Choose File / No file chosen" looked unpolished against the rest of the form). */
input[type=file] {
  width: 100%; font-size: 14px; color: var(--muted); font-family: inherit;
  padding: 10px 12px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm);
  background: var(--field); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
input[type=file]:hover { border-color: #d0d5dd; }
input[type=file]:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input[type=file]::file-selector-button {
  margin-right: 12px; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600;
  color: #fff; background: var(--brand); border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s ease;
}
input[type=file]:hover::file-selector-button { background: var(--brand-2); }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
textarea { resize: vertical; }

/* Date-of-birth field: typeable DD/MM/YYYY text input + a calendar button that opens the native
   date picker (dob-picker.js keeps them in sync). The native <input type=date> only hosts the
   calendar popup, so it's visually hidden — the selector is more specific than the generic
   input[type=date] rule above so the hide actually wins. */
.dob-field { position: relative; }
.dob-field #dob { padding-right: 44px; }
.dob-field .dob-picker {
  position: absolute; right: 12px; bottom: 0; z-index: -1;
  width: 1px; height: 1px; min-width: 0; padding: 0; margin: 0;
  border: 0; opacity: 0; pointer-events: none; background: transparent;
}
.dob-field .dob-cal-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; margin: 0;
  background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--ink-soft);
}
.dob-field .dob-cal-btn:hover { background: #f2f4f7; color: var(--brand); }
.dob-field .dob-cal-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.dob-field .dob-cal-btn svg { width: 20px; height: 20px; display: block; }

.input-affix { display: flex; align-items: stretch; }
.input-affix .affix {
  display: flex; align-items: center; padding: 0 14px; font-weight: 600; color: var(--muted);
  border: 1.5px solid var(--line); border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--field-alt);
}
.input-affix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-affix:focus-within .affix { border-color: var(--brand); }
.otp-input { letter-spacing: .55em; text-align: center; font-size: 24px; font-weight: 700; }
input.upper { text-transform: uppercase; }
input.upper::placeholder { text-transform: none; }

/* =============================== 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 20px;
  font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer;
  text-decoration: none; text-align: center; line-height: 1.2;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .65; cursor: default; transform: none; }
.btn-primary {
  background: var(--brand); color: #fff; width: 100%; margin-top: 22px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 6px 16px rgba(244, 85, 27, .22);
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost {
  background: #fff; color: var(--ink-soft); border-color: var(--line); padding: 10px 16px;
}
.btn-ghost:hover { border-color: #d0d5dd; background: var(--field-alt); }
.btn-link { background: none; color: var(--brand-2); padding: 8px 4px; font-weight: 700; }
.btn-link:hover { text-decoration: underline; }
.auth-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* header logout — now on a light header */
.header-logout { margin-left: auto; }
.btn-logout {
  background: #fff; color: var(--ink-soft); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: border-color .15s ease, background .15s ease;
}
.btn-logout:hover { border-color: #d0d5dd; background: var(--field-alt); }

/* =============================== alerts ================================== */
.alert {
  border-radius: var(--radius-sm); padding: 12px 15px; font-size: 14px; font-weight: 500;
  margin: 8px 0 6px; border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start;
}
.alert::before { font-weight: 800; line-height: 1.4; }
.alert-error { background: var(--error-bg); color: var(--error); border-color: var(--error-line); }
.alert-error::before { content: "!"; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.alert-success::before { content: "✓"; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert-info::before { content: "i"; }

/* =========================== journey list ================================ */
.journey { list-style: none; padding: 0; margin: 20px 0 24px; display: grid; gap: 10px; }
.journey li { position: relative; padding-left: 30px; color: var(--muted); font-size: 14.5px; }
.journey li::before {
  content: ""; position: absolute; left: 0; top: 4px; width: 16px; height: 16px;
  border-radius: 50%; border: 2px solid var(--line); background: #fff;
}
.journey li.done { color: var(--ink); font-weight: 600; }
.journey li.done::before {
  content: "✓"; border-color: var(--brand); background: var(--brand); color: #fff;
  font-size: 10px; font-weight: 900; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* =========================== wizard / progress ========================== */
.wizard { max-width: 500px; }
.card.wizard h1 { margin-top: 6px; }
.upi-qr { text-align: center; margin: 16px 0; }
.upi-qr img { border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 8px; background: #fff; }

.steps-rail {
  list-style: none; display: flex; gap: 0; padding: 0; margin: 0 0 28px; overflow-x: auto;
  scrollbar-width: none;
}
.steps-rail::-webkit-scrollbar { display: none; }
.steps-rail .step {
  flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 600; color: var(--faint); position: relative; min-width: 56px;
  text-align: center;
}
.steps-rail .step::after {
  content: ""; position: absolute; top: 8px; left: 50%; width: 100%; height: 2px;
  background: var(--line); z-index: 0;
}
.steps-rail .step:last-child::after { display: none; }
.step-dot {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  border: 2px solid var(--line); z-index: 1; transition: all .2s ease;
}
.steps-rail .step.done .step-dot {
  background: var(--brand); border-color: var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.steps-rail .step.done::after { background: var(--brand); }
.steps-rail .step.done .step-label { color: var(--ink-soft); }
.steps-rail .step.current .step-dot {
  border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px var(--brand-ring);
}
.steps-rail .step.current .step-label { color: var(--brand); font-weight: 800; }

/* income 'analysing your statement' waiting state */
.processing-panel { text-align: center; padding: 10px 0 4px; }
.spinner {
  display: inline-block; width: 36px; height: 36px; border-radius: 50%; margin-bottom: 14px;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* collapsible "other ways to verify" on the income step */
.more-options { margin-top: 18px; }
.more-options > summary {
  cursor: pointer; font-weight: 700; color: var(--brand-2); padding: 8px 0; list-style: none;
}
.more-options > summary::-webkit-details-marker { display: none; }
.more-options > summary::before { content: "＋ "; }
.more-options[open] > summary::before { content: "－ "; }

/* ============================== checkbox ================================= */
label.checkbox {
  display: flex; align-items: flex-start; gap: 11px; font-weight: 500; font-size: 13.5px;
  color: var(--ink-soft); margin-top: 18px; cursor: pointer; line-height: 1.5;
}
label.checkbox input {
  width: 19px; height: 19px; margin-top: 1px; accent-color: var(--brand); flex: none; cursor: pointer;
}

/* =========================== status badges ============================== */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 13px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700; margin-bottom: 14px; border: 1px solid transparent;
}
.status-declined { background: var(--error-bg); color: var(--error); border-color: var(--error-line); }
.status-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }

/* ============================ offer summary ============================= */
.error-list { margin: 8px 0 22px; padding-left: 20px; color: var(--error); }
.error-list li { margin: 5px 0; font-weight: 600; }

.offer-summary {
  margin: 6px 0 20px; display: grid; gap: 0;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: #fff;
}
.offer-summary > div {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
}
.offer-summary dt { color: var(--muted); font-weight: 500; font-size: 14px; margin: 0; }
.offer-summary dd { margin: 0; font-weight: 700; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.offer-summary .total {
  border-bottom: none; background: var(--brand-050); padding: 16px;
}
.offer-summary .total dt { color: var(--ink); font-weight: 700; }
.offer-summary .total dd { color: var(--brand-2); font-size: 20px; font-weight: 800; }

/* KFS tables (APR computation sheet + amortisation schedule) */
.kfs-table {
  width: 100%; border-collapse: collapse; margin: 6px 0 20px; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  font-variant-numeric: tabular-nums; background: #fff;
}
.kfs-table th, .kfs-table td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft);
}
.kfs-table thead th { background: var(--brand-050); font-weight: 700; color: var(--ink); }
.kfs-table td:last-child, .kfs-table th:last-child { text-align: right; }
.kfs-schedule td, .kfs-schedule th { text-align: right; }
.kfs-schedule td:nth-child(2), .kfs-schedule th:nth-child(2) { text-align: left; }
.kfs-doc h2 { margin-top: 26px; }
.kfs-doc h3 { margin-top: 18px; font-size: 16px; }
@media (max-width: 560px) { .kfs-table { font-size: 12px; } .kfs-table th, .kfs-table td { padding: 6px 8px; } }

/* loan-amount slider */
.amount-picker {
  margin: 8px 0 22px; padding: 22px; border: 1px solid var(--brand-100); border-radius: var(--radius-lg);
  background: var(--brand-050);
}
.amount-picker .amount-label {
  display: block; color: var(--muted); font-weight: 600; font-size: 13px; margin: 0 0 4px;
  text-transform: uppercase; letter-spacing: .04em;
}
.amount-display {
  display: block; font-size: 34px; font-weight: 800; color: var(--ink); line-height: 1.15;
  letter-spacing: -1px; font-variant-numeric: tabular-nums;
}
/* fully custom range so the filled track always matches the thumb (JS sets --fill). */
.amount-picker input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; margin: 18px 0 6px;
  height: 8px; border-radius: var(--radius-pill); cursor: pointer; background: transparent;
  --fill: 100%;
}
.amount-picker input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: var(--radius-pill);
  background: linear-gradient(to right, var(--brand) var(--fill), #f0d9cd var(--fill));
}
.amount-picker input[type="range"]::-moz-range-track {
  height: 8px; border-radius: var(--radius-pill); background: #f0d9cd;
}
.amount-picker input[type="range"]::-moz-range-progress {
  height: 8px; border-radius: var(--radius-pill); background: var(--brand);
}
.amount-picker input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; margin-top: -9px;
  border-radius: 50%; background: #fff; border: 3px solid var(--brand);
  box-shadow: 0 2px 6px rgba(216, 66, 12, .35); transition: transform .05s ease;
}
.amount-picker input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  border: 3px solid var(--brand); box-shadow: 0 2px 6px rgba(216, 66, 12, .35);
}
.amount-picker input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
.amount-picker input[type="range"]:focus-visible { outline: none; }
.amount-picker input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 5px var(--brand-ring);
}
.amount-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 500; }

/* ==================== request a higher amount ========================== */
.higher-amount {
  margin: 16px 0 4px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--field); padding: 0 16px;
}
.higher-amount > summary {
  cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--ink-soft);
  padding: 13px 0; user-select: none;
}
.higher-amount > summary:hover { color: var(--ink); }
.higher-amount[open] > summary { color: var(--ink); border-bottom: 1px solid var(--line-soft); }
.higher-amount-body { padding: 4px 0 14px; }
.higher-amount-body .muted { font-size: 14px; margin: 12px 0; }
.higher-amount-note {
  background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13.5px; margin: 0;
}
.higher-amount-note strong { font-weight: 700; }
.higher-amount-row { display: flex; gap: 8px; align-items: stretch; margin-top: 8px; }
.higher-amount-row input { flex: 1 1 auto; min-width: 0; margin: 0; }
.higher-amount-row .btn { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 480px) { .higher-amount-row { flex-direction: column; } }

/* ========================= repayment schedule ========================== */
.table-scroll {
  overflow-x: auto; margin: 8px 0 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff;
  container-type: inline-size;  /* lets the table below react to ITS width, so the stacked layout
                                   kicks in the same way on a phone and in a narrow desktop card. */
}
table.schedule { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
table.schedule th, table.schedule td {
  padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.schedule th:first-child, table.schedule td:first-child,
table.schedule th:nth-child(2), table.schedule td:nth-child(2) { text-align: left; }
table.schedule thead th {
  color: var(--muted); font-weight: 700; background: var(--field-alt);
  border-bottom: 1px solid var(--line); text-transform: uppercase; font-size: 11px; letter-spacing: .04em;
}
table.schedule tbody tr:last-child td { border-bottom: none; }

/* When the table is wider than its container (a phone, OR a narrow desktop card — same rule for
   both), each row stacks into a labelled card so every field (incl. Status) stays visible with no
   horizontal scroll or cut-off columns. Each <td> carries a data-label that becomes its field
   name here. */
@container (max-width: 540px) {
  .table-scroll { overflow-x: visible; border: none; background: transparent; border-radius: 0; }
  table.schedule { min-width: 0; font-size: 14px; display: block; }
  table.schedule thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.schedule tbody, table.schedule tr, table.schedule td { display: block; width: auto; }
  table.schedule tr {
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
    margin-bottom: 10px; padding: 4px 14px;
  }
  table.schedule td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    text-align: right; white-space: normal; padding: 9px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  table.schedule tr td:last-child { border-bottom: none; }
  table.schedule td::before {
    content: attr(data-label); text-align: left; color: var(--muted);
    font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  }
}
.card h2 { margin-top: 20px; }

/* ======================= ADMIN / back-office =========================== */
/* Back-office chrome is a left vertical sidebar (brand + nav + signed-in user),
   with the page content to its right. Collapses to a top bar below 860px. */
.admin-shell { display: flex; align-items: stretch; min-height: 100vh; }
.admin-sidebar {
  flex: 0 0 236px; width: 236px; box-sizing: border-box;
  background: var(--ink); color: #fff;
  display: flex; flex-direction: column; gap: 4px; padding: 20px 14px;
  position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto;
  box-shadow: var(--shadow-md); z-index: 20;
}
.admin-sidebar .brand { margin: 2px 8px 20px; }
.admin-sidebar .brand-name { color: #fff; }
.admin-sidebar .brand-name span { color: var(--brand); }
.admin-sidebar .brand-mark { box-shadow: none; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
  color: #cdd3dc; text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 9px 12px; border-radius: var(--radius-sm); transition: background .15s ease, color .15s ease;
}
.admin-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.admin-nav a.active { color: #fff; background: rgba(255, 255, 255, .12); box-shadow: inset 3px 0 0 var(--brand); }
.admin-user {
  margin-top: auto; padding-top: 16px; display: flex; flex-direction: column;
  align-items: flex-start; gap: 8px; font-size: 14px; color: #e6e9ee;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.admin-user-name { padding: 0 2px; }
.role-chip {
  background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; padding: 3px 10px;
  border-radius: var(--radius-pill); text-transform: uppercase; letter-spacing: .04em;
}
.admin-main { flex: 1 1 auto; min-width: 0; max-width: 1160px; margin: 0 auto; padding: 32px 40px; }
.admin-main h1 { font-size: 26px; letter-spacing: -.5px; margin: 0 0 6px; font-weight: 800; }
.admin-main h2 { font-size: 17px; margin: 0 0 12px; font-weight: 700; }

@media (max-width: 860px) {
  .admin-shell { display: block; }
  .admin-sidebar {
    width: auto; height: auto; position: sticky; top: 0; align-self: auto;
    flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 12px 16px;
  }
  .admin-sidebar .brand { margin: 0; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .admin-nav a { padding: 6px 10px; }
  .admin-nav a.active { box-shadow: inset 0 -3px 0 var(--brand); }
  .admin-user {
    margin: 0 0 0 auto; padding-top: 0; flex-direction: row; align-items: center;
    gap: 10px; border-top: none;
  }
  .admin-main { max-width: none; margin: 0; padding: 24px 16px; }
}

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px;
  margin: 20px 0;
}
.referral-stats-title { margin: 24px 0 0; font-size: 17px; }
.stat-section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 26px 0 0;
}
.kfs-link { margin: 16px 0; font-size: 14px; }
.kfs-actions { margin-top: 18px; }
/* Space stacked buttons (e.g. Download PDF above ← Back) so they don't sit flush. */
.kfs-actions .btn + .btn { margin-top: 10px; }
/* KFS review screen (OFFER_KFS): acknowledge + accept, or go back to change the amount. */
.kfs-accept { margin-top: 18px; }
.kfs-change { margin-top: 10px; text-align: center; }

/* KFS scroll-gate on the offer screen */
.kfs-gate { margin: 20px 0 6px; }
.kfs-gate-head { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.kfs-scrollbox {
  max-height: 340px; overflow-y: auto; padding: 16px 18px;
  border: 1px solid var(--brand-100); border-radius: var(--radius-lg);
  background: #fff; box-shadow: inset 0 -14px 14px -14px rgba(0,0,0,.14);
  overscroll-behavior: contain;
}
.kfs-scrollbox:focus-visible { outline: none; box-shadow: var(--ring); }
.kfs-scrollbox h2 { margin-top: 20px; font-size: 16px; }
.kfs-scrollbox h3 { margin-top: 16px; font-size: 15px; }
.kfs-scrollbox > :first-child { margin-top: 0; }
.kfs-gate-hint { margin: 10px 0 8px; font-size: 13px; color: var(--muted); }
.kfs-ack { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0 18px; font-size: 14px; }
.kfs-ack input { margin-top: 2px; width: 17px; height: 17px; flex: none; }
.kfs-ack input:disabled + span { color: var(--muted); }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.stat-num { font-size: 28px; font-weight: 800; color: var(--ink); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; font-weight: 500; }
a.stat { text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--brand-100); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 24px;
  box-shadow: var(--shadow); margin: 18px 0;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .detail-grid { grid-template-columns: 1fr; } }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); }
.data-table thead th {
  color: var(--muted); font-weight: 700; background: var(--field-alt);
  border-bottom: 1px solid var(--line); text-transform: uppercase; font-size: 11px; letter-spacing: .04em;
}
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover { background: var(--field-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table a { color: var(--brand-2); font-weight: 700; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

.state-chip {
  display: inline-block; padding: 4px 11px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700;
  background: #eef1f5; color: var(--ink-soft); border: 1px solid var(--line);
}
.state-chip.lg { font-size: 13px; padding: 6px 13px; }
.state-chip.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.state-chip.warn { background: var(--error-bg); color: var(--error); border-color: var(--error-line); }

/* Coarse status buckets on the Applications list: tinted chip + a leading colour
   dot (inherits the chip's text colour) so the bucket is scannable at a glance. */
.state-chip.stage { padding-left: 9px; }
.state-chip.stage::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle; background: currentColor;
}
.state-chip.stage-in_process    { background: #eff4ff; color: #1849a9; border-color: #b2ccff; }
.state-chip.stage-recovery      { background: #f5f3ff; color: #5925dc; border-color: #d9d6fe; }
.state-chip.stage-manual_review { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.state-chip.stage-disbursed     { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.state-chip.stage-closed        { background: #eef1f5; color: var(--ink-soft); border-color: var(--line); }
.state-chip.stage-rejected      { background: var(--error-bg); color: var(--error); border-color: var(--error-line); }

.repay-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.cooloff-banner {
  margin: 18px 0; padding: 14px 16px; border-radius: var(--radius);
  background: var(--brand-50, #eef2ff); border: 1px solid var(--brand-100, #c7d2fe);
}
.cooloff-banner p { margin: 0 0 10px; }

/* Users & Access: employee-provisioning form */
.user-form .field-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px; margin-bottom: 14px;
}
.user-form label { margin-top: 0; }
.data-table td form { margin: 0; }
/* Keep the per-row actions on one line (the table lives in a horizontal-scroll wrapper, so the
   cell grows to fit rather than wrapping Reset / Disable / Delete onto a second row). */
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: nowrap; align-items: center; }
.row-actions form { margin: 0; }
.row-actions .btn { padding: 8px 12px; font-size: 13px; box-shadow: none; white-space: nowrap; }

/* Users & Access: temporary-password confirmation screen */
#creds-panel .field-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px; margin: 14px 0;
}
#creds-panel label { margin-top: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .5px; }
.creds-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.tiny { font-size: 12px; }

.filters { display: flex; gap: 10px; margin: 14px 0 20px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; flex: 1 1 180px; }

/* Audit-log details: compact key=value chips, one per fact */
.audit-kv {
  display: inline-block; margin: 0 5px 3px 0; padding: 2px 7px; font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: #eef1f5; color: var(--ink-soft); border: 1px solid var(--line);
  border-radius: 6px; white-space: nowrap;
}
.pager { display: flex; align-items: center; gap: 14px; margin: 18px 0 4px; }
.pager .disabled { opacity: .45; pointer-events: none; }

.kv { display: grid; gap: 0; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.kv > div:last-child { border-bottom: none; }
.kv dt { color: var(--muted); font-weight: 500; margin: 0; }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.timeline li {
  display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding-left: 18px;
  position: relative;
}
.timeline li::before {
  content: ""; position: absolute; left: 0; top: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 0 3px var(--brand-050);
}
.t-to { font-weight: 600; }

.decision { border-top: 1px solid var(--line); padding: 14px 0; }
.decision:first-of-type { border-top: none; }
.trace { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 5px; font-size: 13px; }
.trace li { padding-left: 24px; position: relative; color: var(--ink-soft); }
.trace li::before { position: absolute; left: 0; font-weight: 800; }
.trace-pass::before { content: "✓"; color: var(--ok); }
.trace-fail::before { content: "✕"; color: var(--error); }
.trace-info::before { content: "•"; color: var(--muted); }

.reject-form { display: flex; gap: 10px; }
.reject-form input { flex: 1; }
.btn.danger { color: var(--error); border-color: var(--error-line); background: #fff; }
.btn.danger:hover { background: var(--error-bg); }

/* credit-review panel */
.review-panel { border: 1px solid var(--brand-100); background: var(--brand-050); }
.review-panel h2 { color: var(--brand-2); }
.review-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-top: 14px; }
.review-form label {
  display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600;
  margin: 0;
}
.review-form input[type="number"] { width: 160px; }
.review-form.reject-form { margin-top: 8px; }
.review-proposal {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px;
  margin: 16px 0 4px;
}
.review-proposal > div {
  background: #fff; border: 1px solid var(--brand-100); border-radius: var(--radius); padding: 14px 16px;
}
.rp-label { display: block; color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.rp-num { font-size: 22px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.rp-num small { font-size: 13px; font-weight: 600; color: var(--muted); }
.review-signals { margin-top: 10px; }
.kv dd.over-cap { color: var(--error); }
.flag-pill {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--error-bg); color: var(--error); border: 1px solid var(--error-line);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.kv.bureau-summary { grid-template-columns: 1fr 1fr; column-gap: 28px; }
@media (max-width: 560px) { .kv.bureau-summary { grid-template-columns: 1fr; } }

/* ========================= application detail page ====================== */
.app-header {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start;
  gap: 18px 32px; padding: 20px 22px; margin: 6px 0 20px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.app-header-main { min-width: 220px; }
.app-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.app-id h1 { margin: 0; }
.app-applicant { margin: 6px 0 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.app-header-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px 24px; margin: 0; flex: 1 1 360px; max-width: 580px;
}
.app-header-facts > div { display: flex; flex-direction: column; gap: 1px; }
.app-header-facts dt {
  color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; margin: 0;
}
.app-header-facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Tabs are hidden until JS enables tab mode; without JS every panel renders stacked (plain scroll). */
.app-tabs .tabs { display: none; }
.app-tabs--on .tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none; background: none; border: none; cursor: pointer; font: inherit; font-weight: 600;
  padding: 10px 16px; margin-bottom: -1px; color: var(--muted);
  border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--ink); background: var(--line-soft); }
.tab.is-active { color: var(--brand-2); border-bottom-color: var(--brand-2); }
.app-tabs--on .tab-panel { display: none; }
.app-tabs--on .tab-panel.is-active { display: block; }

.status-badge.sm { margin-bottom: 0; padding: 3px 10px; font-size: 11px; }
.status-neutral { background: var(--line-soft); color: var(--muted); border-color: var(--line); }

.danger-zone { border: 1px solid var(--error-line); background: var(--error-bg); }
.danger-zone h2 { color: var(--error); }
.danger-zone label.checkbox { margin: 8px 0; }
.danger-zone .btn.danger { margin-top: 12px; }

/* ---------------------------------------------------------------------------
   Reviewer-requested applicant documents (admin detail "Documents from applicant").
   --------------------------------------------------------------------------- */
/* Compact button variant — overrides .btn-primary's full width / top margin. */
.btn-sm { width: auto; margin: 0; padding: 8px 14px; font-size: 14px; box-shadow: none; }

.doc-requests-panel .data-table td { vertical-align: middle; }
/* Accept / Reject / Cancel: one tidy row per request. */
.doc-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-actions .reason-mini {
  flex: 0 1 200px; min-width: 120px; padding: 8px 10px; font: inherit; font-size: 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.doc-actions .reason-mini:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--brand); }

.doc-request-form { margin-top: 18px; }
.doc-request-row { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.doc-request-row input[name="label"] {
  flex: 1; padding: 10px 12px; font: inherit;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.doc-request-row input[name="label"]:focus-visible {
  outline: none; box-shadow: var(--ring); border-color: var(--brand);
}
.checkbox-inline {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 14px; color: var(--ink-soft); font-weight: 600;
}
.doc-request-form-actions { display: flex; gap: 12px; align-items: center; margin-top: 4px; }

/* ---------------------------------------------------------------------------
   Selfie capture (apply/selfie.html + selfie-capture.js). The live camera UI is
   revealed by JS only when getUserMedia is available; otherwise the file input
   shows. No inline styles — the strict CSP forbids them.
   --------------------------------------------------------------------------- */
.selfie-stage {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 3 / 4;
  margin: 0 0 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--field-alt);
  border: 1px solid var(--line);
}
.selfie-video,
.selfie-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.selfie-video { transform: scaleX(-1); }   /* mirror the live view so it feels natural */
.selfie-actions { display: flex; gap: 12px; margin: 0 0 8px; }
