/* ============================================================
   Deal Engine v2 — CSS
   Palette: clean light, green #059669, gold #d97706, blue #2563eb
   Fonts: Syne (display), Nunito Sans (body), JetBrains Mono (numbers)
============================================================ */

:root {
  --bg:        #f1f5f9;
  --bg2:       #ffffff;
  --bg3:       #f8fafc;
  --border:    #e2e8f0;
  --border2:   #cbd5e1;
  --text:      #0f172a;
  --text2:     #475569;
  --text3:     #94a3b8;
  --green:     #059669;
  --green2:    #047857;
  --gold:      #d97706;
  --blue:      #2563eb;
  --red:       #dc2626;
  --inputs-w:  284px;
  --chat-w:    300px;
  --header-h:  56px;
  --radius:    8px;
  --radius-lg: 12px;
  --text-muted: #64748b;
  --accent:    #2563eb;
}

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

html { font-size: 14px; }

body {
  font-family: 'Nunito Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   HEADER
============================================================ */
.app-header {
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
}

.brand {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0;
  padding: 0;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--green);
  background: rgba(5, 150, 105, 0.08);
  border: 1px solid rgba(5, 150, 105, 0.25);
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0;
}

.strategy-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.strat-btn {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.strat-btn:hover { background: var(--bg3); color: var(--text); }

.strat-btn.active {
  background: rgba(5, 150, 105, 0.1);
  border-color: rgba(5, 150, 105, 0.35);
  color: var(--green);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.v1-link {
  font-size: 0.75rem;
  color: var(--text3);
  text-decoration: none;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  transition: all 0.15s;
}

.v1-link:hover { color: var(--text2); border-color: var(--border2); }

.chat-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 600;
  transition: all 0.15s;
}

.chat-toggle-btn:hover,
.chat-toggle-btn.open {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--blue);
}

/* ============================================================
   PAGE BODY — three-column layout
============================================================ */
.page-body {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ============================================================
   INPUTS PANEL
============================================================ */
.inputs-panel {
  width: var(--inputs-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.inputs-panel::-webkit-scrollbar { width: 4px; }
.inputs-panel::-webkit-scrollbar-track { background: transparent; }
.inputs-panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.strategy-inputs { padding: 12px 14px 0; }
.strategy-inputs.hidden { display: none; }

.inp-section {
  margin-bottom: 16px;
}

.inp-section-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inp-section-subtitle {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text2);
  margin: 8px 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inp-section > label,
.inp-section > div > label {
  display: block;
  font-size: 0.75rem;
  color: var(--text2);
  margin-bottom: 6px;
}

/* Switch labels inside inp-section need flex restored */
.inp-section .switch-label { display: flex; margin-bottom: 0; }

.inp-section > label input,
.inp-section > label select,
.inp-section > div > label input,
.inp-section > div > label select {
  display: block;
  margin-top: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}

.inp-section > label input:focus,
.inp-section > label select:focus,
.inp-section > div > label input:focus,
.inp-section > div > label select:focus {
  border-color: var(--blue);
}

.inp-section > label select,
.inp-section > div > label select {
  font-family: 'Nunito Sans', sans-serif;
}

.inp-hint {
  font-size: 0.65rem;
  color: var(--text3);
  font-family: 'Nunito Sans', sans-serif;
  font-style: italic;
}

/* Inline label text + hint */
.label-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Address autocomplete wrapper */
.addr-wrap {
  position: relative;
}
.addr-suggestions {
  position: fixed;
  background: #ffffff;
  border: 1px solid var(--border2);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  z-index: 9999;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.addr-suggestion {
  padding: 8px 10px;
  font-size: 0.8rem;
  font-family: 'Nunito Sans', sans-serif;
  color: #0f172a;
  cursor: pointer;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  transition: background 0.1s;
}
.addr-suggestion:last-child { border-bottom: none; }
.addr-suggestion:hover,
.addr-suggestion.active { background: #eff6ff; }
.addr-suggestion .addr-main { font-weight: 600; color: #0f172a; }
.addr-suggestion .addr-sub  { font-size: 0.7rem; color: #64748b; margin-top: 1px; }

/* Opex mode toggle */
.toggle-row {
  display: flex;
  gap: 0;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg3));
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 6px;
  padding: 2px;
}

.mode-btn {
  font-size: 0.7rem;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--accent) 55%, var(--text2));
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.mode-btn:hover:not(.active) {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* DP range row */
.dp-range-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: flex-start;
}

.dp-range-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text2);
}

.dp-range-label:first-child { flex: 1; }   /* DP Range — takes remaining space */
.dp-range-label:last-child  { flex: 0 0 auto; } /* Step — shrinks to content */

.dp-range-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text2);
  white-space: nowrap;
}

.dp-range-inputs input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 6px;
  border-radius: 5px;
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
  width: 58px;
  outline: none;
  transition: border-color 0.15s;
}

.dp-range-label:last-child .dp-range-inputs input { width: 46px; }

.dp-range-inputs input:focus { border-color: var(--blue); }

/* Loan types */
.loan-types-header {
  font-size: 0.7rem;
  color: var(--text3);
  margin-bottom: 6px;
}

.loan-type-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 0.78rem;
  color: var(--text2);
}

.loan-type-row input[type="checkbox"] {
  accent-color: var(--green);
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.loan-type-row label {
  flex: 1;
  cursor: pointer;
}

.loan-type-row label.full-label { flex: 1 1 100%; }

.rate-inp {
  background: var(--bg3) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  padding: 3px 5px !important;
  border-radius: 4px !important;
  font-size: 0.76rem !important;
  font-family: 'JetBrains Mono', monospace !important;
  width: 52px !important;
  outline: none !important;
  transition: border-color 0.15s !important;
}

.rate-inp:focus { border-color: var(--blue) !important; }

/* Checkbox row */
.inp-check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text2);
  margin-bottom: 6px;
}

.inp-check-row input[type="checkbox"] { accent-color: var(--green); }
.inp-check-row label { cursor: pointer; }

/* Toggle switch */
.switch-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.switch-label input { display: none; }

.switch-track {
  display: block;
  width: 34px;
  height: 18px;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  border-radius: 10px;
  position: relative;
  transition: all 0.2s;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--text3);
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.switch-label input:checked + .switch-track {
  background: rgba(5, 150, 105, 0.18);
  border-color: var(--green);
}

.switch-label input:checked + .switch-track::after {
  left: 18px;
  background: var(--green);
}


.hidden { display: none !important; }

/* ============================================================
   RESULTS PANEL
============================================================ */
.results-panel {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.results-panel::-webkit-scrollbar { width: 5px; }
.results-panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.results-section { display: flex; flex-direction: column; gap: 12px; }
.results-section.hidden { display: none; }

.section-label {
  font-family: 'Syne', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 10px;
}

/* Placeholder */
.placeholder-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 400px;
  text-align: center;
  gap: 12px;
  color: var(--text3);
}

.placeholder-icon { opacity: 0.3; margin-bottom: 4px; }
.placeholder-msg h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text2);
}

.placeholder-msg p { font-size: 0.85rem; line-height: 1.6; }
.placeholder-msg strong { color: var(--green); font-weight: 600; }

/* ============================================================
   RECOMMENDATION CARDS
============================================================ */
.rec-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.rec-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s;
}

.rec-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  right: 0; height: 3px;
}

.rec-card.green::before { background: var(--green); }
.rec-card.gold::before { background: var(--gold); }
.rec-card.blue::before { background: var(--blue); }

.rec-card:hover { border-color: var(--border2); }

.rec-card-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.rec-card.green .rec-card-tag { color: var(--green); }
.rec-card.gold .rec-card-tag { color: var(--gold); }
.rec-card.blue .rec-card-tag { color: var(--blue); }

.rec-card-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.rec-card-sub {
  font-size: 0.75rem;
  color: var(--text2);
  margin-bottom: 10px;
}

.rec-card-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rec-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rec-metric-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}

.rec-metric-lbl {
  font-size: 0.62rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   METRICS BAR
============================================================ */
.metrics-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.metrics-bar.hidden { display: none; }

.metric-item {
  flex: 1;
  min-width: 100px;
  padding: 10px 14px;
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.metric-item-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
}

.metric-item-lbl {
  font-size: 0.62rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ============================================================
   CHART
============================================================ */
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-toggle {
  display: flex;
  gap: 0;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg3));
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 6px;
  padding: 2px;
}

.chart-metric-btn {
  font-size: 0.7rem;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--accent) 55%, var(--text2));
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.chart-metric-btn:hover:not(.active) {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.chart-metric-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.chart-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  height: 260px;
  position: relative;
}

.chart-wrap canvas { max-height: 228px; }

/* ============================================================
   SCENARIO TABLE
============================================================ */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg2);
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

#scenarioTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
}

#scenarioTable thead th {
  background: var(--bg3);
  color: var(--text3);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 9px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

#scenarioTable thead th:first-child,
#scenarioTable thead th:nth-child(2) { text-align: left; }

#scenarioTable thead th:hover { color: var(--text2); }
#scenarioTable thead th.sort-asc::after { content: ' ↑'; }
#scenarioTable thead th.sort-desc::after { content: ' ↓'; }

#scenarioTable tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

#scenarioTable tbody tr:last-child { border-bottom: none; }
#scenarioTable tbody tr:hover { background: var(--bg3); }
#scenarioTable tbody tr.best-row { background: rgba(5, 150, 105, 0.06); }

#scenarioTable tbody td {
  padding: 9px 12px;
  color: var(--text2);
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
}

#scenarioTable tbody td:first-child,
#scenarioTable tbody td:nth-child(2) {
  text-align: left;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--text);
}

.val-pos { color: var(--green) !important; }
.val-neg { color: var(--red) !important; }

.badge-best {
  display: inline-block;
  font-size: 0.58rem;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-left: 5px;
  vertical-align: middle;
}
.badge-irr {
  background: rgba(5, 150, 105, 0.1);
  color: var(--green);
  border: 1px solid rgba(5, 150, 105, 0.25);
}
.badge-coc {
  background: rgba(217, 119, 6, 0.1);
  color: var(--gold);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

/* Group header / divider rows */
.group-header-row td,
tr.group-divider td {
  font-family: 'Syne', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 7px 12px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  text-align: left !important;
  font-family: 'Syne', sans-serif;
}
.group-header-row td { color: var(--green); border-top: none; }
tr.group-divider td  { color: var(--gold);  border-top: 2px solid var(--border); }

.dscr-fail { color: var(--red) !important; text-decoration: line-through; opacity: 0.5; }

/* ============================================================
   STR EXTRAS
============================================================ */
.str-extra-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.str-extra-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.str-extra-card-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 8px;
}

.str-extra-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--text);
}

.str-extra-sub {
  font-size: 0.72rem;
  color: var(--text2);
  margin-top: 4px;
  line-height: 1.4;
}

/* ============================================================
   CHAT SIDEBAR
============================================================ */
.chat-sidebar {
  width: 0;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  overflow: hidden;
  transition: width 0.25s ease;
  position: relative;
}

.chat-sidebar.open {
  width: var(--chat-w);
}

.chat-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  position: absolute;
  top: 0; left: 0; bottom: 0;
  transition: background 0.15s;
  z-index: 10;
}

.chat-resize-handle:hover,
.chat-resize-handle.dragging {
  background: var(--blue);
}

.chat-sidebar-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-left: 4px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text2);
}

.chat-model-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: default;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.chat-msg { display: flex; flex-direction: column; gap: 4px; }

.chat-msg.user { align-items: flex-end; }
.chat-msg.assistant { align-items: flex-start; }

.msg-content {
  max-width: 90%;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text);
}

.chat-msg.user .msg-content {
  background: rgba(5, 150, 105, 0.1);
  border: 1px solid rgba(5, 150, 105, 0.15);
  border-radius: 10px 10px 2px 10px;
}

.chat-msg.assistant .msg-content {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 2px 10px 10px 10px;
}

.msg-content p { margin-bottom: 6px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { color: var(--green); font-weight: 600; }
.msg-content em { color: var(--gold); font-style: normal; font-weight: 600; }

.chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}

#chatInput {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-family: 'Nunito Sans', sans-serif;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.4;
}

#chatInput:focus { border-color: var(--blue); }
#chatInput::placeholder { color: var(--text3); }

.chat-send-btn {
  padding: 8px 10px;
  background: var(--blue);
  border: none;
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.chat-send-btn:hover { background: #93c5fd; transform: scale(1.05); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-typing {
  display: flex;
  gap: 3px;
  padding: 4px 0;
}

.chat-typing span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text3);
  animation: typingDot 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ============================================================
   LEAD CAPTURE MODAL
============================================================ */
.lc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lc-overlay.hidden { display: none; }

.lc-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 28px 20px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.lc-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.lc-close:hover { color: var(--text); background: var(--border); }

.lc-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.lc-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.lc-icon.broker  { background: #dbeafe; }
.lc-icon.agent   { background: #d1fae5; }
.lc-icon.costseg { background: #fef3c7; }

.lc-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.lc-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.lc-context {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}
.lc-context:empty { display: none; }

.lc-form { display: flex; flex-direction: column; gap: 10px; }

.lc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.lc-field input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}
.lc-field input:focus { border-color: var(--accent); }

.lc-submit {
  margin-top: 6px;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.lc-submit:hover { opacity: 0.88; }

.lc-confirm {
  text-align: center;
  padding: 20px 10px 8px;
}
.lc-confirm.hidden { display: none; }
.lc-confirm-icon {
  font-size: 2.5rem;
  color: #059669;
  margin-bottom: 8px;
}
.lc-confirm-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.lc-confirm-body {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.lc-disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 14px;
  opacity: 0.7;
}

/* CTA buttons */
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.cta-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.cta-btn:active { transform: translateY(0); }

.cta-btn.broker  { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.cta-btn.agent   { background: #059669; color: #fff; border-color: #047857; }
.cta-btn.costseg { background: #d97706; color: #fff; border-color: #b45309; }

/* Below-table CTA strip */
.cta-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  align-items: center;
}
.cta-strip-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-right: 4px;
}

/* Rec card CTA */
.rec-card-cta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

/* Chat CTA pills */
.chat-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.chat-cta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  transition: all 0.15s;
}
.chat-cta-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* Metrics bar agent badge */
.metrics-agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  border: none;
  margin-left: 8px;
  transition: opacity 0.15s;
}
.metrics-agent-badge:hover { opacity: 0.85; }

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 900px) {
  .page-body { flex-direction: column; height: auto; overflow: visible; }
  .inputs-panel { width: 100%; max-height: none; border-right: none; border-bottom: 1px solid var(--border); }
  .chat-sidebar.open { width: 100%; height: 380px; border-left: none; border-top: 1px solid var(--border); }
  .chat-resize-handle { display: none; }
  .strategy-nav { gap: 2px; }
  .strat-btn { padding: 5px 10px; font-size: 0.75rem; }
}

@media (max-width: 600px) {
  .strategy-nav { display: none; }
}

/* ============================================================
   MOBILE TAB SWITCHER (≤600px only)
============================================================ */
.mobile-tab-bar { display: none; }

@media (max-width: 600px) {
  /* Tab bar lives in the header as a second row */
  .app-header {
    flex-wrap: wrap;
    padding-bottom: 0;
  }
  .mobile-tab-bar {
    display: flex;
    width: 100%;
    border-top: 1px solid var(--border);
    margin-top: 6px;
  }
  .mobile-tab {
    flex: 1;
    padding: 8px 0;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    background: transparent;
    color: var(--text2);
    cursor: pointer;
    position: relative;
    letter-spacing: 0.02em;
    transition: color 0.15s;
    border-bottom: 2px solid transparent;
  }
  .mobile-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
  .mobile-tab-badge {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.2s;
  }
  .mobile-tab-badge.visible { opacity: 1; }

  /* Panel visibility driven by body[data-mobile-tab] */
  body[data-mobile-tab="results"] .inputs-panel  { display: none; }
  body[data-mobile-tab="inputs"]  .results-panel { display: none; }

  /* Accordion: collapse all inp-section children except the title */
  .inp-section.collapsed > *:not(.inp-section-title) { display: none; }
  .inp-section-title {
    cursor: pointer;
    user-select: none;
  }
  .inp-section-title::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--text2);
    border-bottom: 2px solid var(--text2);
    transform: rotate(45deg) translateY(-2px);
    margin-left: auto;
    transition: transform 0.2s;
    flex-shrink: 0;
  }
  .inp-section.collapsed .inp-section-title::after {
    transform: rotate(-45deg) translateY(0);
  }
}

/* ============================================================
   TOOLTIP ICONS
============================================================ */
.tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-style: normal;
  cursor: pointer;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg);
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
}
.tip-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.tip-popup {
  position: fixed;
  z-index: 9999;
  max-width: 240px;
  padding: 9px 12px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.76rem;
  line-height: 1.45;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.tip-popup.visible {
  opacity: 1;
  transform: translateY(0);
}
.tip-popup::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 12px;
  width: 10px;
  height: 10px;
  background: #1e293b;
  transform: rotate(45deg);
  border-radius: 2px;
}

/* ============================================================
   ONBOARDING OVERLAY
============================================================ */
.ob-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.ob-overlay.hidden { display: none; }

.ob-modal {
  background: #ffffff;
  border-radius: 16px;
  padding: 40px 40px 32px;
  max-width: 520px;
  width: 100%;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.ob-skip {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  font-size: 0.78rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}
.ob-skip:hover { color: #475569; }

/* Slides */
.ob-slide { display: none; }
.ob-slide.active { display: block; }

.ob-slide-icon {
  font-size: 2.4rem;
  margin-bottom: 14px;
  line-height: 1;
}
.ob-headline {
  font-family: 'Syne', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 10px;
}
.ob-body {
  font-size: 0.92rem;
  color: #475569;
  line-height: 1.6;
  margin: 0 0 22px;
}

/* Strategy pills — slide 1 */
.ob-strategy-pills {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ob-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.ob-pill-icon { font-size: 1.4rem; flex-shrink: 0; }
.ob-pill strong { display: block; font-size: 0.88rem; color: #1e293b; }
.ob-pill span { font-size: 0.78rem; color: #64748b; }

/* Steps — slide 2 */
.ob-steps { display: flex; flex-direction: column; gap: 14px; }
.ob-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.5;
}
.ob-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Metrics — slide 3 */
.ob-metrics { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.ob-metric-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  align-items: start;
}
.ob-metric-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #2563eb;
  padding-top: 1px;
}
.ob-metric-desc {
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.5;
}

/* CTA button — slide 3 */
.ob-cta {
  display: block;
  width: 100%;
  padding: 13px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.ob-cta:hover { background: #1d4ed8; }

/* Navigation row */
.ob-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
}
.ob-nav-btn {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 0.82rem;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.ob-nav-btn:hover { border-color: #2563eb; color: #2563eb; }
.ob-nav-btn.hidden { visibility: hidden; }

.ob-dots { display: flex; gap: 7px; align-items: center; }
.ob-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.ob-dot.active {
  background: #2563eb;
  transform: scale(1.25);
}

/* ============================================================
   SEO CONTENT SECTION
============================================================ */
.seo-content {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  margin-top: 16px;
  font-size: 0.88rem;
  color: var(--text2);
  line-height: 1.7;
}
.seo-inner {
  max-width: 800px;
  margin: 0 auto;
}
.seo-content h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.0rem;
  font-weight: 700;
  color: var(--text1);
  margin: 0 0 10px;
}
.seo-content h3 {
  font-family: 'Syne', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text1);
  margin: 18px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.seo-content p { margin: 0 0 12px; }
.seo-content ul {
  margin: 0 0 12px;
  padding-left: 20px;
}
.seo-content li { margin-bottom: 4px; }

/* ============================================================
   LIVE RATE BUTTON
============================================================ */
.live-rate-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border: 1.5px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--accent);
  transition: all 0.15s;
  white-space: nowrap;
  margin-left: auto;
}
.live-rate-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.live-rate-btn:disabled { opacity: 0.6; cursor: default; }
.live-rate-btn.live-rate-success {
  border-color: #059669;
  color: #059669;
  background: #f0fdf4;
}
.live-rate-err {
  font-size: 0.72rem;
  color: #dc2626;
  margin-left: 8px;
}
