/* CFPB TRID Closing Disclosure 5-Page Stylesheet */
:root {
  --cd-black: #111827;
  --cd-dark-gray: #374151;
  --cd-light-gray: #F3F4F6;
  --cd-border: #9CA3AF;
  --cd-navy: #061C3F;
  --cd-primary: #FF6A00;
  --cd-blue-header: #1E3A8A;
}

body.cd-body {
  background-color: #525659;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #000000;
  -webkit-font-smoothing: antialiased;
}

/* TOP TOOLBAR */
.cd-top-toolbar {
  background: #061C3F;
  color: #FFF;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.cd-toolbar-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.cd-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cd-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.cd-logo img,
.cd-brand img {
  height: 36px !important;
  max-height: 36px !important;
  width: auto !important;
  max-width: 160px !important;
  object-fit: contain;
  display: block;
}

.cd-badge {
  background: #FF6A00;
  color: #FFF;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.cd-doc-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #FFF;
}

.cd-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cd-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF !important;
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  text-decoration: none;
}

.cd-action-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.6);
  color: #FFFFFF !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cd-action-btn:active {
  transform: translateY(0);
}

.cd-action-btn.active {
  background: #FF6A00 !important;
  border-color: #FF6A00 !important;
  color: #FFFFFF !important;
  box-shadow: 0 0 12px rgba(255, 106, 0, 0.5);
}

.cd-action-btn.btn-print {
  background: #FF6A00;
  border-color: #FF6A00;
  color: #FFFFFF !important;
  font-weight: 700;
}

.cd-action-btn.btn-print:hover {
  background: #E55F00;
  border-color: #E55F00;
}

.cd-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #061C3F;
  color: #FFF;
  border-left: 4px solid #10B981;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 999999;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s ease;
  pointer-events: none;
}

.cd-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.cd-page-selector {
  display: flex;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.cd-page-btn {
  background: transparent;
  border: none;
  color: #CBD5E1;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.cd-page-btn:hover {
  color: #FFF;
}

.cd-page-btn.active {
  background: #FF6A00;
  color: #FFF;
}

/* RECALCULATION DRAWER */
.cd-control-drawer {
  background: #FFF;
  border-bottom: 2px solid #FF6A00;
  padding: 16px 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.drawer-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #061C3F;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #6B7280;
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.drawer-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 4px;
}

.drawer-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  box-sizing: border-box;
}

.drawer-footer-note {
  margin-top: 10px;
  font-size: 0.75rem;
  color: #6B7280;
  font-style: italic;
}

/* ZOOM / SCREEN-FIT CONTROLS */
.cd-zoom-controls {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  padding: 2px 4px;
  gap: 2px;
}

.cd-zoom-btn {
  background: transparent;
  border: none;
  color: #FFF;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.cd-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.cd-zoom-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #CBD5E1;
  min-width: 42px;
  text-align: center;
  user-select: none;
}

/* CD DOCUMENT CONTAINER & RESPONSIVE SCALING */
.cd-doc-container {
  width: 100%;
  max-width: 1400px;
  margin: 16px auto;
  padding: 0 16px 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
}

/* ALL PAGES MULTI-COLUMN GRID MODE */
.cd-doc-container.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  max-width: 1680px;
  align-items: start;
}

.cd-doc-container.grid-view .cd-page {
  margin: 0 auto;
  width: 100%;
  height: 100%;
}

/* 8.5 x 11 PAGE LAYOUT WITH RESPONSIVE SCALE */
.cd-page {
  background: #FFFFFF;
  width: 8.5in;
  min-height: 11in;
  max-width: 100%;
  margin: 0 auto 24px;
  padding: 0.35in 0.4in;
  box-sizing: border-box;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  position: relative;
  font-size: 8pt;
  line-height: 1.25;
  color: #000;
  display: flex;
  flex-direction: column;
  transform-origin: top center;
  transition: transform 0.2s ease, margin 0.2s ease;
}

.cd-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 3.5px solid #000000;
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.cd-header-row.compact {
  border-bottom: 3.5px solid #000000;
  padding-bottom: 3px;
  margin-bottom: 6px;
}

.cd-main-title {
  margin: 0;
  font-family: 'Roboto Condensed', 'Inter', sans-serif;
  font-size: 26pt;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.5px;
  color: #000;
  line-height: 0.95;
}

.cd-page2-title {
  margin: 0;
  font-family: 'Roboto Condensed', 'Inter', sans-serif;
  font-size: 16pt;
  font-weight: 800;
  text-transform: uppercase;
  color: #000;
}

.cd-subtitle {
  margin: 0;
  font-size: 8pt;
  color: #111;
  max-width: 320px;
  line-height: 1.2;
}

/* METADATA 3-COLUMN GRID */
.cd-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  border-bottom: 1.5px solid #000;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.cd-meta-title {
  font-size: 8.5pt;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 4px;
  border-bottom: 1px solid #CCC;
  padding-bottom: 2px;
}

.cd-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 7.5pt;
}

.cd-meta-table td {
  padding: 1.5px 2px;
  vertical-align: top;
}

.cd-meta-table td:first-child {
  color: #333;
  width: 42%;
}

.cd-meta-table td:last-child {
  font-weight: 600;
}

.cd-subtext {
  font-size: 7pt;
  color: #444;
  display: block;
}

/* SECTION BOXES */
.cd-section-box {
  margin-bottom: 10px;
}

.cd-section-header {
  background: #000000;
  color: #FFFFFF;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 10.5pt;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2.5px 8px;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

/* GENERIC CD TABLE */
.cd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8pt;
}

.cd-table th {
  background: #E5E7EB;
  font-weight: 700;
  text-align: left;
  padding: 3px 6px;
  border: 1px solid #000;
  font-size: 7.5pt;
}

.cd-table td {
  padding: 3.5px 6px;
  border: 1px solid #000;
  vertical-align: middle;
}

.cd-table tr.highlight-row {
  background: #F9FAFB;
}

.cd-table tr.total-row {
  background: #F3F4F6;
  font-weight: 800;
  border-top: 2px solid #000;
}

/* COSTS AT CLOSING SUMMARY ROW */
.cd-costs-summary .cd-costs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border: 1px solid #000;
  padding: 8px 12px;
  background: #FAFAFA;
}

.cd-cost-item {
  display: flex;
  flex-direction: column;
}

.cd-cost-label {
  font-size: 10.5pt;
  font-weight: 800;
  text-transform: uppercase;
}

.cd-cost-amount {
  font-size: 16pt;
  font-weight: 900;
  font-family: 'Roboto Condensed', sans-serif;
  margin: 2px 0 4px;
}

.cd-cost-desc {
  font-size: 7.5pt;
  color: #333;
}

/* PAGE 2 COST DETAILS TABLE */
.cd-cost-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 7pt;
  line-height: 1.15;
}

.cd-cost-details-table th, 
.cd-cost-details-table td {
  border: 1px solid #000;
  padding: 2px 4px;
}

.cd-cost-details-table th {
  background: #E5E7EB;
  font-weight: 700;
  font-size: 7pt;
  text-align: center;
}

.cd-cost-details-table tr.section-title-row td {
  background: #F3F4F6;
  font-weight: 800;
  font-size: 7.5pt;
  border-top: 1.5px solid #000;
  border-bottom: 1.5px solid #000;
}

.section-total-badge {
  float: right;
  font-weight: 900;
  font-size: 8pt;
}

.cd-cost-details-table tr.major-total-row td {
  background: #E5E7EB;
  font-weight: 800;
  font-size: 7.5pt;
  border-top: 2px solid #000;
  border-bottom: 2px solid #000;
}

.cd-cost-details-table tr.grand-total-row td {
  background: #111827;
  color: #FFFFFF;
  font-weight: 900;
  font-size: 8.5pt;
  border: 2px solid #000;
}

.cd-cost-details-table tr.header-subbreak th {
  background: #000000;
  color: #FFFFFF;
  text-align: left;
  font-size: 9pt;
  text-transform: uppercase;
  padding: 2px 6px;
}

/* PAGE 3 CASH TO CLOSE TABLE */
.cd-cash-to-close-table {
  margin-bottom: 12px;
}

.cd-cash-to-close-table th {
  background: #000;
  color: #FFF;
}

.cd-change-tag {
  font-size: 6.5pt;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid #666;
}

.cd-change-tag.no { background: #EEE; color: #333; }
.cd-change-tag.yes { background: #FEE2E2; color: #991B1B; border-color: #EF4444; }

.cash-to-close-grand-row {
  background: #F3F4F6;
  border-top: 2.5px solid #000;
  border-bottom: 2.5px solid #000;
}

/* SUMMARIES OF TRANSACTIONS */
.cd-summaries-wrap {
  border-top: 2px solid #000;
  padding-top: 6px;
}

.cd-summaries-header h3 {
  margin: 0;
  font-size: 11pt;
  font-weight: 800;
  text-transform: uppercase;
}

.cd-summaries-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

.cd-summary-col {
  border: 1.5px solid #000;
  padding: 6px;
}

.cd-summary-title {
  background: #000;
  color: #FFF;
  font-weight: 800;
  font-size: 8.5pt;
  text-align: center;
  padding: 2px 0;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.cd-sub-section {
  margin-bottom: 8px;
}

.cd-sub-title {
  font-weight: 800;
  font-size: 7.5pt;
  border-bottom: 1px solid #000;
  padding-bottom: 2px;
  margin-bottom: 3px;
}

.cd-sub-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 7pt;
}

.cd-sub-table td {
  padding: 1.5px 2px;
  border: none;
  border-bottom: 1px dotted #CCC;
}

.cd-sub-table tr.sub-header td {
  font-weight: 700;
  background: #F9FAFB;
  border-bottom: 1px solid #999;
}

.cd-reconciliation-box {
  background: #F3F4F6;
  border: 1.5px solid #000;
  padding: 6px;
  margin-top: 8px;
}

.recon-row {
  display: flex;
  justify-content: space-between;
  font-size: 7.5pt;
  margin-bottom: 2px;
}

.recon-row.total {
  border-top: 1.5px solid #000;
  padding-top: 4px;
  margin-top: 4px;
}

/* PAGE 4 DISCLOSURES */
.cd-disclosures-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 16px;
}

.cd-disc-block {
  margin-bottom: 10px;
  border-bottom: 1px solid #E5E7EB;
  padding-bottom: 6px;
}

.cd-disc-block h4 {
  margin: 0 0 3px;
  font-size: 8.5pt;
  font-weight: 800;
  text-transform: uppercase;
  color: #000;
}

.cd-disc-block p {
  margin: 0 0 4px;
  font-size: 7.5pt;
}

.cd-checkbox-item {
  font-size: 7.5pt;
  margin-bottom: 2px;
}

.cd-checkbox {
  display: inline-block;
  font-weight: 800;
}

.cd-checkbox.checked {
  color: #000;
}

.escrow-disc-block {
  border-left: 2px solid #000;
  padding-left: 12px;
  border-bottom: none;
}

.cd-escrow-table {
  font-size: 7pt;
}

.cd-escrow-table td {
  padding: 3px;
}

/* PAGE 5 LOAN CALCS & CONTACTS */
.cd-calc-metrics-table td {
  padding: 6px;
  vertical-align: top;
}

.metric-val {
  font-size: 13pt;
  font-weight: 900;
  font-family: 'Roboto Condensed', sans-serif;
  margin-bottom: 4px;
}

.metric-sub {
  font-size: 6.5pt;
  color: #333;
  line-height: 1.2;
}

.cd-page5-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.cd-disc-text-block {
  font-size: 7pt;
  margin-bottom: 6px;
  line-height: 1.25;
}

.cd-contact-table {
  font-size: 7pt;
}

.cd-contact-table th {
  background: #000;
  color: #FFF;
}

.cd-signature-box {
  margin-top: 10px;
  border: 1.5px solid #000;
  padding: 8px 12px;
}

.cd-sig-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 18px;
}

.sig-underline {
  border-bottom: 1.5px solid #000;
  height: 20px;
  margin-bottom: 4px;
}

.sig-caption {
  font-size: 7.5pt;
}

/* FOOTER */
.cd-page-footer {
  margin-top: auto;
  border-top: 1.5px solid #000;
  padding-top: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 7.5pt;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* HELPERS */
.text-right { text-align: right; }
.text-center { text-align: center; }
.bold { font-weight: 800; }
.font-sm { font-size: 7pt; }
.font-md { font-size: 9pt; }
.font-lg { font-size: 11pt; }
.text-primary { color: #D95300; }
.text-navy { color: #061C3F; }
.cd-tag { padding: 1px 4px; border-radius: 3px; font-weight: 800; font-size: 7pt; }
.cd-tag.cd-yes { background: #FEE2E2; color: #991B1B; }
.cd-no { color: #000; }
.cd-badge-in { background: #DCFCE7; color: #166534; font-size: 6.5pt; padding: 1px 4px; border-radius: 3px; font-weight: 700; }
.cd-badge-out { background: #F3F4F6; color: #374151; font-size: 6.5pt; padding: 1px 4px; border-radius: 3px; font-weight: 700; }
.float-right { float: right; }

/* INTERACTIVE ITEMIZATION TOOLTIP SYSTEM */
[data-info] {
  cursor: help;
  position: relative;
  transition: background-color 0.15s ease, color 0.15s ease;
}

[data-info]:hover {
  background-color: #FEF3C7 !important;
  color: #92400E !important;
  border-radius: 2px;
}

.cd-tooltip-box {
  position: fixed;
  background: #061C3F;
  color: #FFFFFF;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.775rem;
  line-height: 1.45;
  max-width: 320px;
  z-index: 99999;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 106, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Inter', sans-serif;
}

.cd-tooltip-box.active {
  opacity: 1;
  transform: translateY(0);
}

.cd-tooltip-box .tt-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: #FF6A00;
  font-size: 0.825rem;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 3px;
}

.cd-tooltip-box .tt-desc {
  color: #E2E8F0;
  font-size: 0.75rem;
}

.cd-tooltip-box .tt-ref {
  margin-top: 5px;
  display: inline-block;
  font-size: 0.675rem;
  color: #94A3B8;
  font-weight: 600;
}

/* PRINT RULES FOR 8.5 x 11 */
@media print {
  .cd-tooltip-box {
    display: none !important;
  }
  [data-info] {
    cursor: default;
    background: transparent !important;
    color: inherit !important;
  }
  body.cd-body {
    background: #FFF;
    padding: 0;
  }
  .no-print {
    display: none !important;
  }
  .cd-doc-container {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  .cd-page {
    box-shadow: none;
    margin: 0;
    padding: 0.35in 0.4in;
    page-break-after: always;
    page-break-inside: avoid;
    height: 10.9in;
    max-height: 11in;
  }
  .cd-page:last-child {
    page-break-after: avoid;
  }
}
