/* ─────────────────────────────────────────────────────────────
   Parcl9 Pro Forma & Returns Model
   Matches the Parcl9 site design tokens exactly.
───────────────────────────────────────────────────────────── */

/* Values reference the Parcl9 theme's own tokens (style.css :root) first,
   falling back to a hardcoded copy so this file still renders correctly
   if the plugin is ever activated on a different theme. */
:root {
  --p9rm-bg:         var(--white, #ffffff);
  --p9rm-bg-subtle:  var(--bg, #f5f2eb);
  --p9rm-bg-warm:    #fdf9f3;
  --p9rm-border:     var(--border, rgba(154, 111, 46, 0.18));
  --p9rm-border-md:  rgba(154, 111, 46, 0.28);
  --p9rm-gold:       var(--gold, #9a6f2e);
  --p9rm-gold-hover: var(--gold2, #b8883e);
  --p9rm-gold-light: rgba(154, 111, 46, 0.09);
  --p9rm-text:       var(--fg, #1a1814);
  --p9rm-text-mid:   var(--mu, #6b6458);
  --p9rm-muted:      var(--mu2, #a8a090);
  --p9rm-danger:     #b53c3c;
  --p9rm-success:    #2e7d32;
  --p9rm-radius:     4px;
  --p9rm-shadow:     var(--shadow-sm, 0 1px 3px rgba(26,24,20,.06), 0 1px 2px rgba(26,24,20,.04));
  --p9rm-shadow-md:  var(--shadow-md, 0 4px 16px rgba(26,24,20,.08), 0 2px 6px rgba(26,24,20,.05));
}

/* ── Wrap ─────────────────────────────────────────────────── */
#p9rm-wrap {
  font-family: 'Inter', sans-serif;
  color: var(--p9rm-text);
  background: var(--p9rm-bg);
  padding: 0 1.5rem 2rem;
  box-sizing: border-box;
}
#p9rm-wrap *, #p9rm-wrap *::before, #p9rm-wrap *::after { box-sizing: border-box; }

/* ── Top bar ──────────────────────────────────────────────── */
/* Title on its own row; toolbar controls on a second row below it —
   mirrors p9ip-waterfall.css's #p9wf-topbar. */
#p9rm-topbar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.5rem 0 1.25rem;
  border-bottom: 1px solid var(--p9rm-border);
  margin-bottom: 1.75rem;
}
#p9rm-topbar h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--p9rm-text);
  margin: 0;
}
/* Model Name now lives as a field inside #p9rm-inputs (see #p9rm-model-name-field) — reuses .p9rm-field's own input styling. */

/* ── Buttons ──────────────────────────────────────────────── */
.p9rm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.6rem 1.25rem;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.p9rm-btn:focus-visible { box-shadow: 0 0 0 3px rgba(154,111,46,.25); }
.p9rm-btn--primary   { background: var(--p9rm-gold); color: #fff; border-color: var(--p9rm-gold); }
.p9rm-btn--primary:hover { background: var(--p9rm-gold-hover); border-color: var(--p9rm-gold-hover); }
.p9rm-btn--secondary { background: transparent; color: var(--p9rm-gold); border-color: rgba(154,111,46,.4); }
.p9rm-btn--secondary:hover { background: var(--p9rm-gold-light); }
.p9rm-btn--calculate { background: var(--p9rm-gold); color: #fff; border-color: var(--p9rm-gold); width: 100%; margin-top: 0.5rem; font-size: 0.82rem; padding: 0.7rem; }
.p9rm-btn--calculate:hover { background: var(--p9rm-gold-hover); }

/* ── Main grid ────────────────────────────────────────────────
   Was "#p9rm-body" — that id doesn't exist in pro-forma.php (the
   wrapper is #p9rm-main-grid, see below), so this rule never matched
   and #p9rm-inputs/#p9rm-outputs silently fell back to display:block,
   stacking full-width with zero gap between them. Renamed to match
   p9ip-waterfall.css's #p9wf-main-grid, which has the same shape. */
#p9rm-main-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 860px) { #p9rm-main-grid { grid-template-columns: 1fr; } }

/* ── Inputs / Outputs — must have min-width:0 so grid children can shrink ── */
#p9rm-inputs { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

/* ── Section panels ───────────────────────────────────────── */
.p9rm-section {
  background: var(--p9rm-bg);
  border: 1px solid var(--p9rm-border);
  border-radius: var(--p9rm-radius);
  box-shadow: var(--p9rm-shadow);
  overflow: hidden;
}
/* The "From Pipeline" flyout (.p9rm-pipeline-panel) is absolutely positioned
   inside this card and would otherwise get clipped by the overflow:hidden
   above (which only exists so .p9rm-section-header's square corners don't
   poke past the card's own rounded ones) — initPipelinePicker() in
   p9ip-proforma.js toggles this class on/off exactly while the panel is open. */
.p9rm-section--panel-open { overflow: visible; }
.p9rm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--p9rm-bg-warm);
  border-bottom: 1px solid var(--p9rm-border);
  cursor: pointer;
  user-select: none;
}
.p9rm-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--p9rm-gold);
}
.p9rm-section-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.p9rm-section-body.collapsed { display: none; }

/* ── Fields ───────────────────────────────────────────────── */
.p9rm-field { display: flex; flex-direction: column; gap: 0.3rem; }
.p9rm-field label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--p9rm-text-mid);
}
.p9rm-field input,
.p9rm-field select {
  background: var(--p9rm-bg-subtle);
  border: 1px solid var(--p9rm-border-md);
  border-radius: var(--p9rm-radius);
  padding: 0.55rem 0.8rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  color: var(--p9rm-text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.p9rm-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239a6f2e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.1rem;
  cursor: pointer;
}
.p9rm-field input:focus,
.p9rm-field select:focus {
  border-color: var(--p9rm-gold);
  box-shadow: 0 0 0 3px rgba(154,111,46,.1);
}
.p9rm-field input::placeholder { color: var(--p9rm-muted); }
.p9rm-field-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.p9rm-field-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; }

/* Toggle */
.p9rm-toggle-row { display: flex; align-items: center; gap: 0.5rem; }
.p9rm-toggle-row input[type="checkbox"] { accent-color: var(--p9rm-gold); width: 1rem; height: 1rem; }
.p9rm-toggle-row label { font-size: 0.85rem; color: var(--p9rm-text-mid); cursor: pointer; }

/* Collapsible sub-section */
#p9rm-perm-detail { padding-top: 0.5rem; border-top: 1px dashed var(--p9rm-border); margin-top: 0.25rem; }

/* ── Outputs ──────────────────────────────────────────────── */
#p9rm-outputs { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.p9rm-empty-state { color: var(--p9rm-muted); font-size: 0.85rem; text-align: center; padding: 3rem 1rem; }

/* ── Metric cards ─────────────────────────────────────────── */
#p9rm-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.p9rm-card {
  background: var(--p9rm-bg);
  border: 1px solid var(--p9rm-border);
  border-radius: var(--p9rm-radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--p9rm-shadow);
}
.p9rm-card-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--p9rm-muted);
  margin-bottom: 0.3rem;
}
.p9rm-card-value { font-size: 1.3rem; font-weight: 300; color: var(--p9rm-text); line-height: 1.1; }
.p9rm-card-value.positive { color: var(--p9rm-success); }
.p9rm-card-value.negative { color: var(--p9rm-danger); }

/* ── Panel ────────────────────────────────────────────────── */
.p9rm-panel {
  background: var(--p9rm-bg);
  border: 1px solid var(--p9rm-border);
  border-radius: var(--p9rm-radius);
  box-shadow: var(--p9rm-shadow);
  padding: 1.25rem;
}
.p9rm-panel-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--p9rm-gold);
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--p9rm-border);
}

/* ── "From Pipeline" deal picker — pulls starting numbers from a
   user-picked Deal Pipeline deal's Quick Proforma analysis. Mirrors
   parcel9-capital-stack's own .p9cs-pipeline-* pattern; see
   initPipelinePicker()/applyPickedPipelineDeal() in p9ip-proforma.js.
   Replaced an earlier auto-detect banner that silently showed/hid itself
   based on whether this deal's own pipeline link happened to already
   match — an explicit, always-available button has no hidden state to
   fall out of sync in the first place. */
.p9rm-field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.p9rm-pipeline-row {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.p9rm-pipeline-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--p9rm-gold);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 3px;
  white-space: nowrap;
}
.p9rm-pipeline-btn:hover { text-decoration: underline; }

.p9rm-pipeline-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 300px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--p9rm-bg);
  border: 1px solid var(--p9rm-border-md);
  border-radius: var(--p9rm-radius);
  box-shadow: var(--p9rm-shadow-md);
  z-index: 40;
}
.p9rm-pipeline-panel-head {
  padding: 8px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--p9rm-muted);
  border-bottom: 1px solid var(--p9rm-border);
}
.p9rm-pipeline-list { list-style: none; margin: 0; padding: 0; }
.p9rm-pipeline-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--p9rm-border);
  padding: 8px 12px;
  cursor: pointer;
}
.p9rm-pipeline-item:last-child { border-bottom: none; }
.p9rm-pipeline-item:hover { background: var(--p9rm-gold-light); }
.p9rm-pipeline-item-addr {
  display: block;
  font-size: 0.78rem;
  color: var(--p9rm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p9rm-pipeline-item-stage {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.65rem;
  color: var(--p9rm-muted);
}
.p9rm-pipeline-empty {
  padding: 16px 12px;
  font-size: 0.75rem;
  color: var(--p9rm-muted);
  text-align: center;
}
@media (max-width: 480px) { .p9rm-pipeline-panel { width: 100%; } }

/* ── Cash flow table ──────────────────────────────────────── */
.p9rm-cf-table-wrap { overflow-x: auto; }
.p9rm-cf-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 480px; }
.p9rm-cf-table th {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--p9rm-muted);
  padding: 0.4rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--p9rm-border);
  white-space: nowrap;
}
.p9rm-cf-table th:first-child { text-align: left; }
.p9rm-cf-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--p9rm-border); text-align: right; color: var(--p9rm-text); font-variant-numeric: tabular-nums; }
.p9rm-cf-table td:first-child { text-align: left; color: var(--p9rm-text-mid); }
.p9rm-cf-table tr.total td { font-weight: 600; background: var(--p9rm-bg-warm); }
.p9rm-cf-table .negative { color: var(--p9rm-danger); }
.p9rm-cf-table .positive { color: var(--p9rm-success); }

/* ── Sensitivity table ────────────────────────────────────── */
.p9rm-sens-table { border-collapse: collapse; font-size: 0.8rem; }
.p9rm-sens-table th,
.p9rm-sens-table td { padding: 0.35rem 0.65rem; border: 1px solid var(--p9rm-border); text-align: center; }
.p9rm-sens-table th { background: var(--p9rm-bg-warm); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--p9rm-text-mid); }
.p9rm-sens-table .sens-base { background: rgba(154,111,46,.12); font-weight: 600; }
.p9rm-sens-table .sens-good { background: rgba(46,125,50,.1); color: #1a4a2e; }
.p9rm-sens-table .sens-bad  { background: rgba(181,60,60,.1);  color: #6b1a1a; }

/* ── Scenario comparison ──────────────────────────────────── */
.p9rm-scenario-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
@media (max-width: 600px) { .p9rm-scenario-cols { grid-template-columns: 1fr; } }
.p9rm-scenario-col {
  background: var(--p9rm-bg-warm);
  border: 1px solid var(--p9rm-border);
  border-radius: var(--p9rm-radius);
  padding: 1rem;
}
.p9rm-scenario-name {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--p9rm-gold);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--p9rm-border);
}
.p9rm-scenario-row { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 0.3rem 0; }
.p9rm-scenario-lbl { color: var(--p9rm-text-mid); }
.p9rm-scenario-val { color: var(--p9rm-text); font-variant-numeric: tabular-nums; font-weight: 500; }

/* ── Notice toast ─────────────────────────────────────────── */
#p9rm-notice {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--p9rm-text); color: #fff;
  padding: 0.7rem 1.2rem; border-radius: 3px;
  font-size: 0.85rem; box-shadow: var(--p9rm-shadow-md);
  display: none; z-index: 9999;
}

/* ── "Saved Models" toolbar row ───────────────────────────────
   Mirrors p9ip-waterfall.css's "Saved Scenarios" panel. */
.p9rm-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.p9rm-toolbar-left  { position: relative; }
.p9rm-toolbar-right { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; }

.p9rm-saved-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.15rem; height: 1.15rem; padding: 0 0.32rem;
  background: var(--p9rm-gold); color: #fff;
  border-radius: 999px; font-size: 0.65rem; font-weight: 700;
  letter-spacing: normal; text-transform: none;
}
.p9rm-saved-count:empty { display: none; }

.p9rm-saved-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 500;
  width: 320px; max-width: min(90vw, 320px);
  background: var(--p9rm-bg); border: 1px solid var(--p9rm-border-md);
  border-radius: var(--p9rm-radius); box-shadow: var(--p9rm-shadow-md);
  overflow: hidden;
}
.p9rm-saved-panel-head {
  padding: 0.65rem 0.9rem; font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--p9rm-text-mid);
  border-bottom: 1px solid var(--p9rm-border); background: var(--p9rm-bg-warm);
}
.p9rm-saved-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.p9rm-saved-item {
  display: flex; align-items: center; gap: 0.15rem;
  padding: 0 0.4rem; border-bottom: 1px solid var(--p9rm-border);
}
.p9rm-saved-item:last-child { border-bottom: none; }
.p9rm-saved-item.is-current { background: var(--p9rm-gold-light); }
.p9rm-saved-open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: none; padding: 0.6rem 0.4rem; cursor: pointer; text-align: left;
}
.p9rm-saved-open:hover { background: var(--p9rm-gold-light); }
.p9rm-saved-name {
  font-size: 0.82rem; color: var(--p9rm-text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.p9rm-saved-date { font-size: 0.7rem; color: var(--p9rm-text-mid); }
.p9rm-saved-rename, .p9rm-saved-del {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0.4rem; cursor: pointer;
  color: var(--p9rm-text-mid); border-radius: 3px; transition: background 0.15s, color 0.15s;
}
.p9rm-saved-rename:hover { color: var(--p9rm-gold); background: var(--p9rm-gold-light); }
.p9rm-saved-del:hover    { color: var(--p9rm-danger); background: rgba(181,60,60,.08); }
.p9rm-saved-empty { padding: 1.5rem 0.9rem; text-align: center; font-size: 0.8rem; color: var(--p9rm-text-mid); }

/* Checkbox used to pick up to 3 models for the "Scenario Comparison" panel — see compareScenarios() in p9ip-proforma.js. */
.p9rm-saved-compare-cb { flex-shrink: 0; margin-left: 0.5rem; accent-color: var(--p9rm-gold); cursor: pointer; }

.p9rm-saved-panel-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 0.9rem; border-top: 1px solid var(--p9rm-border); background: var(--p9rm-bg-warm);
  font-size: 0.75rem; color: var(--p9rm-text-mid);
}
.p9rm-saved-panel-foot .p9rm-link-btn:disabled { color: var(--p9rm-text-mid); cursor: not-allowed; opacity: 0.6; }

.p9rm-save-msg { font-size: 0.75rem; font-weight: 500; min-height: 1em; }

.p9rm-link-btn {
  background: none; border: none; padding: 0; margin: 0;
  font-family: 'Inter', sans-serif; font-size: 0.75rem; font-weight: 500;
  color: var(--p9rm-gold); text-decoration: underline; cursor: pointer;
}
.p9rm-link-btn:hover { color: var(--p9rm-gold-hover); }

/* ── Print / "Save as PDF" (#p9rm-btn-print → printModel() in
   p9ip-proforma.js) ─────────────────────────────────────────
   No PDF library involved — this hides everything on the page except
   #p9rm-wrap's output panels and lets the browser's native print/Save-as-PDF
   dialog do the rest. #p9rm-print-header is populated just-in-time with
   the model name + generation date and only ever shown here. */
#p9rm-print-header { display: none; }
@media print {
  body * { visibility: hidden; }
  #p9rm-wrap, #p9rm-wrap * { visibility: visible; }
  #p9rm-wrap { position: absolute; left: 0; top: 0; width: 100%; padding: 0; }
  #p9rm-topbar { border-bottom: 2px solid var(--p9rm-border-md); margin-bottom: 1rem; padding: 0 0 0.75rem; }
  #p9rm-print-header { display: block; font-size: 0.8rem; color: var(--p9rm-text-mid); margin-top: 0.2rem; }
  .p9rm-toolbar-row, #p9rm-inputs, #p9ip-notif-bell, #p9rm-notice { display: none !important; }
  #p9rm-main-grid { display: block; }
  #p9rm-cards { grid-template-columns: repeat(4, 1fr); }
  .p9rm-panel { break-inside: avoid; page-break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}

/* ═══════════════════════════════════════════════════════════
   PATCH — Missing classes
════════════════════════════════════════════════════════════ */

/* Modal hidden by default */
#p9rm-modal { display: none; }

/* Danger button */
.p9rm-btn--danger { background: var(--p9rm-danger); color: #fff; border-color: var(--p9rm-danger); }
.p9rm-btn--danger:hover { background: #9c2f2f; border-color: #9c2f2f; }

/* Ghost / small variants — used by the "Saved Models" toolbar */
.p9rm-btn--ghost {
  background: transparent;
  color: var(--p9rm-text-mid);
  border-color: var(--p9rm-border-md);
}
.p9rm-btn--ghost:hover { background: var(--p9rm-bg-subtle); color: var(--p9rm-text); border-color: var(--p9rm-gold); }
.p9rm-btn--sm { font-size: 0.7rem; padding: 0.38rem 0.85rem; gap: 0.35rem; }
.p9rm-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Section toggle button (arrow indicator) */
.p9rm-section-toggle { background: none; border: none; color: var(--p9rm-muted); cursor: pointer; font-size: 0.82rem; padding: 0; line-height: 1; transition: transform 0.2s; }
.p9rm-section-toggle.open { transform: rotate(0deg); }

/* Hint text */
.p9rm-hint { font-size: 0.72rem; color: var(--p9rm-muted); margin: 0; line-height: 1.4; }

/* Deal Pipeline <-> Quick Proforma link diagnostic (see renderLinkStatusHint()
   in p9ip-proforma.js) — slightly warmer than a plain hint so it reads as a
   status/action item rather than static help copy, but well short of the
   pull banner's gold treatment since it's informational, not a CTA. */
/* Phase grid (draw schedule) */
.p9rm-phase-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }

/* Sub section (perm loan detail) */
.p9rm-sub { padding-top: 0.5rem; }

/* Panel h4 titles (JS-rendered) */
.p9rm-panel-h4 { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--p9rm-gold); margin: 0 0 1rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--p9rm-border); }

/* Used when a panel header needs an action button beside it (e.g. Scenario Comparison's "Close") — the row itself owns the border/margin the plain .p9rm-panel-h4 would otherwise draw. */
.p9rm-panel-h4-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--p9rm-border); }
.p9rm-panel-h4-row .p9rm-panel-h4 { margin: 0; padding-bottom: 0; border-bottom: none; }

/* Table */
.p9rm-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.p9rm-table th { font-size: 0.67rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--p9rm-muted); padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid var(--p9rm-border); }
.p9rm-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--p9rm-border); color: var(--p9rm-text); font-variant-numeric: tabular-nums; }
.p9rm-table tr.p9rm-total td { font-weight: 600; background: var(--p9rm-bg-warm); border-bottom: none; }
.p9rm-table td:not(:first-child), .p9rm-table th:not(:first-child) { text-align: right; }

/* Value states */
.p9rm-good { color: var(--p9rm-success) !important; font-weight: 600; }
.p9rm-bad  { color: var(--p9rm-danger)  !important; font-weight: 600; }

/* Sources/Uses grid */
.p9rm-su-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.p9rm-su-grid .p9rm-table { margin: 0; }

/* Financing detail */
.p9rm-financing-detail { margin-top: 0.75rem; }
.p9rm-fd-item { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 0.35rem 0; border-bottom: 1px solid var(--p9rm-border); }
.p9rm-fd-item:last-child { border-bottom: none; font-weight: 600; }

/* Cash flow chart wrapper */
.p9rm-cf-wrap { margin-bottom: 0.75rem; }
.p9rm-cf-svg { width: 100%; overflow: visible; }
.p9rm-cf-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 0.5rem; }
.p9rm-swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; margin-right: 0.3rem; vertical-align: middle; flex-shrink: 0; }
.p9rm-cashflow { display: flex; align-items: center; gap: 0.4rem; font-size: 0.73rem; color: var(--p9rm-text-mid); }

/* Sensitivity */
.p9rm-sensitivity-wrap { overflow-x: auto; }
.p9rm-sens-corner { background: var(--p9rm-bg-warm); }
.p9rm-sens-cell { font-variant-numeric: tabular-nums; }
.p9rm-sens-legend { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; font-size: 0.73rem; color: var(--p9rm-text-mid); }

/* Base row highlight */
.p9rm-base-row td { background: rgba(154,111,46,.07); }

/* Note / footnote */
.p9rm-note { font-size: 0.73rem; color: var(--p9rm-muted); margin-top: 0.5rem; line-height: 1.4; }

/* Card variants */
.p9rm-card--good .p9rm-card-value { color: var(--p9rm-success); }
.p9rm-card--bad  .p9rm-card-value { color: var(--p9rm-danger);  }

/* Notice states */
#p9rm-notice.p9rm-notice--success { background: #1a4a2e; }
#p9rm-notice.p9rm-notice--error   { background: var(--p9rm-danger); }

/* =========================================================
   PIPELINE DEAL PICKER  — shared cross-plugin styling
   ========================================================= */
.p9-deal-picker {
    display: block;
    width: 100%;
    margin-bottom: 0.65rem;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.82rem;
    color: var(--text, #2e2b26);
    background: #fff;
    border: 1px solid var(--border, rgba(154,111,46,0.25));
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239a6f2e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2.1rem;
}
.p9-deal-picker:focus {
    outline: none;
    border-color: var(--accent, #9a6f2e);
    box-shadow: 0 0 0 2px rgba(154,111,46,0.15);
}
