/* =========================================================================
   Borrower Portal – Styles
   Redesigned: Orange brand, dark sidebar, streamlined dashboard
   ========================================================================= */

/* --- Tokens ------------------------------------------------------------ */
:root {
  /* Brand — Orange */
  --brand-700: #CF6409;
  --brand-600: #E8700A;
  --brand-500: #F59E0B;
  --brand-400: #FBBF24;
  --brand-100: #FEF3C7;
  --brand-50:  #FFFBEB;

  /* Neutral */
  --neutral-900: #101828;
  --neutral-700: #344054;
  --neutral-600: #475467;
  --neutral-500: #667085;
  --neutral-300: #D0D5DD;
  --neutral-200: #E4E7EC;
  --neutral-100: #F2F4F7;
  --neutral-50:  #f7f8fa;
  --white:       #FFFFFF;

  /* Semantic */
  --success-700: #067647;
  --success-100: #D1FADF;
  --warning-700: #B54708;
  --warning-100: #FEF0C7;
  --error-700:   #B42318;
  --error-100:   #FEE4E2;
  --info-700:    #1849A9;
  --info-100:    #D1E9FF;

  /* Red (past-due state) */
  --red-700: #B42318;
  --red-600: #D92D20;
  --red-500: #F04438;
  --red-100: #FEE4E2;
  --red-50:  #FEF3F2;

  /* Blue accents */
  --blue-600: #1570EF;
  --blue-200: #B2DDFF;
  --blue-100: #D1E9FF;
  --blue-50:  #EFF8FF;

  /* Sidebar */
  --sidebar-bg-start: #1a1a1a;
  --sidebar-bg-end:   #2d2d2d;
  --sidebar-text: #FFFFFF;
  --sidebar-muted: #9ca3af;

  /* Spacing (8pt scale) */
  --sp-0: 0;
  --sp-05: 4px;
  --sp-1: 8px;
  --sp-15: 12px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 40px;
  --sp-6: 48px;
  --sp-8: 64px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.12);
  --shadow-xl: 0 20px 60px rgba(16,24,40,.16);

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);

  /* Layout */
  --sidebar-w: 280px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--neutral-900);
  background: var(--neutral-50);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }

/* --- App shell --------------------------------------------------------- */
#app-shell {
  min-height: 100vh;
}

#app-shell.auth-mode #sidebar { display: none; }
#app-shell.auth-mode #mobile-header { display: none !important; }
#app-shell.auth-mode #page-footer { display: none; }

/* --- Sidebar (dark theme) ---------------------------------------------- */
#sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 100;
  overflow-y: auto;
  color: var(--sidebar-text);
}

.sidebar-header {
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
}

.brand-logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-orange {
  color: #E8700A;
  font-weight: 700;
}

.brand-pill {
  background: #E8700A;
  color: #fff;
  font-size: 0.7em;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--sidebar-muted);
  margin-top: var(--sp-05);
}

.nav-list {
  list-style: none;
  padding: var(--sp-1) var(--sp-15);
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-15);
  width: 100%;
  padding: var(--sp-15) var(--sp-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms var(--ease);
  text-align: left;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text);
}

.nav-item.active {
  background: rgba(232,112,10,.10);
  color: #E8700A;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: #E8700A;
  border-radius: 0 2px 2px 0;
}

.nav-icon { font-size: 1.125rem; }

.sidebar-footer {
  padding: var(--sp-2) var(--sp-15);
  border-top: 1px solid rgba(255,255,255,.08);
  margin-top: auto;
}

.help-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.help-title { font-weight: 600; font-size: 0.875rem; color: var(--sidebar-text); }
.help-phone { font-size: 0.875rem; color: var(--sidebar-muted); margin-top: var(--sp-05); }
.help-phone a { color: var(--sidebar-muted); }
.help-phone a:hover { color: var(--sidebar-text); text-decoration: none; }
.help-links { font-size: 0.75rem; color: var(--sidebar-muted); margin-top: var(--sp-1); line-height: 1.6; }
.help-links a { color: var(--sidebar-muted); }
.help-links a:hover { color: var(--sidebar-text); text-decoration: none; }

.sidebar-signout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms var(--ease);
  font-family: inherit;
}
.sidebar-signout:hover {
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text);
  border-color: rgba(255,255,255,.25);
}

/* --- Mobile header ----------------------------------------------------- */
#mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 110;
  background: var(--sidebar-bg-start);
  color: #fff;
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
}

#hamburger-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
#hamburger-btn:hover { background: rgba(255,255,255,.1); }

.mobile-brand {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Sidebar overlay --------------------------------------------------- */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 300ms var(--ease);
}
#sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* --- Main content ------------------------------------------------------ */
#main-content {
  padding: var(--sp-4);
  margin-left: var(--sidebar-w);
  max-width: 1200px;
  width: calc(100vw - var(--sidebar-w));
  box-sizing: border-box;
  overflow-x: hidden;
  min-width: 0;
}

.auth-mode #main-content {
  margin-left: 0;
  max-width: 100%;
  width: 100vw;
  padding: 0;
}

/* --- Page header ------------------------------------------------------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-4);
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-width: 0;
}

.page-header > div {
  min-width: 0;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: break-word;
  word-break: break-word;
}

.page-subtitle {
  color: var(--neutral-500);
  font-size: 1rem;
  margin-top: var(--sp-05);
}

/* Back link (used on sub-pages) */
.back-link {
  font-size: 0.875rem;
  color: var(--brand-600);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.back-link:hover { color: var(--brand-700); text-decoration: underline; }

/* ===== DASHBOARD ====================================================== */

/* Loan details card */
.loan-details-card {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.loan-details-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--sp-3);
}

/* Progress bar */
.progress-section {
  margin-bottom: var(--sp-3);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-1);
}

.progress-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--neutral-700);
}

.progress-count {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--neutral-500);
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--neutral-100);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #E8700A, #F59E0B);
  border-radius: 999px;
  transition: width 600ms var(--ease);
}

/* Info box ("What is Smart Home Pay") */
.dash-info-box {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  position: relative;
  overflow: hidden;
  overflow-wrap: break-word;
  margin-bottom: var(--sp-3);
}

.dash-info-box::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #E8700A;
}

.dash-info-box h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--sp-1);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.dash-info-box p {
  font-size: 0.875rem;
  color: var(--neutral-600);
  line-height: 1.6;
}

/* ===== CARDS (general) ================================================= */
.card {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  overflow: hidden;
  min-width: 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-2);
}

.card-header h2 { font-size: 1.25rem; font-weight: 600; }
.card-header h3 { font-size: 1.125rem; font-weight: 600; }
.card-compact { padding: var(--sp-2); }
.card-compact h3 { font-size: 1rem; font-weight: 600; margin-bottom: var(--sp-15); }

.card-info {
  background: var(--info-100);
  border-color: var(--brand-400);
}

/* ===== CONTENT GRID (two-column layout) ================================ */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--sp-3);
  align-items: start;
  min-width: 0;
}

.content-grid > * {
  min-width: 0;
}

.sidebar-cards {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

/* Payment summary sidebar card — blue tint with orange accent */
.payment-summary-card {
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.payment-summary-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: #E8700A;
}

/* ===== TABLES ========================================================== */
.table-container { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: var(--sp-15) var(--sp-2);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neutral-500);
  background: var(--neutral-50);
  border-bottom: 2px solid var(--neutral-200);
}

.data-table td {
  padding: var(--sp-15) var(--sp-2);
  border-bottom: 1px solid var(--neutral-100);
  vertical-align: middle;
}

.data-table tr:hover td { background: var(--neutral-50); }

.text-right { text-align: right; }

.empty-state {
  text-align: center;
  color: var(--neutral-500);
  padding: var(--sp-5) !important;
}

/* --- Mobile history cards (hidden on desktop) -------------------------- */
.history-cards-mobile {
  display: none;
}

.history-card {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
  margin-bottom: var(--sp-15);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-1);
}

.history-card-desc {
  font-weight: 600;
  font-size: 0.875rem;
}

.history-card-amount {
  font-weight: 700;
  font-size: 1rem;
}

.history-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--neutral-500);
}

/* ===== BADGES ========================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-success { background: var(--success-100); color: var(--success-700); }
.badge-warning { background: var(--warning-100); color: var(--warning-700); }
.badge-error { background: var(--error-100); color: var(--error-700); }
.badge-muted { background: var(--neutral-100); color: var(--neutral-700); }
.badge-brand { background: var(--brand-100); color: var(--brand-700); }

/* ===== DETAIL LISTS ==================================================== */
.detail-list { display: flex; flex-direction: column; gap: var(--sp-1); }

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--neutral-100);
  gap: var(--sp-2);
  min-width: 0;
}

.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--neutral-500); flex-shrink: 0; }
.detail-row span:last-child { font-weight: 500; text-align: right; overflow-wrap: break-word; word-break: break-all; min-width: 0; }

/* ===== BUTTONS ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms var(--ease);
  white-space: nowrap;
  font-family: inherit;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: var(--white);
  border-color: var(--brand-700);
  box-shadow: 0 1px 3px rgba(232,112,10,.3);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand-700), #B85A08);
  box-shadow: 0 4px 12px rgba(232,112,10,.35);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(232,112,10,.3);
}

.btn-outline {
  background: var(--white);
  color: var(--neutral-700);
  border-color: var(--neutral-300);
}
.btn-outline:hover:not(:disabled) {
  background: var(--neutral-50);
  border-color: var(--neutral-500);
}

.btn-ghost {
  background: transparent;
  color: var(--neutral-700);
  padding: 6px 12px;
}
.btn-ghost:hover:not(:disabled) { background: var(--neutral-100); }

.btn-sm { font-size: 0.8125rem; padding: 6px 14px; }
.btn-full { width: 100%; }

/* ===== FORMS =========================================================== */
.form-section {
  margin-bottom: var(--sp-3);
}

.form-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--sp-15);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-05);
  margin-bottom: var(--sp-2);
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--neutral-700);
}

.form-input, .form-select, input[type="text"], input[type="date"], input[type="email"], select {
  padding: 10px 14px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--neutral-900);
  background: var(--white);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(232,112,10,.15);
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--neutral-500);
}

.form-error {
  font-size: 0.8125rem;
  color: var(--error-700);
  background: var(--error-100);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  margin-top: var(--sp-1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--neutral-200);
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
}

.toggle-row label { font-weight: 400; }

.toggle-row input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
}

.toggle-row span {
  font-size: 0.8125rem;
  color: var(--neutral-600);
  line-height: 1.5;
}

/* ===== REVIEW SECTION ================================================== */
.review-section {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
}

.review-section h3 { margin-bottom: var(--sp-2); }

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-15);
}

.review-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.review-item span { font-size: 0.8125rem; color: var(--neutral-500); }
.review-item strong { font-size: 1rem; margin-top: 2px; overflow-wrap: break-word; word-break: break-word; }

.review-disclosure {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--neutral-200);
  font-size: 0.8125rem;
  color: var(--neutral-500);
}

/* ===== AUTHORIZATION DISCLOSURE ======================================== */
.auth-disclosure-text {
  font-size: 0.8125rem;
  color: var(--neutral-700);
  line-height: 1.7;
  padding: var(--sp-2);
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  overflow-wrap: break-word;
  word-break: break-word;
  margin-top: var(--sp-2);
}

.auth-disclosure-text + .form-group {
  margin-top: var(--sp-15);
}

/* ===== CONFIRMATION ==================================================== */
.confirmation-container {
  display: flex;
  justify-content: center;
  padding-top: var(--sp-4);
  padding-bottom: var(--sp-4);
}

.confirmation-card {
  max-width: 640px;
  width: 100%;
  text-align: center;
}

.confirmation-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--success-100), #A7F3D0);
  color: var(--success-700);
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-3);
  animation: confirmPop 400ms var(--ease);
  box-shadow: 0 4px 20px rgba(6,118,71,.15);
}

@keyframes confirmPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.confirmation-card h1 { font-size: 1.5rem; margin-bottom: var(--sp-1); }
.confirmation-subtitle { color: var(--neutral-500); margin-bottom: var(--sp-3); }

.confirmation-details {
  text-align: left;
  margin-bottom: var(--sp-3);
}

.confirmation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
}

.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.8125rem; word-break: break-all; }

/* ===== PAYMENT METHODS ================================================= */
.methods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-2);
}

.method-card { transition: box-shadow 200ms var(--ease); }
.method-card:hover { box-shadow: var(--shadow-md); }
.method-default { border-color: var(--brand-400); }

.method-header {
  display: flex;
  align-items: center;
  gap: var(--sp-15);
  margin-bottom: var(--sp-2);
  flex-wrap: wrap;
  min-width: 0;
}

.method-info {
  min-width: 0;
  overflow-wrap: break-word;
}

.method-icon { font-size: 2rem; }

.method-name { font-weight: 600; font-size: 1rem; }
.method-detail { font-size: 0.8125rem; color: var(--neutral-500); }

.method-actions {
  display: flex;
  gap: var(--sp-1);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--neutral-100);
}

/* Method detail card (new detailed single-card layout) */
.method-detail-card {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  overflow: hidden;
  min-width: 0;
}

.method-last-txn {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 0.8125rem;
  color: var(--neutral-500);
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--neutral-100);
}

.method-last-txn .txn-success {
  color: var(--success-700);
  font-weight: 600;
}

/* Need help info box */
.need-help-box {
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  text-align: center;
  overflow-wrap: break-word;
}

.need-help-box h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.need-help-box p {
  font-size: 0.8125rem;
  color: var(--neutral-500);
  line-height: 1.5;
}

.need-help-box a {
  font-weight: 600;
}

/* ===== AUTOPAY ========================================================= */
.autopay-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--neutral-50);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
  min-width: 0;
}

.autopay-status-badge {
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
}

.autopay-active { background: var(--success-100); color: var(--success-700); }
.autopay-inactive { background: var(--neutral-200); color: var(--neutral-500); }

.autopay-next { font-size: 0.9375rem; color: var(--neutral-700); }

.autopay-form { margin-top: var(--sp-2); }

/* Autopay legal links */
.autopay-legal {
  margin-top: var(--sp-2);
  font-size: 0.8125rem;
  color: var(--neutral-500);
}

.autopay-legal a {
  font-weight: 500;
}

/* ===== AUTH SCREENS ===================================================== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top left, var(--brand-50), var(--neutral-50) 50%, #FFFBEB);
  padding: var(--sp-3);
}

.auth-card {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-xl);
  padding: var(--sp-5) var(--sp-4);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  animation: authFadeIn 400ms var(--ease);
}

@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-brand {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--sp-3);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--sp-1);
}

.auth-subtitle {
  color: var(--neutral-500);
  margin-bottom: var(--sp-3);
}

.auth-card form { margin-top: var(--sp-2); }

.token-display {
  background: var(--success-100);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-2);
}

/* ===== PAGE FOOTER ===================================================== */
#page-footer {
  margin-left: var(--sidebar-w);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--neutral-200);
  font-size: 0.6875rem;
  color: var(--neutral-500);
  text-align: center;
  background: var(--white);
  overflow-wrap: break-word;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
  margin-bottom: var(--sp-1);
}

.footer-links a {
  font-size: 0.6875rem;
  color: var(--neutral-500);
  font-weight: 500;
}
.footer-links a:hover {
  color: var(--neutral-900);
  text-decoration: underline;
}

.footer-dot {
  color: var(--neutral-300);
}

.footer-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.625rem;
  color: var(--neutral-500);
}

/* ===== TOAST =========================================================== */
#toast-container {
  position: fixed;
  top: var(--sp-3);
  right: var(--sp-3);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-15) var(--sp-2);
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateX(120%);
  transition: transform 300ms var(--ease);
}

.toast.show { transform: translateX(0); }

.toast-success { border-left: 3px solid var(--success-700); }
.toast-error { border-left: 3px solid var(--error-700); }
.toast-info { border-left: 3px solid var(--info-700); }
.toast-icon { font-size: 1rem; }

/* ===== SKELETONS ======================================================= */
.skeleton-container { display: flex; flex-direction: column; gap: var(--sp-3); }
.skeleton-row { display: flex; gap: var(--sp-2); }

.skeleton {
  background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-50) 50%, var(--neutral-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-title { height: 32px; width: 300px; }
.skeleton-card { height: 120px; flex: 1; }
.skeleton-block { height: 300px; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== SPINNER ========================================================= */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--white);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== UTILITIES ======================================================= */
.text-error { color: var(--error-700) !important; }
.text-success { color: var(--success-700) !important; }
.text-brand { color: var(--brand-600) !important; }
.text-muted { color: var(--neutral-500) !important; }
.link { color: var(--brand-600); text-decoration: underline; cursor: pointer; }

/* ===== DASHBOARD v2 (narrow hero layout) =============================== */

/* Narrow centered column */
.dash-narrow {
  max-width: 576px;
  margin: 0 auto;
}

/* Hero payment card */
.hero-card {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-3);
  position: relative;
  overflow: hidden;
  text-align: center;
  margin-bottom: var(--sp-3);
}
.hero-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
}
.hero-card--normal::before { background: var(--brand-600); }
.hero-card--pastdue::before { background: var(--red-600); }

.hero-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--neutral-500);
  margin-bottom: var(--sp-05);
}

.hero-amount {
  font-size: 3.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: var(--sp-1);
}

.hero-badge-pastdue {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--red-100);
  color: var(--red-700);
  margin-bottom: var(--sp-15);
}

.hero-due-date {
  font-size: 0.875rem;
  color: var(--neutral-500);
  margin-bottom: var(--sp-2);
}

.hero-cta {
  margin-top: var(--sp-1);
}

.hero-phone {
  font-size: 0.8125rem;
  color: var(--neutral-500);
  margin-top: var(--sp-15);
}
.hero-phone a { font-weight: 600; }

.hero-installment {
  font-size: 0.8125rem;
  color: var(--neutral-500);
  margin-top: var(--sp-05);
}

/* Past-due alert banner */
.past-due-alert {
  display: flex;
  align-items: center;
  gap: var(--sp-15);
  padding: var(--sp-2);
  background: var(--red-50);
  border: 1px solid var(--red-100);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-3);
  font-size: 0.875rem;
  color: var(--red-700);
  font-weight: 500;
}

.past-due-alert svg { flex-shrink: 0; }

/* Pulsing red dot for past-due badge */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red-500);
  animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240,68,56,.4); }
  50% { box-shadow: 0 0 0 6px rgba(240,68,56,0); }
}

/* Danger button (red CTA for past-due) */
.btn-danger {
  background: linear-gradient(135deg, var(--red-600), var(--red-700));
  color: var(--white);
  border-color: var(--red-700);
  box-shadow: 0 1px 3px rgba(217,45,32,.3);
}
.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--red-700), #9A1F15);
  box-shadow: 0 4px 12px rgba(217,45,32,.35);
  transform: translateY(-1px);
}
.btn-danger:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(217,45,32,.3);
}

/* Payoff text link */
.payoff-link {
  text-align: center;
  margin-bottom: var(--sp-3);
  font-size: 0.875rem;
}
.payoff-link a {
  font-weight: 600;
  color: var(--brand-600);
}
.payoff-link a:hover { text-decoration: underline; }

/* Section headers (uppercase label) */
.section-header {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--neutral-500);
  margin-bottom: var(--sp-15);
}

/* Loan detail rows (divide-y) */
.loan-detail-rows {
  display: flex;
  flex-direction: column;
}
.loan-detail-rows .detail-row {
  padding: var(--sp-15) 0;
  border-bottom: 1px solid var(--neutral-100);
}
.loan-detail-rows .detail-row:last-child {
  border-bottom: none;
}

/* Dealer card */
.dealer-card {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.dealer-card-header {
  display: flex;
  align-items: center;
  gap: var(--sp-15);
  margin-bottom: var(--sp-2);
}

.dealer-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--neutral-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dealer-card-links {
  display: flex;
  gap: var(--sp-3);
  font-size: 0.875rem;
}
.dealer-card-links a {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

/* ===== AMOUNT / SCHEDULE BUTTON SELECTOR =============================== */
.amount-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.amount-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2) var(--sp-15);
  border: 2px solid var(--neutral-300);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 150ms var(--ease);
  background: var(--white);
  text-align: center;
  font-family: inherit;
  min-height: 80px;
}

.amount-btn .btn-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--neutral-500);
  margin-bottom: 2px;
}

.amount-btn .btn-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--neutral-900);
}

.amount-btn .btn-detail {
  font-size: 0.75rem;
  color: var(--neutral-500);
  margin-top: 2px;
}

.amount-btn.selected {
  border-color: var(--brand-600);
  background: var(--brand-50);
}
.amount-btn.selected .btn-label { color: var(--brand-700); }
.amount-btn.selected .btn-value { color: var(--brand-700); }

.amount-btn:hover:not(.selected) {
  border-color: var(--neutral-500);
  background: var(--neutral-50);
}

/* ===== MAKE PAYMENT EXTRAS ============================================= */

/* Last payment success banner */
.last-payment-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-15);
  padding: var(--sp-2);
  background: var(--success-100);
  border: 1px solid rgba(6,118,71,.15);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-3);
  font-size: 0.875rem;
  color: var(--success-700);
  font-weight: 500;
}

/* Last payment banner — failed (red) variant */
.last-payment-banner--failed {
  display: flex;
  align-items: center;
  gap: var(--sp-15);
  padding: var(--sp-2);
  background: var(--red-50);
  border: 1px solid var(--red-100);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-15);
  font-size: 0.875rem;
  color: var(--red-700);
  font-weight: 500;
}

/* Prominent action callout for failed payments */
.failed-action-callout {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-15);
  padding: var(--sp-2) var(--sp-3);
  background: var(--red-50);
  border: 2px solid var(--red-600);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-3);
  font-size: 0.875rem;
  color: var(--red-700);
  line-height: 1.5;
}

.failed-action-callout svg { flex-shrink: 0; margin-top: 2px; }

.failed-action-callout a {
  font-weight: 700;
  color: var(--red-700);
  text-decoration: underline;
}

/* Phone callout box */
.phone-callout {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-15);
  padding: var(--sp-2);
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  margin-top: var(--sp-2);
  font-size: 0.8125rem;
  color: var(--neutral-600);
}

.phone-callout svg { flex-shrink: 0; margin-top: 2px; }

/* Disclaimer box */
.disclaimer-box {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-15);
  padding: var(--sp-2);
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  margin-top: var(--sp-2);
  font-size: 0.8125rem;
  color: var(--neutral-500);
  line-height: 1.5;
}

.disclaimer-box svg { flex-shrink: 0; margin-top: 2px; }

/* Dealer context box in sidebar */
.dealer-context-box {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-15);
  padding: var(--sp-2);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--neutral-700);
}

.dealer-context-box svg { flex-shrink: 0; margin-top: 2px; }

/* ===== PAYMENT METHODS v2 ============================================== */

/* Blue accent border */
.method-detail-card.method-blue {
  border-color: var(--blue-200);
  border-width: 2px;
}

/* Icon box (48px) */
.method-icon-box {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--neutral-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.method-icon-box svg { color: var(--neutral-600); }

/* Last transaction box */
.method-last-txn-box {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-15) var(--sp-2);
  background: var(--success-100);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--success-700);
  font-weight: 500;
  margin-top: var(--sp-2);
}

.method-last-txn-box svg { flex-shrink: 0; }

/* Text-only danger button */
.btn-text-danger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--red-600);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
}
.btn-text-danger:hover { color: var(--red-700); text-decoration: underline; }

/* ===== AUTOPAY v2 ====================================================== */

/* Inline legal text */
.autopay-simple-legal {
  font-size: 0.75rem;
  color: var(--neutral-500);
  line-height: 1.6;
  margin-top: var(--sp-2);
}

.autopay-simple-legal a { font-weight: 500; }

/* ===== SIDEBAR CLOSE BTN (mobile) ====================================== */
.sidebar-close-btn {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  color: var(--sidebar-muted);
  cursor: pointer;
}
.sidebar-close-btn:hover {
  background: rgba(255,255,255,.15);
  color: var(--sidebar-text);
}

/* ===== HISTORY CARD BADGES (mobile) ==================================== */
.history-card-badges {
  display: flex;
  gap: var(--sp-1);
  margin-bottom: var(--sp-1);
}

/* ===== RESPONSIVE ====================================================== */

/* Tablet: collapse content grid, show mobile header */
@media (max-width: 1024px) {
  #mobile-header { display: flex; }

  #sidebar {
    transform: translateX(-100%);
    transition: transform 300ms var(--ease);
  }
  #sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn { display: flex; }

  #main-content {
    margin-left: 0;
    width: 100vw;
    padding: var(--sp-3);
  }

  #page-footer {
    margin-left: 0;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
  .sidebar-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
  }

}

/* Phone */
@media (max-width: 768px) {
  #main-content {
    padding: var(--sp-2);
  }

  .page-title { font-size: 1.375rem; }

  /* Show mobile history cards, hide desktop table */
  .history-cards-mobile { display: block; }
  .table-container.desktop-only { display: none; }

  .form-row { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: 1fr; }
  .amount-selector { grid-template-columns: 1fr; }

  .hero-amount { font-size: 2.5rem; }

  .sidebar-cards { grid-template-columns: 1fr; }
  .methods-grid { grid-template-columns: 1fr; }

  .auth-card { padding: var(--sp-3); }
}

/* Tablet confirmation fix */
@media (max-width: 640px) {
  .confirmation-actions { flex-direction: column; }
  .confirmation-actions .btn { width: 100%; }
}

/* Small phone */
@media (max-width: 480px) {
  .hero-amount { font-size: 2rem; }
}

/* ===== ANIMATIONS & POLISH ============================================= */

/* Card entrance animation */
.card {
  animation: cardSlideUp 300ms var(--ease);
}

@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Table row stagger animation */
.data-table tbody tr {
  animation: rowSlide 200ms var(--ease) backwards;
}
.data-table tbody tr:nth-child(1) { animation-delay: 0ms; }
.data-table tbody tr:nth-child(2) { animation-delay: 30ms; }
.data-table tbody tr:nth-child(3) { animation-delay: 60ms; }
.data-table tbody tr:nth-child(4) { animation-delay: 90ms; }
.data-table tbody tr:nth-child(5) { animation-delay: 120ms; }

@keyframes rowSlide {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Method card hover lift */
.method-card {
  transition: all 200ms var(--ease);
}
.method-card:hover {
  transform: translateY(-2px);
}

/* Autopay status badge pulse when active */
.autopay-active {
  animation: subtlePulse 3s ease-in-out infinite;
}

@keyframes subtlePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(6,118,71,.15); }
  50% { box-shadow: 0 0 0 6px rgba(6,118,71,0); }
}

/* Custom scrollbar */
#sidebar::-webkit-scrollbar {
  width: 4px;
}
#sidebar::-webkit-scrollbar-track {
  background: transparent;
}
#sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.15);
  border-radius: 2px;
}

/* Selection color */
::selection {
  background: var(--brand-100);
  color: var(--brand-700);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
}

/* Smooth page content transitions */
#main-content > * {
  animation: fadeIn 250ms var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
