@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap');

/* =========================================
   1. GLOBAL LAYOUT & TYPOGRAPHY
   ========================================= */
body {
  background: #f6f7fb;
  font-family: 'Montserrat', Arial, sans-serif;
  margin: 0;
  color: #1e2633;
}

h1, h2, h3, h4 { color: #0c2340; font-weight: 600; }
h1 { text-align: center; margin-bottom: 20px; line-height: 1.2; }
h2 { margin-top: 24px; margin-bottom: 16px; }
h3 { margin-top: 24px; margin-bottom: 10px; }
h4 { margin-top: 10px; margin-bottom: 8px; }

/* =========================================
   2. LOOKUP CONTAINER (Top Bar)
   ========================================= */
.lookup-container {
  max-width: 950px;
  margin: 20px auto 10px auto;
  padding: 15px;
  background-color: #e9ecef;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(16, 32, 61, 0.08);
  
  /* Flexbox Layout */
  display: flex;
  justify-content: space-between; /* Buttons Left, Status Right */
  align-items: flex-end; /* Aligns buttons to the bottom of the input boxes */
  flex-wrap: wrap;
  gap: 15px;
}

/* Left Side: Buttons */
.lookup-buttons {
    display: flex;
    gap: 10px;
}

#lastModifiedDisplay{
  display:block;
  margin-top:2px;
}

#caseLabelDisplay{
  display:block;
  margin-top:0;
  text-align:right;
  font-size: inherit;
  opacity: 0.9;
}

#lenderLabelDisplay{
  display:block;
  margin-top:2px;
  text-align:right;
  font-size: inherit;
  opacity: 0.9;
}

.date-created-block,
.date-modified-block{
  display:flex;
  flex-direction:column;
}

.date-modified-block{
  align-items:flex-end;
}

#duplicateIntakeBtn.duplicate-btn{
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.lookup-results-table td:nth-child(3) {
  font-weight: 600;
}

/* Right Side: Lead Status Inputs */
.lead-status-container {
  display: flex;
  gap: 15px;
  align-items: center;
}

.lead-status-field {
  display: flex;
  flex-direction: column;
  min-width: 160px;
}

.lead-status-field label {
  margin: 0 0 4px 0;
  font-size: 0.85em;
  font-weight: 600;
  color: #0c2340;
}

.lead-status-field select {
  width: 100%;
  margin-top: 0;
  padding: 8px;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
}

/* Hidden Old Top Bar */
.top-bar {
  display: none; 
}

/* =========================================
   3. NAVIGATION
   ========================================= */
.nav-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 26px;
  margin-bottom: 22px;
  padding-left: 24px;
  padding-right: 24px;
}

.floating-nav {
  display: flex;
  justify-content: center;
  background: #0c2340cc;
  border-radius: 20px;
  box-shadow: 0 6px 18px rgba(16,32,61,0.10);
  padding: 14px 36px;
  max-width: 950px;
  margin: 0 auto;
}

.floating-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.floating-nav li {
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
  font-size: 1.06rem;
}

.floating-nav li.active, .floating-nav li:hover {
  color: #ffb700;
  text-decoration: underline;
}

/* =========================================
   4. MAIN FORM CONTAINER & INPUTS
   ========================================= */
.container {
  max-width: 760px;
  margin: 0 auto 32px auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(16, 32, 61, 0.14);
  padding: 38px 36px 34px 36px;
  position: relative;
  z-index: 50;
}

.date-info-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    color: #6e7786;
    font-size: 0.9em;
    font-weight: 500;
}

label { display: block; margin: 16px 0 6px 0; font-weight: 500; }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  margin-top: 5px;
  background: #fafdff;
  font-size: 1rem;
  font-family: inherit;
  transition: border 0.2s, background-color 0.2s;
  box-sizing: border-box;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #0c2340;
}

input:focus, select:focus, textarea:focus {
  border-color: #ffb700;
  outline: none;
}

input:disabled, select:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

input[readonly] { background: #e9ecef; color: #6e7786; cursor: not-allowed; }

hr.section-divider {
    border: none;
    border-top: 1px solid #d1d5db;
    margin: 30px 0 10px 0;
}

/* Address Grouping */
.address-fields { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.address-fields > * { flex: 1 1 40%; min-width: 120px; }

/* Buttons */
button, .submit-btn, .save-btn, .add-owner-btn, .waiver-btn {
  padding: 12px 28px;
  background: #0c2340;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.08rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover, .submit-btn:hover, .save-btn:hover, .add-owner-btn:hover, .waiver-btn:hover {
  background: #ffb700;
  color: #0c2340;
}

.add-owner-btn, .waiver-btn {
  background: #fff;
  color: #0c2340;
  border: 2px solid #0c2340;
  margin: 10px 0 14px 0;
  font-size: 1rem;
  padding: 8px 20px;
}

.add-owner-btn:hover, .waiver-btn:hover { background: #0c2340; color: #fff; }
.waiver-btn { margin-left: 8px; }

.form-navigation {
  margin-top: 30px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.final-actions-container {
    margin-top: 20px;
    display: none;
}
.form-section[style*="display: block;"] .final-actions-container {
    display: block;
}
.final-actions-container .action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin: 20px 0;
}
#pdfBtn { background: #6c757d; }
#pdfBtn:hover { background: #5a6268; color: #fff; }
#generateDocBtn { background: #17a2b8; }
#generateDocBtn:hover { background: #138496; color: #fff; }
#generateDocsBtn { background: #17a2b8; }
#generateDocsBtn:hover { background: #138496; color: #fff; }
#finalSaveBtn { background: #0c2340; color: #fff; }
#finalSaveBtn:hover { background: #ffb700; color: #0c2340; }

/* =========================================
   Document Generation Modal
   ========================================= */
.docgen-modal-content { max-width: 520px; }
.docgen-subtitle { margin-top: -6px; color: #6e7786; }
.docgen-options { margin-top: 14px; display: grid; gap: 10px; }
.docgen-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e6e8ee;
  border-radius: 10px;
  background: #fbfcff;
}
.docgen-option input { transform: scale(1.05); }
.docgen-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }

/* E-Sign row */
.docgen-esign-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:14px;
  padding:12px 14px;
  border:1px solid #e1e5eb;
  border-radius:12px;
  margin-top:12px;
  background:#fbfcfe;
  text-align:left;
}
.docgen-esign-title{ font-weight:700; }
.docgen-esign-sub{ font-size:0.92rem; opacity:0.8; margin-top:2px; }

/* Toggle switch */
.docgen-switch{ position:relative; display:inline-block; width:52px; height:30px; }
.docgen-switch input{ opacity:0; width:0; height:0; }
.docgen-slider{
  position:absolute; cursor:pointer; inset:0;
  background:#cfd6df;
  transition:.2s;
  border-radius:999px;
}
.docgen-slider:before{
  position:absolute; content:"";
  height:24px; width:24px; left:3px; top:3px;
  background:#fff; transition:.2s;
  border-radius:50%;
  box-shadow:0 2px 10px rgba(0,0,0,.12);
}
.docgen-switch input:checked + .docgen-slider{ background:#0cb654; }
.docgen-switch input:checked + .docgen-slider:before{ transform:translateX(22px); }

/* =========================================
   5. OWNERS TABLE
   ========================================= */
#ownersDiv { margin-bottom: 18px; }
.owners-table { width: 100%; border-collapse: collapse; }
.owners-table thead th {
  font-weight: 600;
  color: #0c2340;
  background: #f6f7fb;
  padding: 8px 4px;
  text-align: left;
}
.owners-table tbody td { padding: 4px 2px; vertical-align: middle; }
.owners-table .remove-x {
  color: #e0412f;
  cursor: pointer;
  font-weight: 900;
  font-size: 1.2rem;
  transition: color 0.16s;
  text-align: center;
  padding: 0 8px;
}
.owners-table .remove-x:hover { color: #0c2340; }

/* =========================================
   6. PAYMENT & COST SECTIONS
   ========================================= */
.payment-row { display: flex; gap: 18px; margin: 12px 0; align-items: center; }
.payment-row label { flex: 1 1 32%; margin: 0; }
.payment-row .currency-field { display: flex; align-items: center; flex: 1 1 60%; }
.currency-field .currency-symbol { font-size: 1.1em; color: #888; margin-right: 6px; }
.currency-input { text-align: right; }

/* Quick highlight for missing fields */
.field-missing { outline: 3px solid #ffb700 !important; border-radius: 6px; }

.payment-row.multi-field-row { align-items: flex-end; gap: 12px; }
.multi-field-row .field-group { flex: 1 1 33%; min-width: 0; }
.multi-field-row .field-group label { text-align: center; }
.multi-field-row #downPayment, .multi-field-row #monthlyPayment { text-align: left; }
.multi-field-row #installments { text-align: center; }

.payment-row input[type="number"] { -moz-appearance: textfield; }
.payment-row input[type="number"]::-webkit-outer-spin-button,
.payment-row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.label-with-button { display: flex; align-items: center; justify-content: space-between; }
.calc-btn {
    padding: 4px 8px;
    font-size: 1rem;
    line-height: 1;
    background: #e9ecef;
    color: #0c2340;
    border: 1px solid #ced4da;
    border-radius: 6px;
}
.calc-btn:hover { background: #d1d5db; color: #0c2340; }

.payment-details-row { display: flex; align-items: flex-end; gap: 12px; margin-top: 10px; }
.payment-details-row .field-group { flex: 1; min-width: 0; }
.payment-details-row .payment-method-group { flex: 0 1 180px; }
.payment-details-row .collected-group { flex: 0 0 auto; padding-bottom: 10px; }

.payment-warning {
    background-color: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 8px;
    padding: 10px 15px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #8a6d3b;
    font-weight: 500;
    font-size: 0.95em;
}
.payment-warning .warning-icon { font-size: 1.2em; }

#costBreakdown {
    font-family: 'Courier New', Courier, monospace;
    background-color: #fafdff;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 16px;
    font-size: 0.95em;
    line-height: 1.6;
}
#costBreakdown .breakdown-item { display: flex; justify-content: space-between; }
#costBreakdown .breakdown-total { font-weight: bold; border-top: 1.5px solid #d1d5db; margin-top: 8px; padding-top: 8px; }

/* Accordion */
.details-accordion-item { margin-bottom: 10px; border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; }
.details-accordion-header {
    background-color: #f6f7fb;
    padding: 12px 15px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.details-accordion-header::after { content: '+'; font-size: 1.5em; font-weight: bold; transition: transform 0.3s; }
.details-accordion-header.active::after { transform: rotate(45deg); }
.details-accordion-content {
    padding: 0 15px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}
.details-accordion-content ul { list-style-type: disc; padding-left: 20px; }
.details-accordion-content li { margin-bottom: 8px; }

/* Checkboxes & Plans */
.plan-item, .plan-item-complex {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px;
    border: 1.5px solid #e1e5eb;
    border-radius: 8px;
    margin-bottom: 12px;
}
.plan-item-complex { justify-content: space-between; }
.checkbox-label { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; margin: 0; }
.plan-note { font-size: 0.9em; color: #6e7786; margin-top: -8px; margin-bottom: 18px; text-align: left; padding-left: 5px; }
.settlor-select { width: auto; flex-grow: 0.5; }

.calculate-link {
    flex-basis: 15%;
    text-align: right;
    font-size: 0.9em;
    font-weight: 600;
    color: #0c2340;
    text-decoration: none;
    transition: color 0.2s;
}
.calculate-link:hover { color: #ffb700; }
#openCalculatorLink.calculate-link { display: block; text-align: right; margin-top: 4px; margin-bottom: 10px; }

/* =========================================
   7. UPLOAD SECTION
   ========================================= */
#uploadGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.upload-section-header {
    grid-column: 1 / -1; 
    text-align: left;
    font-size: 1.2em;
    font-weight: 600;
    color: #0c2340;
    margin-top: 20px;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 2px solid #e9ecef;
}

.upload-item {
    background-color: #fafdff;
    border: 1.5px dashed #d1d5db;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s;
}

.upload-item h4 {
    margin: 0 0 10px 0;
    font-weight: 500;
    font-size: 1rem;
    color: #1e2633;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.upload-info-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: #6c757d;
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    font-weight: bold;
    cursor: help;
    font-family: 'Courier New', Courier, monospace;
}

.upload-item .upload-subcategory-select { width: 100%; margin-top: 8px; margin-bottom: 4px; }

.upload-btn {
    width: 100%;
    margin-top: 10px;
    background: #fff;
    color: #0c2340;
    border: 2px solid #0c2340;
    font-size: 0.9rem;
    padding: 8px 16px;
}
.upload-btn:hover { background: #0c2340; color: #fff; }
.upload-btn:disabled { background-color: #ced4da; border-color: #ced4da; cursor: not-allowed; }

.upload-item.drag-over {
    background-color: #e3f2fd; /* Light blue background */
    border-color: #2196f3;     /* Blue border */
    border-style: solid;
    transform: scale(1.02);
    transition: all 0.2s ease;
}

.upload-item .upload-status {
    font-size: 2rem;
    color: #d1d5db;
    transition: color 0.3s;
    height: 32px;
    line-height: 32px;
}
.upload-item .upload-status.completed { color: #0cb654; }

.file-list {
    font-size: 0.85em;
    color: #333;
    margin-top: 8px;
    text-align: left;
    width: 100%;
    word-break: break-word;
}
.file-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f0f4f8;
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 4px;
}
.file-list-item .file-name { flex-grow: 1; }
.remove-file {
    color: #e0412f;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.2em;
    padding-left: 10px;
    transition: color 0.2s;
}
.remove-file:hover { color: #0c2340; }

.temp-folder-link-container { text-align: center; margin-top: 10px; margin-bottom: 20px; }
.temp-folder-link {
    color: #0c2340;
    font-weight: 600;
    text-decoration: none;
    font-size: 1rem;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}
.temp-folder-link:hover { background-color: #f6f7fb; text-decoration: underline; }

/* =========================================
   8. MODALS (General)
   ========================================= */
.modal {
  position: fixed;
  z-index: 150; 
  left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(25, 35, 50, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal-content {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 32px rgba(18,34,60,0.22);
  padding: 34px 32px 24px 32px;
  max-width: 540px;
  width: 90%;
  text-align: center;
  position: relative;
}
.close {
  position: absolute;
  right: 15px; top: 10px;
  font-size: 2.2em;
  color: #aaa;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: color 0.16s;
}
.close:hover { color: #e0412f; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e1e5eb;
}
.modal-footer-btn { padding: 10px 24px; font-size: 1rem; font-weight: 600; }
.cancel-btn { background-color: #6c757d; }
.cancel-btn:hover { background-color: #5a6268; color: #fff; }
.load-btn { background-color: #0cb654; }
.load-btn:hover { background-color: #00a244; }
.load-btn:disabled { background-color: #ced4da; cursor: not-allowed; }

/* =========================================
   9. LOOKUP MODAL SPECIFICS
   ========================================= */
.lookup-modal-content {
    max-width: 800px;
    width: 95%;
    text-align: left;
}
.lookup-modal-content h3, .lookup-modal-content h4 { text-align: center; }
.lookup-search-criteria {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    margin-bottom: 15px;
}
.lookup-field label { margin-top: 5px; margin-bottom: 2px; }
.lookup-search-btn { display: block; margin: 15px auto 0 auto; width: 200px; }

#lookupModalResults {
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 8px;
    background-color: #fafdff;
}
.lookup-results-table { width: 100%; border-collapse: collapse; }
.lookup-results-table th, .lookup-results-table td {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid #e1e5eb;
}
.lookup-results-table th { font-weight: 600; background-color: #f6f7fb; }
.lookup-results-table tbody tr:hover { background-color: #e9ecef; }
.lookup-results-table td:first-child { width: 40px; text-align: center; }
.lookup-results-spinner { display: flex; justify-content: center; align-items: center; height: 100%; }

/* --- UPDATED: TOOLTIP FIX FOR SEARCH RESULTS --- */

/* 1. Ensure the container has extra scrollable space and more height */
#lookupModalResults {
    max-height: 450px !important;    /* Increased from 300px for better visibility */
    padding-bottom: 100px !important; /* Crucial: Adds space at the bottom to scroll into */
    position: relative;
}

.lookup-results-table tr {
    position: relative; /* Anchor for the tooltip */
    cursor: pointer;
}

.lookup-tooltip {
    display: none; /* Hidden by default */
    position: absolute;
    background-color: #333;
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    width: 220px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    pointer-events: none;
    line-height: 1.4;
    
    /* DEFAULT POSITION: Down and to the right */
    top: 100%; 
    left: 20px; 
    margin-top: 5px;
}

/* Show tooltip on hover */
.lookup-results-table tr:hover .lookup-tooltip {
    display: block;
}

/* 2. SMART FLIP: For the last 3 rows, show tooltip ABOVE the row to prevent cutoff */
/* FIX: Added :not(:nth-child(-n+2)) so the 1st and 2nd rows never flip up, preventing top-cutoff */
.lookup-results-table tbody tr:nth-last-child(-n+3):not(:nth-child(-n+2)) .lookup-tooltip {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 10px;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.3); /* Reverse shadow direction */
}

.lookup-tooltip strong {
    color: #ffb700; 
    font-weight: 600;
}

.lookup-tooltip div {
    margin-bottom: 4px;
}

/* =========================================
   10. PAYMENT MODAL SPECIFICS
   ========================================= */
.payment-modal-content {
    max-width: 680px;
    text-align: left;
    max-height: 90vh;
    overflow-y: auto;
}
.payment-modal-content > input,
.payment-modal-content > select,
.payment-modal-content > .address-fields,
.payment-modal-content > .prefill-options,
.payment-modal-content > .radio-group,
.payment-modal-content > hr { margin-bottom: 12px; }
.payment-modal-content h3 { text-align: center; }
.payment-modal-content h4 { margin-top: 20px; }
.payment-modal-content .modal-footer { justify-content: center; }

.prefill-options {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: #f6f7fb;
    padding: 15px;
    border-radius: 8px;
}
.prefill-options .prefill-field { flex: 1 1 250px; }
.prefill-options .prefill-field label { margin-top: 0; margin-bottom: 4px; }
.prefill-options .checkbox-field { flex: 1 1 auto; padding-bottom: 12px; white-space: normal; }
.prefill-options .checkbox-field label { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }

.radio-group { display: flex; gap: 20px; }
.radio-group label { margin: 0; display: flex; align-items: center; gap: 6px; }

.card-type-selector { display: flex; gap: 10px; margin-bottom: 10px; }
.card-type-selector span { opacity: 0.5; transition: opacity 0.2s; }
.card-type-selector span.active { opacity: 1; }

#paymentModalButtons { gap: 10px; }
#paymentModalButtons button { background-color: #17a2b8; }
#paymentModalButtons button:hover { background-color: #138496; color: #fff; }

.payment-modal-content .address-fields { display: flex; gap: 12px; margin-bottom: 12px; }
.payment-modal-content .address-fields > * { flex: 1 1 auto; min-width: 0; }

/* =========================================
   10b. ADDRESS MODAL
   ========================================= */

#addressRecommendationModal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.address-recommendation-modal-content {
    max-width: 620px;
    width: 92%;
    text-align: left;
}

.address-recommendation-modal-content h3 {
    text-align: center;
    margin-bottom: 12px;
}

.recommended-address-box {
    margin: 14px 0 16px 0;
    padding: 14px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    background: #fafdff;
    font-weight: 600;
    color: #0c2340;
    line-height: 1.5;
    white-space: normal;
}

/* =========================================
   11. HELPERS & UTILITIES
   ========================================= */
.matter-helper {
    background-color: #fafdff;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 16px;
    margin-top: 1rem;
}
.matter-helper h3 { margin-top: 0; }

.validation-container {
    margin-top: 5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}
.validate-btn {
    background: #fff;
    color: #0c2340;
    border: 2px solid #0c2340;
    padding: 6px 16px;
    font-size: 0.9rem;
    margin-right: 10px;
}
.validate-btn:hover { background: #0c2340; color: #fff; }
.validation-result { font-weight: 600; font-size: 0.9rem; }
.validation-result.success { color: #0cb654; }
.validation-result.error { color: #e0412f; }

.label-with-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    position: relative;
}
.label-with-link label { margin: 0; }
.cslb-link {
    font-size: 0.9em;
    text-decoration: none;
    white-space: nowrap;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.calculator-fields { text-align: left; margin: 20px 0; }
.calculator-fields label { margin-top: 10px; }

/* =========================================
   12. LOADING ANIMATION
   ========================================= */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Ensure it's on top of everything */
}
.loader-spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #0c2340;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* =========================================
   13. ERROR MODAL
   ========================================= */
/* Highlight missing fields in red */
.field-error {
    border: 2px solid #e0412f !important;
    background-color: #fff1f0 !important;
}

/* Modal Error List Styling */
#errorList {
    text-align: left;
    margin: 20px 0;
    padding-left: 20px;
    color: #e0412f;
}

#errorList li {
    margin-bottom: 8px;
    font-weight: 500;
}
/* =========================================
   14. Uploads CSS
   ========================================= */
/* New status for Flow B uploads */
.file-list-item.uploading {
    opacity: 0.6;
    font-style: italic;
    border-left: 3px solid #ffb700;
}
.file-list-item.success {
    border-left: 3px solid #0cb654;
}

/* =========================================
   KLARNA (Link-based) ADD-ON
   ========================================= */
#paymentModalButtons #applyWithKlarnaBtn {
  background-color: #6f42c1;
}
#paymentModalButtons #applyWithKlarnaBtn:hover {
  background-color: #5b34a1;
  color: #fff;
}
#klarnaLinkInput {
  font-family: inherit;
}


/* =========================================
   KLARNA BUYING POWER (embedded section)
   ========================================= */
.klarna-buyingpower{
  border: 1.5px solid #e1e5eb;
  border-radius: 14px;
  padding: 16px 16px;
  background: #fafdff;
}
.klarna-buyingpower .klarna-placement-wrap{
  margin-top: 10px;
  padding: 12px;
  border: 1.5px dashed #d1d5db;
  border-radius: 12px;
  background: #ffffff;
}
.klarna-buyingpower input[type="text"]{
  background: #fff;
}
.klarna-buyingpower #klarnaEpayUrl{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
}


/* ================================
   Klarna Buying Power (Embedded Widget)
   ================================ */
.klarna-embed-wrap{
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.75);
}
.klarna-embed-note{
  font-size: 0.95rem;
  color: #6e7786;
  margin-bottom: 10px;
}
.klarna-embed-status{
  font-weight: 600;
  margin-bottom: 10px;
}
.klarna-payments-box{
  min-height: 160px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
}
.klarna-embed-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top: 12px;
}
.klarna-btn-primary{
  background: #0a1f3f;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
}
.klarna-btn-secondary{
  background: #4b5563;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
}

/* ================================
   Affirm Link Modal
   ================================ */

#paymentModalButtons #applyWithAffirmBtn {
  background-color: #1b6ef3;
}
#paymentModalButtons #applyWithAffirmBtn:hover {
  background-color: #1557c2;
  color: #fff;
}
#affirmLinkInput {
  font-family: inherit;
}

/* =========================================
   Packet Review Modal
   ========================================= */
.packet-review-modal-content{
  width: min(96vw, 1320px);
  max-width: 1320px;
  height: min(92vh, 940px);
  text-align: left;
  padding: 22px 22px 18px 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.packet-review-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
  padding-right:36px;
  flex: 0 0 auto;
}

.packet-review-header h3{
  margin:0 0 6px 0;
  text-align:left;
}

.packet-review-subtitle{
  margin:0;
  color:#6e7786;
}

.packet-review-status{
  margin-top:8px;
  font-size:13px;
  color:#64748b;
}

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

.packet-review-body{
  margin-top:16px;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.packet-preview-frame{
  width:100%;
  height:100%;
  min-height:72vh;
  border:1px solid #d1d5db;
  border-radius:12px;
  background:#ffffff;
  display:block;
}

.packet-renderer-bridge{
  position:fixed;
  left:-9999px;
  top:-9999px;
  width:1px;
  height:1px;
  border:0;
  opacity:0;
  pointer-events:none;
}

#packetReviewEsignBtn[disabled],
#packetReviewPrintBtn[disabled],
#packetReviewRefreshBtn[disabled],
#packetReviewCloseBtn[disabled]{
  background:#ced4da;
  cursor:not-allowed;
  color:#1e2633;
}


/* ===== Requested visual updates ===== */
.upload-item.required-support {
  border-color: #c92828;
  background: #fff8f8;
}
.upload-item.required-support h4 {
  color: #9f2323;
}
.upload-item.required-support .upload-btn {
  border-color: #9f2323;
}

.upload-item.completed {
  border-color: #139c4b !important;
  background: #f3fff7 !important;
}
.upload-item.completed h4,
.upload-item.completed .upload-status.completed {
  color: #139c4b !important;
}
.upload-item.completed .upload-btn {
  border-color: #139c4b !important;
}

.modern-toggle {
  position: relative;
  display: inline-flex;
  width: 64px;
  height: 34px;
  align-items: center;
}
.modern-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.modern-toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d1d5db;
  transition: .2s ease;
  box-shadow: inset 0 0 0 1px rgba(12,35,64,.08);
}
.modern-toggle-slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: #fff;
  transition: .2s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.modern-toggle input:checked + .modern-toggle-slider {
  background: #16a34a;
}
.modern-toggle input:checked + .modern-toggle-slider::before {
  transform: translateX(30px);
}
.collected-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
}

.collected-script-modal-content {
  max-width: 720px;
  text-align: left;
}
.collected-script-intro {
  color: #6e7786;
  margin-top: -4px;
}
.collected-script-body {
  border: 1px solid #e5e7eb;
  background: #fbfcff;
  border-radius: 12px;
  padding: 18px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.otp-method-buttons,
.rp-method-buttons {
  display: flex;
  gap: 10px;
  margin: 8px 0 14px;
}
.method-btn {
  min-width: 120px;
}
.method-btn.selected,
.otp-method-buttons .method-btn.selected,
.rp-method-buttons .method-btn.selected {
  background: #0c2340;
  color: #fff;
  border-color: #0c2340;
}

#leadCoordinatorRow {
  margin-top: 10px;
}

.packet-preview-frame {
  width: 100%;
  min-height: 70vh;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
}

/* =========================================
   Tools Modal
   ========================================= */

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  border: 1px solid #d7dde8;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.faq-question {
  width: 100%;
  border: 0;
  background: #f7f9fc;
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.faq-question:hover {
  background: #eef4ff;
}

.faq-icon {
  font-size: 18px;
  font-weight: 700;
  margin-left: 12px;
  color: #2563eb;
  flex-shrink: 0;
}

.faq-answer {
  display: none;
  padding: 14px 16px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

.faq-item.open .faq-answer {
  display: block;
}

.faq-item.open .faq-icon {
  content: "-";
}


.payment-structure-credit-row .field-group { flex: 1 1 0; min-width: 0; }
#financeAprDisplay { text-align: center; font-weight: 700; }
.financed-group { flex: 0 0 auto; padding-bottom: 10px; }
.modern-toggle-blue .modern-toggle-slider { background: #cfe4ff; }
.modern-toggle-blue input:checked + .modern-toggle-slider { background: #1f6feb; }
.intake-tools-modal-content { max-width: 860px; }
.intake-tool-panel { margin-top: 18px; }
.intake-tools-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.intake-tools-table th, .intake-tools-table td { border: 1px solid #d1d5db; padding: 10px 12px; text-align: left; vertical-align: top; }
.intake-tools-table th { background: #f5f8fc; }
.intake-tool-faq-item { padding: 12px 0; border-top: 1px solid #e5e7eb; }
.intake-tool-faq-item:first-of-type { border-top: none; padding-top: 0; }
@media (max-width: 768px) {
  .payment-structure-credit-row, .payment-details-row { flex-wrap: wrap; }
}


/* Service Level Selection inputs inside Generate Docs modal */
.docgen-service-inputs {
  border: 1px solid #d7dbe3;
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: -2px;
}
.docgen-service-inputs label {
  font-weight: 700;
  font-size: 0.92rem;
}
.docgen-service-inputs input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #cfd6e2;
  border-radius: 8px;
}


.intake-tools-link-list p {
  margin: 8px 0;
}

.intake-tools-link-list a {
  word-break: break-word;
}


/* BofA Charge button inside One-Time Payment modal */
.otp-charge-footer {
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.bofa-charge-btn {
  background: linear-gradient(135deg, #e31837 0%, #e31837 48%, #0057b8 52%, #0057b8 100%);
  color: #fff;
  border: none;
  min-width: 128px;
  box-shadow: 0 8px 18px rgba(0, 87, 184, 0.22);
}

.bofa-charge-btn:hover {
  color: #fff;
  filter: brightness(0.95);
}

.bofa-charge-btn:disabled {
  background: #ced4da;
  color: #fff;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}


/* BofA Secure Acceptance checkout modal */
.bofa-checkout-modal {
  z-index: 10050;
}

.bofa-checkout-content {
  width: min(1180px, 96vw);
  max-width: 1180px;
  height: min(860px, 92vh);
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
}

.bofa-checkout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid #e7e9ee;
  background: linear-gradient(90deg, #e31837 0%, #e31837 48%, #0057b8 52%, #0057b8 100%);
  color: #fff;
}

.bofa-checkout-header h3 {
  margin: 0;
  color: #fff;
  font-size: 20px;
}

.bofa-checkout-header p {
  margin: 3px 0 0;
  color: rgba(255,255,255,0.9);
  line-height: 1.3;
}

.bofa-checkout-close {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 28px;
  line-height: 36px;
  cursor: pointer;
}

.bofa-checkout-status {
  padding: 10px 18px;
  font-weight: 700;
  color: #0c2340;
  background: #f5f7fb;
  border-bottom: 1px solid #e7e9ee;
}

.bofa-checkout-frame {
  display: block;
  width: 100%;
  height: calc(100% - 95px);
  border: 0;
  background: #fff;
}

@media (max-width: 768px) {
  .bofa-checkout-content {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .bofa-checkout-frame {
    height: calc(100vh - 112px);
  }
}

.bofa-reopen-btn {
  margin-left: 10px;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, #e31837 0%, #0052a5 100%);
  cursor: pointer;
}


/* BofA payment link copy button */
.payment-link-copy-btn {
  background: linear-gradient(90deg, #d71920 0%, #003da5 100%) !important;
  color: #fff !important;
  border: none !important;
}
.payment-link-copy-btn:hover {
  filter: brightness(0.95);
}
.payment-link-copy-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
