/* =========================================================
   Construction Loan Calculator — cl- prefix
   Header: #292524 (dark stone)
   clamp(MIN, fluid, MAX) used throughout for fluid scaling
   ========================================================= */

/* ── Reset ── */
.cl-wrap *, .cl-wrap *::before, .cl-wrap *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Wrapper ── */
.cl-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: #1c1917;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10);
  overflow: hidden;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Header ── */
.cl-header {
  background: #292524;
  color: #fff;
  padding: clamp(14px, 2.5vw, 22px) clamp(14px, 3vw, 28px);
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 16px);
}
.cl-header-icon {
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1;
  flex-shrink: 0;
}
.cl-header-title {
    color: white;
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.cl-header-sub {
  font-size: clamp(0.68rem, 1.5vw, 0.78rem);
  color: #a8a29e;
  letter-spacing: 0.01em;
}

/* ── Body Layout ── */
.cl-body {
  display: flex;
  gap: 0;
  align-items: flex-start;
}

/* ── Form (Left) ── */
.cl-form {
  flex: 0 0 44%;
  padding: clamp(14px, 2.5vw, 24px) clamp(12px, 2.5vw, 24px) clamp(16px, 3vw, 28px);
  background: #ffffff;
  border-right: 1.5px solid #e7e5e4;
}

/* ── Section Title ── */
.cl-section-title {
  font-size: clamp(0.66rem, 1.4vw, 0.72rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #78716c;
  margin: clamp(12px, 2vw, 18px) 0 10px;
  border-bottom: 1px solid #e7e5e4;
  padding-bottom: 6px;
}

/* ── Field Group ── */
.cl-field-group {
  margin-bottom: clamp(10px, 1.8vw, 14px);
}

/* ── Label ── */
.cl-label {
  display: block;
  font-size: clamp(0.76rem, 1.5vw, 0.82rem);
  font-weight: 600;
  color: #44403c;
  margin-bottom: 6px;
}
.cl-hint-inline {
  font-size: clamp(0.68rem, 1.4vw, 0.73rem);
  font-weight: 400;
  color: #78716c;
  margin-left: 4px;
}

/* ── Choice Buttons ── */
.cl-choices {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(4px, 1vw, 6px);
}
.cl-choice {
  flex: 1;
  min-width: 0;
  padding: clamp(6px, 1.2vw, 8px) clamp(7px, 1.5vw, 10px);
  border: 1.5px solid #d6d3d1;
  border-radius: 7px;
  background: #fafaf9;
  font-size: clamp(0.72rem, 1.4vw, 0.78rem);
  font-weight: 500;
  color: #44403c;
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  transition: all 0.15s;
}
.cl-choice:hover {
    color: #292524;
  border-color: #78716c;
  background: #f5f5f4;
}
.cl-choice.active {
  background: #292524;
  border-color: #292524;
  color: #ffffff;
}
.cl-choice-sub {
  display: block;
  font-size: clamp(0.62rem, 1.2vw, 0.68rem);
  font-weight: 400;
  opacity: 0.8;
  margin-top: 2px;
}

/* Toggle: 2 buttons side-by-side */
.cl-toggle .cl-choice {
  flex: 1 1 48%;
}

/* ── Input (with unit) ── */
.cl-input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid #d1d5db;
  border-radius: 7px;
  overflow: hidden;
  transition: border-color 0.15s;
  background: #fff;
}
.cl-input-wrap:focus-within {
  border-color: #292524;
}
.cl-input-wrap .cl-input {
  border: none;
  outline: none;
  padding: 8px 10px;
  font-size: clamp(0.82rem, 1.6vw, 0.9rem);
  flex: 1;
  background: transparent;
  -moz-appearance: textfield;
  appearance: textfield;
}
.cl-input-wrap .cl-input::-webkit-inner-spin-button,
.cl-input-wrap .cl-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
.cl-unit {
  padding: 0 10px;
  font-size: 0.83rem;
  font-weight: 600;
  color: #78716c;
  background: #f5f5f4;
  border-left: 1.5px solid #d1d5db;
  height: 100%;
  display: flex;
  align-items: center;
}

/* ── Input Group ($) ── */
.cl-input-group {
  display: flex;
  align-items: stretch;
  border: 1.5px solid #d1d5db;
  border-radius: 7px;
  overflow: hidden;
  transition: border-color 0.15s;
  background: #fff;
}
.cl-input-group:focus-within {
  border-color: #292524;
}
.cl-input-addon {
  padding: 8px 10px;
  background: #f5f5f4;
  border-right: 1.5px solid #d1d5db;
  font-size: 0.85rem;
  font-weight: 600;
  color: #78716c;
  display: flex;
  align-items: center;
}
.cl-input-addon-field {
  border: none;
  outline: none;
  padding: 8px 10px;
  font-size: clamp(0.82rem, 1.6vw, 0.9rem);
  flex: 1;
  background: transparent;
  -moz-appearance: textfield;
  appearance: textfield;
}
.cl-input-addon-field::-webkit-inner-spin-button,
.cl-input-addon-field::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

/* ── Auto Display ── */
.cl-auto-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(6px, 1.2vw, 8px) clamp(10px, 1.8vw, 12px);
  background: #f5f5f4;
  border: 1.5px solid #e7e5e4;
  border-radius: 7px;
  font-size: clamp(0.76rem, 1.5vw, 0.82rem);
}
.cl-auto-highlight {
  background: #fef9c3;
  border-color: #fde047;
}
.cl-auto-label { color: #78716c; }
.cl-auto-value { font-weight: 700; color: #292524; }

/* ── Range Slider ── */
.cl-slider {
  width: 100%;
  margin: 6px 0 2px;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 4px;
  background: #e7e5e4;
  outline: none;
  cursor: pointer;
}
.cl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #292524;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.cl-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #292524;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.cl-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: #a8a29e;
  margin-top: 2px;
}

/* ── Hint text ── */
.cl-hint {
  font-size: clamp(0.68rem, 1.4vw, 0.72rem);
  color: #78716c;
  margin-top: 4px;
  line-height: 1.4;
}
.cl-highlight {
  font-weight: 700;
  color: #292524;
}

/* ── Draw Sliders Section ── */
.cl-draw-sliders {
  display: flex;
  flex-direction: column;
  gap: clamp(7px, 1.5vw, 10px);
}
.cl-draw-item {
  background: #fafaf9;
  border: 1px solid #e7e5e4;
  border-radius: 7px;
  padding: clamp(7px, 1.5vw, 10px) clamp(9px, 1.8vw, 12px) clamp(6px, 1.2vw, 8px);
}
.cl-draw-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  flex-wrap: wrap;
  gap: 4px;
}
.cl-draw-name {
  font-size: clamp(0.70rem, 1.4vw, 0.78rem);
  font-weight: 600;
  color: #44403c;
}
.cl-draw-pct-val {
  font-size: clamp(0.70rem, 1.4vw, 0.78rem);
  font-weight: 700;
  color: #292524;
  white-space: nowrap;
}
.cl-draw-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f5f5f4;
  border-radius: 6px;
  font-size: clamp(0.74rem, 1.5vw, 0.8rem);
  font-weight: 600;
  border: 1.5px solid #e7e5e4;
}
.cl-draw-total-val {
  font-size: clamp(0.82rem, 1.8vw, 0.9rem);
  font-weight: 700;
  color: #292524;
}
.cl-draw-total-val.warn { color: #dc2626; }
.cl-draw-warn {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  color: #b91c1c;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: clamp(0.70rem, 1.4vw, 0.78rem);
  font-weight: 600;
}

/* ── Disclaimer ── */
.cl-disclaimer {
  margin-top: clamp(12px, 2vw, 16px);
  padding: clamp(10px, 1.8vw, 12px) clamp(11px, 2vw, 14px);
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 7px;
  font-size: clamp(0.68rem, 1.4vw, 0.72rem);
  color: #78716c;
  line-height: 1.5;
}

/* =========================================================
   cl-results — RIGHT PANEL
   All sizing uses clamp() so it scales across all viewports
   ========================================================= */
.cl-results {
  flex: 1 1 0;
  min-width: 0;
  padding: clamp(14px, 2.5vw, 24px) clamp(12px, 2.5vw, 24px) clamp(16px, 3vw, 28px);
  background: #fafaf9;
}

/* ── Placeholder ── */
.cl-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(36px, 8vw, 60px) 20px;
  gap: 14px;
}
.cl-placeholder-icon { font-size: clamp(2rem, 4vw, 2.5rem); }
.cl-placeholder p {
  color: #a8a29e;
  font-size: clamp(0.80rem, 1.6vw, 0.88rem);
  max-width: 300px;
  line-height: 1.5;
}

/* ── Hero Card ── */
.cl-hero-card {
  background: #292524;
  color: #fff;
  border-radius: 10px;
  padding: clamp(14px, 2.5vw, 20px);
  margin-bottom: clamp(10px, 1.8vw, 14px);
}
.cl-phase-row {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 12px);
}
.cl-phase {
  flex: 1;
  text-align: center;
  padding: clamp(10px, 1.8vw, 12px) clamp(6px, 1.2vw, 8px);
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
}
.cl-phase-perm {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.22);
}
.cl-phase-tag {
  font-size: clamp(0.60rem, 1.2vw, 0.68rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-bottom: 6px;
}
.cl-phase-value {
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.cl-phase-sub {
  font-size: clamp(0.65rem, 1.3vw, 0.72rem);
  font-weight: 600;
  opacity: 0.8;
  margin-bottom: 3px;
}
.cl-phase-note {
  font-size: clamp(0.60rem, 1.2vw, 0.65rem);
  opacity: 0.55;
}
.cl-phase-arrow {
  font-size: clamp(1rem, 2vw, 1.4rem);
  opacity: 0.5;
  flex-shrink: 0;
}

/* ── Cards ── */
.cl-card {
  background: #fff;
  border: 1.5px solid #e7e5e4;
  border-radius: 10px;
  padding: clamp(12px, 2vw, 16px);
  margin-bottom: clamp(10px, 1.8vw, 14px);
}
.cl-card-title {
  font-size: clamp(0.68rem, 1.4vw, 0.78rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #78716c;
  margin-bottom: clamp(8px, 1.5vw, 12px);
}

/* ── Draw Table ── */
.cl-draw-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cl-draw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.72rem, 1.5vw, 0.82rem);
  min-width: 300px;
}
.cl-draw-table th {
  background: #f5f5f4;
  font-weight: 700;
  font-size: clamp(0.64rem, 1.3vw, 0.72rem);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #78716c;
  padding: clamp(6px, 1.2vw, 8px) clamp(7px, 1.5vw, 10px);
  text-align: left;
  border-bottom: 2px solid #e7e5e4;
}
.cl-draw-table td {
  padding: clamp(7px, 1.4vw, 9px) clamp(7px, 1.5vw, 10px);
  border-bottom: 1px solid #f5f5f4;
  color: #292524;
  font-weight: 500;
  vertical-align: middle;
}
.cl-draw-table tbody tr:last-child td { border-bottom: none; }
.cl-draw-table tfoot td {
  font-weight: 700;
  font-size: clamp(0.76rem, 1.5vw, 0.85rem);
  color: #292524;
  background: #fef9c3;
  padding: clamp(7px, 1.5vw, 10px);
  border-top: 2px solid #e7e5e4;
}

/* ── Interest Reserve Card ── */
.cl-reserve-card {
  border-color: #a5f3fc;
  background: #f0fdff;
}
.cl-reserve-card .cl-card-title { color: #0e7490; }
.cl-reserve-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.cl-reserve-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: clamp(6px, 1.2vw, 7px) clamp(8px, 1.5vw, 10px);
  background: rgba(255,255,255,0.7);
  border-radius: 6px;
  font-size: clamp(0.74rem, 1.5vw, 0.82rem);
}
.cl-reserve-row span:last-child { font-weight: 600; margin-left: auto; }
.cl-reserve-total { font-weight: 700; font-size: clamp(0.80rem, 1.6vw, 0.88rem); }
.cl-reserve-note {
  font-size: clamp(0.68rem, 1.4vw, 0.75rem);
  color: #0e7490;
  font-weight: 600;
}

/* ── Compare Table (1-close vs 2-close) ── */
.cl-compare-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}
.cl-compare-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: clamp(2px, 0.8vw, 4px);
}
.cl-compare-header {
  font-weight: 700;
  font-size: clamp(0.66rem, 1.3vw, 0.75rem);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #78716c;
}
.cl-compare-row div {
  padding: clamp(6px, 1.2vw, 8px) clamp(7px, 1.5vw, 10px);
  background: #fafaf9;
  border-radius: 5px;
  font-size: clamp(0.68rem, 1.4vw, 0.8rem);
  color: #292524;
}
.cl-compare-header div { background: #f5f5f4; color: #78716c; font-weight: 700; }
.cl-compare-last div { font-weight: 700; }
.cl-savings-badge {
  display: inline-block;
  background: #dcfce7;
  color: #15803d;
  border: 1.5px solid #86efac;
  border-radius: 20px;
  padding: 5px clamp(10px, 2vw, 14px);
  font-size: clamp(0.70rem, 1.4vw, 0.78rem);
  font-weight: 700;
  white-space: normal;
}

/* ── Budget / Cost Rows ── */
.cl-budget-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cl-budget-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: clamp(6px, 1.2vw, 7px) clamp(8px, 1.5vw, 10px);
  background: #fafaf9;
  border-radius: 5px;
  font-size: clamp(0.74rem, 1.5vw, 0.82rem);
  color: #292524;
}
.cl-budget-row span:last-child { margin-left: auto; }
.cl-budget-total {
  font-weight: 700;
  font-size: clamp(0.80rem, 1.6vw, 0.88rem);
  border-top: 2px solid #e7e5e4;
  margin-top: 4px;
  background: #f5f5f4;
}
.cl-budget-loan {
  font-weight: 700;
  color: #292524;
  background: #fef9c3;
}

/* ── Stats Grid ── */
.cl-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 1.5vw, 10px);
  margin-top: 4px;
}
.cl-stat {
  background: #fff;
  border: 1.5px solid #e7e5e4;
  border-radius: 8px;
  padding: clamp(10px, 1.8vw, 14px) clamp(8px, 1.5vw, 14px) clamp(9px, 1.7vw, 12px);
  text-align: center;
}
.cl-stat-label {
  font-size: clamp(0.60rem, 1.2vw, 0.7rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #a8a29e;
  margin-bottom: 6px;
}
.cl-stat-value {
  font-size: clamp(0.92rem, 2vw, 1.15rem);
  font-weight: 800;
  color: #292524;
  letter-spacing: -0.01em;
}
.cl-stat-sm { font-size: clamp(0.80rem, 1.7vw, 0.95rem); }

/* =========================================================
   RESPONSIVE — MOBILE (max 480px)
   Layout changes ONLY — sizing handled by clamp() above
   ========================================================= */
@media (max-width: 480px) {
  /* Stack form + results vertically */
  .cl-body { flex-direction: column; }

  .cl-form {
    flex: none;
    width: 100%;
    border-right: none;
    border-bottom: 1.5px solid #e7e5e4;
  }

  .cl-results { width: 100%; }

  /* Loan Structure toggle: full-width each button */
  .cl-toggle .cl-choice { flex: 1 1 100%; }

  /* Hero: stack phases vertically */
  .cl-phase-row { flex-direction: column; }
  .cl-phase-arrow { transform: rotate(90deg); }

  /* Stats: 2-col fits better than 1-col on narrow */
  .cl-stats-grid { grid-template-columns: 1fr 1fr; }
}

/* =========================================================
   RESPONSIVE — TABLET (481px – 899px)
   Layout changes ONLY — sizing handled by clamp() above
   ========================================================= */
@media (min-width: 481px) and (max-width: 899px) {
  /* Stack form + results vertically */
  .cl-body { flex-direction: column; }

  .cl-form {
    flex: none;
    width: 100%;
    border-right: none;
    border-bottom: 1.5px solid #e7e5e4;
  }

  .cl-results { width: 100%; }

  /* Stats: 4-col row on tablet */
  .cl-stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* =========================================================
   RESPONSIVE — DESKTOP (900px+)
   ========================================================= */
@media (min-width: 900px) {
  .cl-form { overflow-y: auto; }
  /* Stats: 4-col on large desktop */
  .cl-stats-grid { grid-template-columns: repeat(4, 1fr); }
}
