
:root{
  --bg:#0b1020;
  --panel:#121a33;
  --panel2:#0f1730;
  --text:#e9eefc;
  --muted:#9aa8c7;
  --border:#243055;
  --primary:#4ea1ff;
  --danger:#ff4e6a;
  --ok:#3bd18a;
  --warn:#ffd166;
  --shadow: 0 12px 30px rgba(0,0,0,0.25);
  --radius:14px;
  --radius-sm:10px;
  --pad:16px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;

  /* Hint to browsers that the app UI is dark.
     This improves native control rendering (notably <select> dropdown lists)
     on Windows where option text can otherwise appear invisible. */
  color-scheme: dark;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--font);
  background: radial-gradient(1200px 800px at 20% 0%, #121a33 0%, #0b1020 45%, #070b17 100%);
  color:var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

a{color:var(--primary); text-decoration:none}
a:hover{text-decoration:underline}

.layout{
  display:flex;
  min-height:100vh;
}

.sidebar{
  width:260px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel2) 100%);
  border-right:1px solid var(--border);
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.brand{
  padding:12px 12px 10px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  background: rgba(255,255,255,0.03);
}
.brand-title{font-weight:800; letter-spacing:0.2px}
.brand-sub{color:var(--muted); font-size:12px; margin-top:2px}

.nav{display:flex; flex-direction:column; gap:8px; margin-top:6px}
.nav-link{
  padding:10px 12px;
  border:1px solid transparent;
  border-radius:var(--radius-sm);
  color:var(--text);
  background: rgba(255,255,255,0.03);
}
.nav-link:hover{border-color:var(--border); text-decoration:none}
.nav-link.active{
  border-color: rgba(78,161,255,0.6);
  background: rgba(78,161,255,0.10);
}

.sidebar-footer{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.userbox{
  padding:12px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background: rgba(255,255,255,0.03);
}
.userbox-name{font-weight:700}
.userbox-role{color:var(--muted); font-size:12px; margin-top:2px}
.userbox-email{color:var(--muted); font-size:12px; margin-top:2px; word-break:break-all}

.main{
  flex:1;
  padding:20px 22px;
}

.topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  margin-bottom:16px;
}
.topbar-left{display:flex; gap:10px; align-items:flex-start}
.topbar-titles{min-width:0}
.page-title{
  margin:0;
  font-size:22px;
  font-weight:800;
}
.page-subtitle{
  color:var(--muted);
  margin-top:4px;
  font-size:13px;
}
.topbar-right .pill{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(59,209,138,0.5);
  background: rgba(59,209,138,0.12);
  color: var(--ok);
  font-size:12px;
  font-weight:700;
}

.content{
  display:block;
}

.kv{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:12px;
}

.card{
  border:1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius:var(--radius);
  padding:var(--pad);
  box-shadow:var(--shadow);
}

.card-header{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:12px;
  margin-bottom:10px;
}
.card-header h2{
  margin:0;
  font-size:16px;
}

.grid{display:grid; gap:14px}
/* Many templates use grid-2/grid-3 without the base .grid class. */
.grid-2{display:grid; gap:14px; grid-template-columns:repeat(2,minmax(0,1fr))}
.grid-3{display:grid; gap:14px; grid-template-columns:repeat(3,minmax(0,1fr))}
.grid-span-2{grid-column: span 2;}
@media (max-width: 1100px){
  .sidebar{width:220px}
  .grid-3{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width: 900px){
  .layout{display:block}

  body.nav-open{overflow:hidden}

  /* Off-canvas sidebar for mobile/tablet */
  .sidebar{
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    width:min(320px, 88vw);
    transform: translateX(-110%);
    transition: transform 0.20s ease;
    z-index:1001;
    overflow-y:auto;
    padding:18px 14px;
    padding-top: calc(18px + env(safe-area-inset-top));
    box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  }
  body.nav-open .sidebar{transform: translateX(0);}

  .main{
    padding:12px;
    padding-top: calc(12px + env(safe-area-inset-top));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .topbar{
    position:sticky;
    top:0;
    z-index:900;
    background: rgba(11,16,32,0.82);
    backdrop-filter: blur(10px);
    padding:10px 0;
  }

  .topbar-right .pill{display:none}

  .grid-2, .grid-3{grid-template-columns:1fr}
}

/* Mobile nav scrim */
.scrim{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.55);
  display:none;
  z-index:1000;
}
body.nav-open .scrim{display:block;}

/* Icon button (hamburger) */
.icon-btn{
  border:1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color:var(--text);
  border-radius:12px;
  width:44px;
  height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  cursor:pointer;
  touch-action: manipulation;
}
.icon-btn:hover{filter:brightness(1.06)}

.nav-toggle{display:none}
.icon-btn-bars{
  position:relative;
  width:18px;
  height:2px;
  background: var(--text);
  border-radius:2px;
  display:block;
}
.icon-btn-bars:before,
.icon-btn-bars:after{
  content:"";
  position:absolute;
  left:0;
  width:18px;
  height:2px;
  background: var(--text);
  border-radius:2px;
}
.icon-btn-bars:before{top:-6px}
.icon-btn-bars:after{top:6px}

@media (max-width: 900px){
  .nav-toggle{display:inline-flex}
}

@media (max-width: 520px){
  .page-title{font-size:18px}
  .card{padding:14px}
  .actions{flex-direction:column; align-items:stretch}
  .actions .btn{width:100%}
}

/* Touch devices: keep tap targets comfortable */
@media (pointer: coarse){
  .btn{min-height:44px}
  .input, .select{min-height:44px}
}

.spacer{height:14px}
.hr{border-top:1px solid var(--border); height:1px}

.muted{color:var(--muted)}
.w-full{width:100%}

.kpi-label{color:var(--muted); font-size:12px}
.kpi-value{font-size:28px; font-weight:900; margin-top:4px}

/* Compact, clickable KPI cards (rep dashboard) */
.kpi-grid{
  display:grid;
  gap:10px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.kpi-card{
  display:block;
  padding:12px 14px;
  text-decoration:none;
  color:inherit;
}
.kpi-card:hover{
  text-decoration:none;
  border-color: rgba(78,161,255,0.6);
  background: rgba(78,161,255,0.08);
}
.kpi-card .kpi-value{font-size:22px}

.table-wrap{overflow:auto}
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width:720px;
}
.table th, .table td{
  padding:10px 10px;
  border-bottom:1px solid rgba(36,48,85,0.7);
  vertical-align:top;
}
.table th{
  text-align:left;
  font-size:12px;
  color:var(--muted);
  font-weight:700;
}
.table tbody tr:hover{
  background: rgba(255,255,255,0.03);
}

/* ------------------------------------------------------------
   Amortization / Quick Quote
   (Mobile polish: reduce text noise + stack actions)
   ------------------------------------------------------------ */

.amort-subtitle-mobile,
.amort-subtitle-details,
.help-mobile{
  display:none;
}

/* KPI grid on the amortization result section */
.amort-kpi-grid{
  display:grid;
  gap:12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1100px){
  .amort-kpi-grid{grid-template-columns: repeat(2, minmax(0, 1fr));}
}

@media (max-width: 360px){
  .amort-kpi-grid{grid-template-columns: 1fr;}
}

@media (max-width: 520px){
  .amort-subtitle-desktop{display:none;}
  .amort-subtitle-mobile{display:block;}
  .amort-subtitle-details{display:block; margin-top:8px;}

  .help-desktop{display:none;}
  .help-mobile{display:block;}

  /* Stack the amortization action buttons for thumb-friendly taps */
  .amort-actions{flex-direction:column; align-items:stretch;}
  .amort-actions .btn{width:100%;}

  /* Make the schedule table easier to read on small screens */
  .amort-table{min-width:560px;}
  .amort-table th, .amort-table td{padding:8px 8px; font-size:12px;}

  /* Reduce card padding a hair on dense screens */
  .amort-page .card{padding:14px;}
}

.amort-subtitle-details summary{
  cursor:pointer;
  color:var(--primary);
  font-weight:800;
}

.amort-subtitle-details summary::-webkit-details-marker{
  display:none;
}

.amort-subtitle-details summary:before{
  content:"ℹ️ ";
}

.status{
  padding:4px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,0.02);
  font-size:12px;
}

/* ------------------------------------------------------------
   Attention helpers ("docs ready" pulses, etc.)
   ------------------------------------------------------------ */

@keyframes pulseGlow {
  0%   { box-shadow: 0 0 0 0 rgba(255,209,102,0.35); }
  70%  { box-shadow: 0 0 0 14px rgba(255,209,102,0.00); }
  100% { box-shadow: 0 0 0 0 rgba(255,209,102,0.00); }
}

.status-pulse{
  border-color: rgba(255,209,102,0.75);
  background: rgba(255,209,102,0.10);
  color: #fff3d1;
  animation: pulseGlow 1.6s infinite;
}

.pill-pulse{
  border-color: rgba(255,209,102,0.75);
  background: rgba(255,209,102,0.10);
  animation: pulseGlow 1.6s infinite;
}

.pill{
  display:inline-block;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,0.02);
  font-size:12px;
  color:var(--text);
}

.form{display:flex; flex-direction:column; gap:10px}
.label{font-size:12px; color:var(--muted); font-weight:700}
.input, .textarea, .select{
  width:100%;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(0,0,0,0.25);
  color:var(--text);
  font-size:16px;
}
.textarea{min-height:92px; resize:vertical}
.select{height:40px; color-scheme: dark;}

/* Some browsers render the dropdown list with a light background even in a
   dark themed app. Ensure option text is readable. */
.select option{background-color: var(--panel); color: var(--text);}

.filters{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.filters .input{max-width:420px}
.filters .select{max-width:240px}

.checkbox{
  display:flex;
  gap:8px;
  align-items:center;
  font-size:12px;
  color:var(--muted);
  font-weight:700;
  padding:0 4px;
}

.btn{
  border:1px solid transparent;
  border-radius:12px;
  padding:10px 12px;
  color:var(--text);
  cursor:pointer;
  font-weight:800;
  letter-spacing:0.2px;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}
.btn:hover{filter:brightness(1.06)}
.btn-primary{
  background: rgba(78,161,255,0.18);
  border-color: rgba(78,161,255,0.6);
}
.btn-secondary{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}
.btn-danger{
  background: rgba(255,78,106,0.18);
  border-color: rgba(255,78,106,0.6);
}

/* Back-compat with older templates that use "btn primary" etc. */
.btn.primary{background: rgba(78,161,255,0.18); border-color: rgba(78,161,255,0.6);}
.btn.secondary{background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12);}
.btn.danger{background: rgba(255,78,106,0.18); border-color: rgba(255,78,106,0.6);}
.btn.small{padding:6px 10px; font-size:12px; border-radius:10px}

.btn-sm{
  padding:6px 10px;
  font-size:12px;
  border-radius:10px;
}

.inline-form{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.inline-form .input{min-width:220px}
.inline{display:inline}

.list{
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.list li{
  padding:10px;
  border:1px solid rgba(36,48,85,0.7);
  border-radius:12px;
  background: rgba(0,0,0,0.18);
}

/* Highlight list items that need attention (e.g., CS results awaiting rep). */
.list li.attn{
  border-color: rgba(255,209,102,0.65);
  background: rgba(255,209,102,0.07);
}

/* Highlight table rows that need attention (e.g., CS results awaiting rep). */
.table tbody tr.attn-row{
  background: rgba(255,209,102,0.06);
}
.table tbody tr.attn-row:hover{
  background: rgba(255,209,102,0.10);
}

/* Preserve newlines for "email-style" notes (Admin -> Rep, checklists, etc.) */
.note-body{
  white-space: pre-wrap;
}

.deal-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
}
.deal-id{font-size:18px; font-weight:900}
.deal-customer{font-size:15px; font-weight:800; margin-top:4px}
.deal-meta{text-align:right}
.status-badge{
  display:inline-block;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(78,161,255,0.55);
  background: rgba(78,161,255,0.10);
  font-weight:900;
}

/* Allow the same pulse styling on the larger status badge. */
.status-badge.status-pulse{
  border-color: rgba(255,209,102,0.75);
  background: rgba(255,209,102,0.10);
  color: #fff3d1;
  animation: pulseGlow 1.6s infinite;
}

.actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.alert{
  padding:10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(0,0,0,0.25);
}
.alert-success{
  border-color: rgba(59,209,138,0.6);
  background: rgba(59,209,138,0.12);
  color: #d6ffe9;
}
.alert-warn{
  border-color: rgba(255,209,102,0.65);
  background: rgba(255,209,102,0.10);
  color: #fff3d1;
}
.alert-error{
  border-color: rgba(255,78,106,0.6);
  background: rgba(255,78,106,0.12);
  color: #ffdbe2;
}

/* Auto-dismiss success "toast" messages (used on dashboard after create/complete actions). */
.alert.fade-out{
  opacity: 0;
  transition: opacity 0.6s ease;
}

.callout{
  padding:12px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(0,0,0,0.18);
}

.login-body{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
}
.login-card{
  width:420px;
  max-width:100%;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background: rgba(255,255,255,0.03);
  padding:18px;
  box-shadow:var(--shadow);
}
.login-title{font-weight:900; font-size:20px}
.login-subtitle{color:var(--muted); margin-top:4px; margin-bottom:12px}
.login-footer{margin-top:12px; color:var(--muted)}

/* --- Credit Package Wizard --- */
.btn.small{padding:6px 10px; font-size:12px}

.card.subtle{
  background: rgba(255,255,255,0.03);
  border-color: var(--border);
}

/* Template sometimes calls this wizard-steps; support both. */
.wizard-tabs, .wizard-steps{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:10px 0 16px 0;
}

.wiz-tab{
  border:1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  padding:6px 10px;
  border-radius:999px;
  cursor:pointer;
  font-size:13px;
}

.wiz-tab.active{
  border-color: rgba(78,161,255,0.9);
  background: rgba(78,161,255,0.10);
  font-weight:800;
}

.wiz-panel h3{margin-top:0}

.wiz-nav{
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin-top:14px;
}

/* --- Modal (used for lender / Equifax portals) --- */
.modal{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:1000;
}
.modal.hidden{display:none;}
.modal-content{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  width:min(1100px, 100%);
  max-height:90vh;
  overflow:hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.50);
}
.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
}
.modal-title{font-weight:900;}
.modal-body{padding:0;}
.modal-iframe{
  width:100%;
  height:80vh;
  border:0;
  display:block;
  background:#fff;
}
