/* ==========================================================================
   Parcl9 Quick Proforma — Styles
   Design tokens match the Parcl9 auth + theme palette exactly.
   ========================================================================== */

/* ── Design tokens ──────────────────────────────────────────────────────── */
.p9pf-wrap {
  --p9pf-gold:       #9a6f2e;
  --p9pf-gold-hover: #b8883e;
  --p9pf-gold-pale:  rgba(154, 111, 46, 0.12);
  --p9pf-gold-border:rgba(154, 111, 46, 0.22);
  --p9pf-orange:       #c9541c;
  --p9pf-orange-dark:  #a3410f;
  --p9pf-orange-pale:  rgba(201, 84, 28, 0.12);
  --p9pf-orange-border:rgba(201, 84, 28, 0.35);
  --p9pf-dark:       #1a1814;
  --p9pf-text:       #1a1814;
  --p9pf-muted:      #6b6458;
  --p9pf-muted-lt:   #9c9288;
  --p9pf-bg:         #faf9f7;
  --p9pf-bg-lt:      #ffffff;
  --p9pf-border:     rgba(154, 111, 46, 0.18);
  --p9pf-border-lt:  rgba(26, 24, 20, 0.08);
  --p9pf-green:      #2e7d50;
  --p9pf-green-pale: rgba(46, 125, 80, 0.08);
  --p9pf-red:        #b03a2e;
  --p9pf-red-pale:   rgba(176, 58, 46, 0.08);
  --p9pf-amber:      #92600a;
  --p9pf-amber-pale: rgba(146, 96, 10, 0.10);
  --p9pf-radius:     4px;
  --p9pf-shadow:     0 1px 3px rgba(26, 24, 20, 0.06), 0 1px 2px rgba(26, 24, 20, 0.04);
  --p9pf-shadow-md:  0 4px 12px rgba(26, 24, 20, 0.10);
  --p9pf-font-serif: var(--font-serif, 'Playfair Display', Georgia, 'Times New Roman', serif);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--p9pf-text);
  font-size: 14px;
  line-height: 1.5;
}

.p9pf-wrap *,
.p9pf-wrap *::before,
.p9pf-wrap *::after {
  box-sizing: border-box;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.p9pf-layout {
  display: grid;
  /* --pf-col-w is set by initColumnResizer()/initColumnResizerAcq() (and
     persisted to localStorage) once the user drags .p9pf-col-resizer — the
     middle column below IS that resizer, not a plain grid gap, so dragging
     it visually feels like resizing the gap itself. Each .p9pf-layout
     instance (Developer vs Institutional Acquisition) sets this custom
     property on itself, so the two tabs remember independent widths. */
  grid-template-columns: var(--pf-col-w, 380px) 20px 1fr;
  column-gap: 6px;
  align-items: start;
  /* max-width: 1100px; */
  margin: 0 auto;
}

@media (max-width: 860px) {
  .p9pf-layout {
    grid-template-columns: 1fr;
  }
  /* !important required: the base .p9pf-col-resizer rule below sets its own
     unconditional 'display: flex' with identical specificity (single class
     selector), so without it that rule would win the cascade here too.
     There's also nothing to resize between once the layout collapses to a
     single column. */
  .p9pf-col-resizer { display: none !important; }
}

/* Draggable divider between the input and results panels — see
   initColumnResizer() / initColumnResizerAcq() in p9-proforma.js /
   p9-acquisition.js. The full grid column is the hit-area (easier to grab
   than a hairline), with a full-height dashed line down the middle and a
   vertical "drag to adjust" label breaking it partway down. */
.p9pf-col-resizer {
  align-self: stretch;
  min-height: 100%;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  position: relative;
}
.p9pf-col-resizer::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 2px dashed var(--p9pf-border);
  transition: border-color 0.15s ease;
}
.p9pf-col-resizer:hover::before,
.p9pf-col-resizer.is-dragging::before {
  border-color: var(--p9pf-gold);
}
.p9pf-col-resizer-label {
  position: relative;
  z-index: 1;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--p9pf-muted-lt);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  /* Solid patch in the page's own background color, breaking the dashed
     line cleanly behind the label instead of text sitting on top of it. */
  background: var(--p9pf-bg);
  padding: 10px 1px;
  border-radius: var(--p9pf-radius);
  transition: color 0.15s ease;
}
.p9pf-col-resizer:hover .p9pf-col-resizer-label,
.p9pf-col-resizer.is-dragging .p9pf-col-resizer-label {
  color: var(--p9pf-gold);
}

/* ── Input panel ────────────────────────────────────────────────────────── */
.p9pf-inputs {
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  padding: 20px;
  box-shadow: var(--p9pf-shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Describe-your-deal intake box ─────────────────────────────────────── */
/* ── Guided Intake Chat ──────────────────────────────────────────────────── */
.p9pf-intake-box {
  /* Explicit (not just inherited via ".p9pf-wrap *") because
     openFloatingChat()/openFloatingChatAcq() move this element onto
     <body> and put the .p9pf-wrap class directly ON it (rather than
     leaving it nested inside .p9pf-wrap), so it no longer matches that
     descendant selector while floating. */
  box-sizing: border-box;
  background: var(--p9pf-gold-pale);
  border: 1px solid var(--p9pf-gold-border);
  border-radius: var(--p9pf-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.3s, border-color 0.3s;
}

/* Brief pulse when the chat is opened/brought to attention */
.p9pf-intake-box--highlight {
  border-color: var(--p9pf-gold);
  box-shadow: 0 0 0 3px var(--p9pf-gold-pale), var(--p9pf-shadow-md);
}

/* ── Floating / draggable chat window ─────────────────────────────────────
   Sending the first chat message pops the very same intake box out of the
   sidebar into a movable window (reparented onto #p9pf-wrap, position: fixed)
   so it can sit next to whatever part of the results the user is looking at,
   instead of being missed at the top of a long left column. */
.p9pf-intake-box--floating {
  position: fixed;
  top: 24px;
  left: 24px;
  bottom: auto;
  right: auto;
  width: 380px;
  min-width: 300px;
  max-width: calc(100vw - 24px);
  height: min(70vh, 560px);
  min-height: 320px;
  max-height: calc(100vh - 24px);
  /* No native `resize` here — that only ever gives a single bottom-right
     corner. All 4 edges + 4 corners are handled instead by the explicit
     .p9pf-resize-handle elements below, driven by initFloatingResize() /
     initFloatingResizeAcq(), so it behaves like a normal desktop window. */
  z-index: 9999;
  /* Solid, opaque backdrop — the default gold-pale wash is semi-transparent,
     which looks fine sitting on the page's white background inline, but
     lets dashboard content bleed through once floating over it. Everything
     nested inside (including the translucent message-bubble tints) then
     composites against this solid backdrop instead of the page. */
  background: var(--p9pf-bg-lt);
  box-shadow: var(--p9pf-shadow-md);
  border-color: var(--p9pf-gold);
}

.p9pf-intake-box--floating .p9pf-intake-thread {
  flex: 1;
  height: auto;
  max-height: none;
}

/* Edge/corner resize handles for the floating chat window — inert and
   hidden while docked. Positioned just inside the box's own edges (not
   straddling them) so .p9pf-intake-box's overflow:hidden (needed for its
   rounded corners) doesn't clip them. Corners sit above edges (higher
   z-index) since they overlap the same space at the box's 4 corners. */
.p9pf-resize-handle { display: none; position: absolute; z-index: 30; }
.p9pf-intake-box--floating .p9pf-resize-handle { display: block; }

.p9pf-resize-handle--n, .p9pf-resize-handle--s {
  left: 12px; right: 12px; height: 7px; cursor: ns-resize;
}
.p9pf-resize-handle--n { top: 0; }
.p9pf-resize-handle--s { bottom: 0; }

.p9pf-resize-handle--e, .p9pf-resize-handle--w {
  top: 12px; bottom: 12px; width: 7px; cursor: ew-resize;
}
.p9pf-resize-handle--e { right: 0; }
.p9pf-resize-handle--w { left: 0; }

.p9pf-resize-handle--ne, .p9pf-resize-handle--nw,
.p9pf-resize-handle--se, .p9pf-resize-handle--sw {
  width: 16px; height: 16px; z-index: 31;
}
.p9pf-resize-handle--ne { top: 0; right: 0; cursor: nesw-resize; }
.p9pf-resize-handle--nw { top: 0; left: 0;  cursor: nwse-resize; }
.p9pf-resize-handle--se { bottom: 0; right: 0; cursor: nwse-resize; }
.p9pf-resize-handle--sw { bottom: 0; left: 0;  cursor: nesw-resize; }

/* Decorative echo of the docked chat's own resize cue, kept in the one
   corner users most expect it — purely visual, doesn't affect the actual
   hit-area (that's the full 16x16 handle underneath). */
.p9pf-resize-handle--se::after {
  content: '';
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 12px;
  height: 12px;
  pointer-events: none;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  background: repeating-linear-gradient(
    135deg,
    var(--p9pf-gold) 0px, var(--p9pf-gold) 2px,
    transparent 2px, transparent 5px
  );
  opacity: .5;
}

.p9pf-intake-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--p9pf-gold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 10px 14px 0;
}

.p9pf-intake-box--floating .p9pf-intake-header {
  cursor: move;
  user-select: none;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--p9pf-gold-border);
}

/* Shared style for the header's pop-out / dock-back icon buttons — only
   one of the two is ever visible at a time, depending on floating state. */
.p9pf-intake-header-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--p9pf-gold);
  padding: 3px;
  display: flex;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.p9pf-intake-header-btn:hover { opacity: 1; }

.p9pf-intake-subtitle {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--p9pf-muted-lt);
  font-size: 10.5px;
  margin-left: 2px;
}

/* Message thread */
.p9pf-intake-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  /* max-height (not height) so it grows with the conversation up to this
     cap by default — min/max below are just the drag bounds once the user
     grabs the resize bar right below this element, which sets an explicit
     height directly (see initThreadResize() / initThreadResizeAcq()). */
  min-height: 90px;
  max-height: 260px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.p9pf-intake-thread::-webkit-scrollbar { width: 4px; }
.p9pf-intake-thread::-webkit-scrollbar-track { background: transparent; }
.p9pf-intake-thread::-webkit-scrollbar-thumb { background: var(--p9pf-border); border-radius: 2px; }

/* Dedicated horizontal resize bar, docked mode only — sits between the
   thread and the input row so drags never land on the thread's own
   scrollbar (which occupies that same bottom-right corner once there are
   enough messages to actually scroll — native CSS `resize` there would
   just scroll instead of resizing). See initThreadResize() /
   initThreadResizeAcq() in p9-proforma.js / p9-acquisition.js. */
.p9pf-thread-resize-bar {
  flex-shrink: 0;
  height: 10px;
  /* margin: -5px 0; */
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  z-index: 5;
  touch-action: none;
}
.p9pf-thread-resize-bar::before {
  content: '';
  width: 30px;
  height: 3px;
  border-radius: 3px;
  background: var(--p9pf-border);
  transition: background 0.15s ease, width 0.15s ease;
}
.p9pf-thread-resize-bar::after {
  content: 'drag';
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--p9pf-muted-lt);
  opacity: 0.8;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.p9pf-thread-resize-bar:hover::before,
.p9pf-thread-resize-bar.is-dragging::before {
  background: var(--p9pf-gold);
  width: 48px;
}
.p9pf-thread-resize-bar:hover::after,
.p9pf-thread-resize-bar.is-dragging::after {
  color: var(--p9pf-gold);
  opacity: 1;
}
.p9pf-intake-box--floating .p9pf-thread-resize-bar { display: none; }

/* Messages */
.p9pf-intake-msg {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  max-width: 92%;
}

.p9pf-intake-msg--user {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.p9pf-intake-avatar {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: var(--p9pf-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--p9pf-bg);
  margin-top: 1px;
}

.p9pf-intake-bubble {
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--p9pf-text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.p9pf-intake-msg--assistant .p9pf-intake-bubble {
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border-lt);
  border-top-left-radius: 3px;
}

.p9pf-intake-msg--user .p9pf-intake-bubble {
  background: rgba(201, 169, 110, 0.18);
  border: 1px solid var(--p9pf-gold-border);
  border-top-right-radius: 3px;
  color: var(--p9pf-text);
}

/* Typing dots */
.p9pf-intake-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  min-width: 44px;
}

.p9pf-intake-typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--p9pf-muted-lt);
  border-radius: 50%;
  animation: p9pfTypingDot 1.2s infinite;
}

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

@keyframes p9pfTypingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%            { opacity: 1;   transform: translateY(-3px); }
}

/* Input row */
.p9pf-intake-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 0 14px 10px;
}

.p9pf-intake-input {
  flex: 1;
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-gold-border);
  border-radius: 8px;
  padding: 11px;
  font-size: 12.5px;
  color: var(--p9pf-text);
  font-family: inherit;
  outline: none;
  resize: none;
  line-height: 1.5;
  overflow-y: hidden;
  min-height: 52px;
  max-height: 120px;
  display: flex;
  align-items: center;
  transition: border-color 0.15s;
  /* vertically center single-line placeholder */
  padding-top: 14px;
  padding-bottom: 14px;
}

.p9pf-intake-input:focus {
  border-color: var(--p9pf-gold);
}

.p9pf-intake-input::placeholder {
  color: var(--p9pf-muted-lt);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: center;
}

.p9pf-intake-send-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--p9pf-gold);
  border: none;
  border-radius: 8px;
  color: var(--p9pf-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.p9pf-intake-send-btn:hover  { opacity: 0.85; }
.p9pf-intake-send-btn:active { opacity: 0.7;  }

/* Missing required field highlight (shown after intake apply with gaps) */
.p9pf-input--missing,
input.p9pf-input--missing {
  border-color: #c9853a !important;
  box-shadow: 0 0 0 2px rgba(201, 133, 58, 0.25) !important;
  animation: p9pfMissingPulse 1.8s ease 0s 2;
}

@keyframes p9pfMissingPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(201, 133, 58, 0.25); }
  50%       { box-shadow: 0 0 0 4px rgba(201, 133, 58, 0.45); }
}

/* Access gate (upgrade notice) for post-results chat */
.p9pf-intake-gate {
  padding: 0 14px 10px;
}

/* Apply footer */
.p9pf-intake-footer {
  padding: 0 14px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.p9pf-intake-apply-note {
  font-size: 11px;
  color: var(--p9pf-muted-lt);
}

/* Applied state */
.p9pf-intake-box--applied .p9pf-intake-footer {
  background: var(--p9pf-green-pale);
  border-top: 1px solid rgba(46,125,80,0.15);
  padding-top: 8px;
}

.p9pf-intake-box--applied .p9pf-intake-apply-note {
  color: var(--p9pf-green);
}

/* Skip link */
.p9pf-intake-skip {
  padding: 0 14px 10px;
  font-size: 11px;
  color: var(--p9pf-muted-lt);
}

.p9pf-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--p9pf-gold);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Inline cost estimate panel ─────────────────────────────────────────── */
.p9pf-cost-estimate-panel {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--p9pf-bg);
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  font-size: 12px;
  line-height: 1.5;
  color: var(--p9pf-text);
}

.p9pf-cost-estimate-panel .p9pf-ai-table {
  margin-top: 4px;
  font-size: 11px;
}

/* ── Section headings ───────────────────────────────────────────────────── */
.p9pf-section-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--p9pf-gold);
  padding-top: 6px;
  margin-bottom: -4px;
  border-top: 1px solid var(--p9pf-border-lt);
}

.p9pf-section-heading:first-child {
  border-top: none;
  padding-top: 0;
}

/* ── Acquisition mode toggle in section heading ─────────────────────────── */
.p9pf-acq-mode-toggle {
  margin-left: auto;
}

/* ── Land assembly parcel list ──────────────────────────────────────────── */
.p9pf-parcel-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.p9pf-parcel-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.p9pf-parcel-label {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--p9pf-bg-input, #1e1b16);
  border: 1px solid var(--p9pf-border, #3a3428);
  border-radius: 6px;
  color: var(--p9pf-text, #f0ebe2);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.2s;
}

.p9pf-parcel-label:focus {
  border-color: var(--p9pf-gold, #c9a96e);
}

.p9pf-parcel-price-wrap {
  flex: 0 0 140px;
}

.p9pf-parcel-remove {
  flex: 0 0 28px;
  height: 28px;
  width: 28px;
  border: 1px solid var(--p9pf-border, #3a3428);
  border-radius: 6px;
  background: transparent;
  color: #6b6458;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}

.p9pf-parcel-remove:hover {
  border-color: #e05252;
  color: #e05252;
}

.p9pf-parcel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.p9pf-parcel-total-row {
  margin-left: auto;
  font-size: 12px;
  color: #9a8b7a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.p9pf-parcel-total-row strong {
  color: var(--p9pf-gold, #c9a96e);
  font-size: 13px;
}

.p9pf-assembly-carry-note {
  font-size: 11px;
  color: #c47c2b;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(196, 124, 43, 0.08);
  border-left: 2px solid #c47c2b;
  border-radius: 0 4px 4px 0;
}

/* ── Phased lot sales list ───────────────────────────────────────────────── */
.p9pf-lot-col-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--p9pf-muted-lt, #6b6458);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0 0 4px;
}

.p9pf-lot-col-hint span:nth-child(1) { flex: 1 1 auto; }
.p9pf-lot-col-hint span:nth-child(2) { flex: 0 0 80px; }
.p9pf-lot-col-hint span:nth-child(3) { flex: 0 0 130px; }
.p9pf-lot-col-hint span:nth-child(4) { flex: 0 0 60px; }
.p9pf-lot-col-hint span:nth-child(5) { flex: 0 0 28px; }

.p9pf-lot-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.p9pf-lot-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.p9pf-lot-label,
.p9pf-lot-sqft,
.p9pf-lot-month {
  background: var(--p9pf-bg-input, #1e1b16);
  border: 1px solid var(--p9pf-border, #3a3428);
  border-radius: 6px;
  color: var(--p9pf-text, #f0ebe2);
  font-size: 13px;
  padding: 7px 8px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.p9pf-lot-label:focus,
.p9pf-lot-sqft:focus,
.p9pf-lot-month:focus {
  border-color: var(--p9pf-gold, #c9a96e);
}

.p9pf-lot-label { flex: 1 1 auto; }
.p9pf-lot-sqft  { flex: 0 0 80px; }
.p9pf-lot-month { flex: 0 0 60px; }

.p9pf-lot-price-wrap {
  flex: 0 0 130px;
}

/* ── Demolition field ───────────────────────────────────────────────────── */
.p9pf-demolition-field {
  margin-top: 10px;
}

.p9pf-label-hint {
  font-weight: 400;
  font-size: 10px;
  color: #6b6458;
  margin-left: 5px;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Project type grid ──────────────────────────────────────────────────── */
.p9pf-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.p9pf-type-grid--5 {
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

@media (max-width: 480px) {
  .p9pf-type-grid--5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.p9pf-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px 8px;
  background: var(--p9pf-bg);
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  cursor: pointer;
  font-size: 11px;
  color: var(--p9pf-muted);
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.3;
}

.p9pf-type-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.p9pf-type-btn small {
  color: var(--p9pf-muted-lt);
  display: block;
}

.p9pf-type-btn:hover {
  background: var(--p9pf-gold-pale);
  border-color: var(--p9pf-gold-border);
  color: var(--p9pf-dark);
}

.p9pf-type-btn--active {
  background: var(--p9pf-gold-pale) !important;
  border-color: var(--p9pf-gold) !important;
  color: var(--p9pf-dark) !important;
}

.p9pf-type-btn--active svg {
  stroke: var(--p9pf-gold);
}

/* ── Fields ─────────────────────────────────────────────────────────────── */
.p9pf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.p9pf-field--full {
  grid-column: 1 / -1;
}

.p9pf-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--p9pf-muted);
  letter-spacing: 0.02em;
}

.p9pf-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* ── Deal Pipeline picker ("From Pipeline") ─────────────────────────────── */

.p9pf-pipeline-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--p9pf-gold);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 3px;
  white-space: nowrap;
  flex-shrink: 0;
}
.p9pf-pipeline-btn:hover { text-decoration: underline; }

.p9pf-pipeline-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 260px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  box-shadow: var(--p9pf-shadow-md);
  z-index: 40;
}

.p9pf-pipeline-panel-head {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--p9pf-muted);
  border-bottom: 1px solid var(--p9pf-border-lt);
}

.p9pf-pipeline-list { list-style: none; margin: 0; padding: 0; }

.p9pf-pipeline-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--p9pf-border-lt);
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
}
.p9pf-pipeline-item:last-child { border-bottom: none; }
.p9pf-pipeline-item:hover { background: var(--p9pf-gold-pale); }

.p9pf-pipeline-item-addr {
  display: block;
  font-size: 12.5px;
  color: var(--p9pf-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p9pf-pipeline-item-stage {
  display: inline-block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--p9pf-muted);
}

.p9pf-pipeline-empty {
  padding: 16px 12px;
  font-size: 12px;
  color: var(--p9pf-muted);
  text-align: center;
}

@media (max-width: 480px) {
  .p9pf-pipeline-panel { right: auto; left: 0; width: 100%; }
}

.p9pf-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.p9pf-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.p9pf-wrap input[type="number"],
.p9pf-wrap input[type="text"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  font-size: 13px;
  color: var(--p9pf-text);
  background: var(--p9pf-bg-lt);
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}

.p9pf-wrap input[type="number"]::-webkit-outer-spin-button,
.p9pf-wrap input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.p9pf-wrap input:focus {
  outline: none;
  border-color: var(--p9pf-gold);
  box-shadow: 0 0 0 3px var(--p9pf-gold-pale);
}

/* ── Dropdown selectors ────────────────────────────────────────────────────
   Same box/border/focus language as the text & number inputs above, with the
   native OS arrow swapped for a custom chevron (via background-image, since
   pseudo-elements can't be inserted into a <select>) so it doesn't clash
   with the browser-default look next to everything else on the form. */
.p9pf-wrap select {
  width: 100%;
  padding: 7px 30px 7px 10px;
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--p9pf-text);
  background-color: var(--p9pf-bg-lt);
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b6458' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px 14px;
}

.p9pf-wrap select:hover {
  border-color: var(--p9pf-border);
}

.p9pf-wrap select:focus {
  outline: none;
  border-color: var(--p9pf-gold);
  box-shadow: 0 0 0 3px var(--p9pf-gold-pale);
}

.p9pf-wrap select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.p9pf-wrap select option {
  color: var(--p9pf-text);
  background: var(--p9pf-bg-lt);
}

.p9pf-input-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  overflow: hidden;
  background: var(--p9pf-bg-lt);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.p9pf-input-prefix:focus-within {
  border-color: var(--p9pf-gold);
  box-shadow: 0 0 0 3px var(--p9pf-gold-pale);
}

.p9pf-input-prefix > span {
  display: flex;
  align-items: center;
  padding: 0 6px 0 10px;
  font-size: 12px;
  color: var(--p9pf-muted);
  pointer-events: none;
  flex-shrink: 0;
  user-select: none;
}

/* Input inside a prefix wrapper: remove its own border/radius/shadow */
.p9pf-input-prefix input {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding-left: 2px;
  flex: 1;
  min-width: 0;
  background: transparent;
}

.p9pf-input-prefix input:focus {
  outline: none;
  border: none !important;
  box-shadow: none !important;
}

/* ── Computed display field ─────────────────────────────────────────────── */
.p9pf-field--computed .p9pf-computed-val {
  padding: 7px 10px;
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  font-size: 13px;
  color: var(--p9pf-muted);
  background: var(--p9pf-bg);
  min-height: 34px;
}

/* ── Construction method grid ───────────────────────────────────────────── */
.p9pf-method-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

@media (max-width: 480px) {
  .p9pf-method-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.p9pf-method-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px 7px;
  background: var(--p9pf-bg);
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--p9pf-muted);
  text-align: center;
  line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.p9pf-method-btn small {
  display: block;
  font-size: 9.5px;
  font-weight: 400;
  color: var(--p9pf-muted-lt);
  line-height: 1.3;
}

.p9pf-method-btn:hover {
  background: var(--p9pf-gold-pale);
  border-color: var(--p9pf-gold-border);
  color: var(--p9pf-dark);
}

.p9pf-method-btn--active {
  background: var(--p9pf-gold-pale) !important;
  border-color: var(--p9pf-gold) !important;
  color: var(--p9pf-dark) !important;
}

/* ── Toggle buttons ─────────────────────────────────────────────────────── */
.p9pf-toggle-group {
  display: flex;
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  overflow: hidden;
  width: fit-content;
}

.p9pf-toggle-group--wide {
  width: 100%;
}

.p9pf-toggle-btn {
  flex: 1;
  padding: 6px 14px;
  border: none;
  background: var(--p9pf-bg);
  color: var(--p9pf-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.p9pf-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--p9pf-border-lt);
}

.p9pf-toggle-btn--active {
  background: var(--p9pf-dark);
  color: #fff;
}

/* ── Soft cost row ──────────────────────────────────────────────────────── */
.p9pf-soft-cost-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.p9pf-soft-cost-row .p9pf-input-prefix {
  flex: 1;
}

.p9pf-soft-desc {
  font-size: 11px;
  color: var(--p9pf-muted-lt);
  white-space: nowrap;
}

/* ── Checkbox field ─────────────────────────────────────────────────────── */
.p9pf-field--checkbox {
  justify-content: flex-end;
}

.p9pf-field--checkbox label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--p9pf-muted);
  margin-top: 18px;
}

.p9pf-field--checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ── Subsection ─────────────────────────────────────────────────────────── */
.p9pf-subsection {
  padding: 10px;
  background: var(--p9pf-bg);
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.p9pf-subsection-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--p9pf-muted);
}

.p9pf-optional {
  font-weight: 400;
  color: var(--p9pf-muted-lt);
}

/* ── AI estimate button ─────────────────────────────────────────────────── */
.p9pf-ai-estimate-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--p9pf-gold);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-weight: 500;
  transition: opacity 0.15s;
}

.p9pf-ai-estimate-btn:hover { opacity: 0.75; }

.p9pf-ai-source {
  font-size: 10px;
  color: var(--p9pf-muted-lt);
  padding: 3px 6px;
  background: var(--p9pf-gold-pale);
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.p9pf-ai-source::before {
  content: '⚑';
  font-size: 9px;
  color: var(--p9pf-gold);
}

/* ── Results panel ──────────────────────────────────────────────────────── */
.p9pf-results {
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  padding: 20px;
  box-shadow: var(--p9pf-shadow);
  min-height: 300px;
  /* Match the left input column's height (instead of just hugging its own
     content) so the empty-state / registration-gate placeholders — both much
     shorter than the actual dashboard — sit vertically centered in the
     available space rather than pinned to the top with dead space below.
     display:flex (rather than a percentage-height trick on the children)
     avoids the well-known cross-browser flakiness of percentage heights
     inside a stretched grid item. */
  align-self: stretch;
  display: flex;
  flex-direction: column;
  /* The empty state ↔ dashboard swap (e.g. right after "Apply to form")
     changes this panel's content height while it's on-screen. Without this,
     Chrome's scroll anchoring "helpfully" nudges the whole page by a few
     pixels to compensate, which is exactly the "page slides up a little
     and hides the buttons" behavior — opt this panel out of that. */
  overflow-anchor: none;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.p9pf-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: initial;
  gap: 12px;
  flex: 1 1 auto;
  padding: 60px 20px;
  text-align: center;
  color: var(--p9pf-muted-lt);
}

.p9pf-empty-state svg {
  opacity: 0.35;
}

.p9pf-empty-state p {
  font-size: 13px;
  margin: 0;
}

/* ── Warning flags ──────────────────────────────────────────────────────── */
.p9pf-flags {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.p9pf-flag {
  padding: 8px 12px;
  border-radius: var(--p9pf-radius);
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.p9pf-flag::before {
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 12px;
}

.p9pf-flag--danger {
  background: var(--p9pf-red-pale);
  border: 1px solid rgba(176, 58, 46, 0.18);
  color: var(--p9pf-red);
}
.p9pf-flag--danger::before { content: '✕'; }

.p9pf-flag--warn {
  background: var(--p9pf-amber-pale);
  border: 1px solid rgba(146, 96, 10, 0.18);
  color: var(--p9pf-amber);
}
.p9pf-flag--warn::before { content: '⚠'; }

.p9pf-flag--info {
  background: var(--p9pf-gold-pale);
  border: 1px solid var(--p9pf-gold-border);
  color: var(--p9pf-gold);
}
.p9pf-flag--info::before { content: 'i'; font-style: italic; font-weight: 600; }

/* ── Metrics grid ───────────────────────────────────────────────────────── */
.p9pf-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.p9pf-returns-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.p9pf-hold-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.p9pf-hold-mode-note {
  font-size: 12px;
  color: #6b7280;
  background: #f0f9ff;
  border-left: 3px solid #0ea5e9;
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 14px;
  line-height: 1.5;
}

@media (max-width: 680px) {
  .p9pf-metrics-grid,
  .p9pf-returns-grid,
  .p9pf-hold-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

.p9pf-metric {
  background: var(--p9pf-bg);
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  padding: 12px 14px;
}

.p9pf-metric--primary {
  background: var(--p9pf-dark);
  border-color: var(--p9pf-dark);
  grid-column: 1 / -1;
}

.p9pf-metric--primary .p9pf-metric-label {
  color: rgba(255, 255, 255, 0.55);
}

.p9pf-metric--primary .p9pf-metric-value {
  color: #fff;
  font-size: 24px;
}

.p9pf-metric--profit {
  background: var(--p9pf-green-pale);
  border-color: rgba(46, 125, 80, 0.14);
}

.p9pf-metric--profit .p9pf-metric-value {
  color: var(--p9pf-green);
}

.p9pf-metric--wide {
  grid-column: 1 / -1;
}

.p9pf-metric--mao {
  background: var(--p9pf-gold-pale);
  border-color: var(--p9pf-gold-border);
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.p9pf-metric--mao .p9pf-metric-label {
  flex-shrink: 0;
}

.p9pf-metric--mao .p9pf-metric-value {
  font-size: 22px;
  color: var(--p9pf-gold);
  flex-shrink: 0;
}

.p9pf-metric-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--p9pf-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.p9pf-metric-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  font-weight: 400;
  color: var(--p9pf-text);
  line-height: 1;
}

.p9pf-metric-sub {
  font-size: 10px;
  color: var(--p9pf-muted);
  margin-top: 4px;
  line-height: 1.35;
  text-align: left;
}

.p9pf-metric--mao .p9pf-metric-sub {
  flex: 1;
  text-align: right;
  margin-top: 0;
}

/* ── Cost breakdown bar ─────────────────────────────────────────────────── */
.p9pf-breakdown {
  margin: 14px 0;
}

.p9pf-breakdown-title {
  font-size: 10px;
  font-weight: 500;
  color: var(--p9pf-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.p9pf-breakdown-bar {
  height: 8px;
  border-radius: 4px;
  display: flex;
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--p9pf-border-lt);
}

.p9pf-bar-segment {
  height: 100%;
  transition: width 0.3s ease;
}

.p9pf-bar-land    { background: #9a6f2e; }
.p9pf-bar-hard    { background: #1a1814; }
.p9pf-bar-soft    { background: #6b6458; }
.p9pf-bar-finance { background: #b8a89a; }
.p9pf-bar-carry   { background: #c47c2b; }
.p9pf-bar-demo    { background: #7a5c3e; }
.p9pf-bar-mezz    { background: #8b5e8b; }
.p9pf-bar-platting { background: #4f7a6b; }
.p9pf-bar-offsite  { background: #3e6b8f; }
.p9pf-bar-impact   { background: #a3893e; }

/* Capital stack */
.p9pf-stack-senior { background: #1a3a5c; }
.p9pf-stack-mezz   { background: #8b5e8b; }
.p9pf-stack-equity { background: #2e7d32; }

.p9pf-breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.p9pf-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--p9pf-muted);
}

.p9pf-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Cumulative cash-flow chart ──────────────────────────────────────────── */
.p9pf-cashflow {
  margin: 16px 0;
}

.p9pf-cashflow-subtitle {
  font-size: 11px;
  color: var(--p9pf-muted);
  margin: 2px 0 10px;
  line-height: 1.4;
}

.p9pf-cashflow-chart {
  width: 100%;
  height: 170px;
  display: block;
}

.p9pf-cashflow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 6px;
}

.p9pf-cashflow-legend .p9pf-legend-item {
  font-size: 10px;
}

.p9pf-legend-dot--red {
  background: var(--p9pf-red);
}

.p9pf-legend-dot--green {
  background: var(--p9pf-green);
}

.p9pf-legend-dot--dash {
  background: none;
  width: 10px;
  height: 0;
  border-top: 1px dashed var(--p9pf-muted-lt);
  border-radius: 0;
}

.p9pf-cashflow-caption {
  font-size: 11px;
  color: var(--p9pf-muted);
  margin-top: 6px;
  font-weight: 600;
}

.p9pf-cashflow-slider-wrap {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--p9pf-bg);
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
}

.p9pf-cashflow-slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.p9pf-cashflow-slider-head label {
  font-size: 11px;
  color: var(--p9pf-muted);
}

.p9pf-cashflow-slider-head label strong {
  color: var(--p9pf-text);
  font-weight: 600;
}

.p9pf-cashflow-slider-jumps {
  display: flex;
  gap: 6px;
}

.p9pf-cashflow-jump-btn {
  font-size: 10px;
  font-weight: 500;
  color: var(--p9pf-gold);
  background: var(--p9pf-gold-pale);
  border: 1px solid var(--p9pf-gold-border);
  border-radius: 3px;
  padding: 3px 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.p9pf-cashflow-jump-btn:hover {
  opacity: 0.75;
}

.p9pf-cashflow-jump-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.p9pf-cashflow-slider {
  width: 100%;
  display: block;
  accent-color: var(--p9pf-gold);
  margin: 4px 0 10px;
}

.p9pf-cashflow-slider-readout {
  font-size: 15px;
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--p9pf-text);
  line-height: 1.5;
}

.p9pf-cashflow-slider-time {
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--p9pf-muted);
}

.p9pf-cashflow-slider-verdict {
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Scenario comparison ─────────────────────────────────────────────────── */
.p9pf-scenarios {
  margin: 16px 0;
}

.p9pf-scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 680px) {
  .p9pf-scenario-grid {
    grid-template-columns: 1fr;
  }
}

.p9pf-scenario-card {
  background: var(--p9pf-bg);
  border: 1px solid var(--p9pf-border-lt);
  border-radius: var(--p9pf-radius);
  padding: 10px 12px;
}

.p9pf-scenario-card--base {
  background: var(--p9pf-gold-pale);
  border-color: var(--p9pf-gold-border);
}

.p9pf-scenario-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--p9pf-border-lt);
}

.p9pf-scenario-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--p9pf-text);
}

.p9pf-scenario-hint {
  font-size: 9.5px;
  color: var(--p9pf-muted-lt);
}

.p9pf-scenario-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--p9pf-muted);
  padding: 3px 0;
}

.p9pf-scenario-row strong {
  color: var(--p9pf-text);
  font-weight: 600;
}

/* ── HUD eligibility chip ───────────────────────────────────────────────── */
.p9pf-hud-row {
  margin: 8px 0;
}

.p9pf-hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 500;
}

.p9pf-hud-chip--eligible {
  background: var(--p9pf-green-pale);
  color: var(--p9pf-green);
  border: 1px solid rgba(46, 125, 80, 0.2);
}

.p9pf-hud-chip--ineligible {
  background: var(--p9pf-border-lt);
  color: var(--p9pf-muted);
  border: 1px solid var(--p9pf-border-lt);
}

/* ── HUD max-loan detail panel ──────────────────────────────────────────── */
.p9pf-hud-panel {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--p9pf-green-pale);
  border: 1px solid rgba(46, 125, 80, 0.18);
  border-radius: var(--p9pf-radius);
}

.p9pf-hud-panel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.p9pf-hud-panel-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 15px;
  color: var(--p9pf-text);
}

.p9pf-hud-panel-item--binding .p9pf-hud-panel-value {
  color: var(--p9pf-green);
  font-weight: 600;
}

.p9pf-hud-panel-note {
  font-size: 10.5px;
  color: var(--p9pf-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(46, 125, 80, 0.15);
  line-height: 1.5;
}

/* ── AI narration block ─────────────────────────────────────────────────── */
.p9pf-narration {
  margin-bottom: 16px;
  padding: 14px;
  background: var(--p9pf-gold-pale);
  border: 1px solid var(--p9pf-gold-border);
  border-radius: var(--p9pf-radius);
}

.p9pf-narration-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--p9pf-gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.p9pf-narration-text {
  font-size: 13px;
  color: var(--p9pf-text);
  line-height: 1.6;
}

.p9pf-narration-text strong,
.p9pf-narration-text b {
  color: var(--p9pf-dark);
  font-weight: 600;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.p9pf-ai-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.p9pf-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--p9pf-radius);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s, border-color 0.15s;
  white-space: nowrap;
}

/* Must come after `.p9pf-btn` in source order — equal specificity means the
   later rule wins, and this needs to override the base padding/font-size. */
.p9pf-btn--sm {
  padding: 6px 14px;
  font-size: 11px;
}

/* Burnt-orange primary — brighter and more inviting than a plain dark/black
   button, and reads as an active brand CTA against the theme. */
.p9pf-btn--ai {
  background: var(--p9pf-orange);
  color: #fff;
  border-color: var(--p9pf-orange);
  box-shadow: var(--p9pf-shadow);
}

.p9pf-btn--ai:hover {
  background: var(--p9pf-orange-dark);
  border-color: var(--p9pf-orange-dark);
  opacity: 1;
}

.p9pf-btn--ai:disabled {
  opacity: 0.5;
  cursor: default;
}

.p9pf-btn--ghost {
  background: transparent;
  color: var(--p9pf-muted);
  border-color: var(--p9pf-border);
}

.p9pf-btn--ghost:hover {
  color: var(--p9pf-gold);
  border-color: var(--p9pf-gold);
}

/* Solid gold CTA — used for the toolbar's "Save analysis" and the intake
   chat's "Apply" step. Distinct from the burnt-orange `--ai` buttons, which
   are reserved for AI-triggered actions. */
.p9pf-btn--primary {
  background: var(--p9pf-gold);
  color: #fff;
  border-color: var(--p9pf-gold);
  box-shadow: var(--p9pf-shadow);
}

.p9pf-btn--primary:hover:not(:disabled) {
  background: var(--p9pf-gold-hover);
  border-color: var(--p9pf-gold-hover);
}

.p9pf-btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Save PDF menu ─────────────────────────────────────────────────────── */

.p9pf-pdf-menu-wrap { position: relative; display: inline-flex; }

.p9pf-pdf-caret { transition: transform 0.15s; }
.p9pf-pdf-menu-wrap.is-open .p9pf-pdf-caret { transform: rotate(180deg); }

.p9pf-pdf-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 45;
  width: 300px;
  max-width: calc(100vw - 32px);
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  box-shadow: var(--p9pf-shadow-md);
  padding: 6px;
}

.p9pf-pdf-menu-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-radius: var(--p9pf-radius);
  color: var(--p9pf-text);
  text-align: left;
  cursor: pointer;
}
.p9pf-pdf-menu-item:hover { background: var(--p9pf-bg); }
.p9pf-pdf-menu-item svg { flex-shrink: 0; margin-top: 1px; color: var(--p9pf-gold); }
.p9pf-pdf-menu-item span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.p9pf-pdf-menu-item strong { font-size: 13px; font-weight: 600; color: var(--p9pf-text); }
.p9pf-pdf-menu-item small { font-size: 11px; color: var(--p9pf-muted-lt); }
.p9pf-pdf-menu-item:disabled { cursor: default; opacity: 0.55; }
.p9pf-pdf-menu-item:disabled:hover { background: transparent; }

.p9pf-pdf-workspace-panel {
  margin-top: 4px;
  padding: 8px 10px 4px;
  border-top: 1px solid var(--p9pf-border-lt);
}

.p9pf-pdf-workspace-panel .p9pf-pdf-ws-hint {
  font-size: 12px;
  color: var(--p9pf-muted);
  line-height: 1.4;
  margin: 0 0 8px;
}

.p9pf-pdf-workspace-panel .p9pf-pdf-ws-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--p9pf-gold);
  text-decoration: none;
}
.p9pf-pdf-workspace-panel .p9pf-pdf-ws-link:hover { text-decoration: underline; }

.p9pf-pdf-ws-project-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 180px; overflow-y: auto; }

.p9pf-pdf-ws-project {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 8px;
  background: transparent;
  border: none;
  border-radius: var(--p9pf-radius);
  font-size: 12.5px;
  color: var(--p9pf-text);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p9pf-pdf-ws-project:hover { background: var(--p9pf-bg); }
.p9pf-pdf-ws-project.is-selected { background: var(--p9pf-gold-pale); font-weight: 600; }

.p9pf-pdf-ws-status {
  font-size: 12px;
  padding: 4px 2px 6px;
  color: var(--p9pf-muted);
}
.p9pf-pdf-ws-status.is-error   { color: var(--p9pf-red); }
.p9pf-pdf-ws-status.is-success { color: var(--p9pf-green); }

.p9pf-pdf-ws-create { margin-top: 4px; }

.p9pf-pdf-ws-create-toggle {
  background: none;
  border: none;
  padding: 4px 2px;
  cursor: pointer;
}

.p9pf-pdf-ws-create-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.p9pf-pdf-ws-create-input {
  width: 100%;
  padding: 7px 9px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--p9pf-text);
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  box-sizing: border-box;
}
.p9pf-pdf-ws-create-input:focus {
  outline: none;
  border-color: var(--p9pf-gold);
  box-shadow: 0 0 0 3px var(--p9pf-gold-pale);
}

.p9pf-pdf-ws-create-btn {
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: var(--p9pf-orange);
  border: 1px solid var(--p9pf-orange);
  border-radius: var(--p9pf-radius);
  cursor: pointer;
}
.p9pf-pdf-ws-create-btn:hover:not(:disabled) { background: var(--p9pf-orange-dark); }
.p9pf-pdf-ws-create-btn:disabled { opacity: 0.6; cursor: default; }

/* Loading spinner on button */
.p9pf-btn--loading::after {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: p9pf-spin 0.6s linear infinite;
}

@keyframes p9pf-spin {
  to { transform: rotate(360deg); }
}

/* Source attribution chip inside AI message */
.p9pf-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--p9pf-gold);
  background: var(--p9pf-gold-pale);
  border: 1px solid var(--p9pf-gold-border);
  border-radius: 2px;
  padding: 2px 6px;
  margin: 4px 2px 2px;
  vertical-align: middle;
}

/* Apply scenario button */
.p9pf-apply-scenario {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--p9pf-gold-pale);
  border: 1px solid var(--p9pf-gold-border);
  border-radius: var(--p9pf-radius);
  color: var(--p9pf-gold);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.15s;
}

.p9pf-apply-scenario:hover {
  background: rgba(154, 111, 46, 0.2);
}

.p9pf-apply-scenario.is-applied {
  background: var(--p9pf-green-pale);
  border-color: rgba(46, 125, 80, 0.2);
  color: var(--p9pf-green);
  cursor: default;
}

/* ── AI inline markdown elements ───────────────────────────────────────── */
.p9pf-ai-heading {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--p9pf-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.p9pf-ai-note {
  display: block;
  font-size: 11px;
  color: var(--p9pf-muted);
  line-height: 1.55;
  padding: 6px 10px;
  background: var(--p9pf-bg);
  border-left: 2px solid var(--p9pf-gold-border);
  border-radius: 0 2px 2px 0;
  margin-top: 6px;
}

/* ── AI table (rendered from markdown) ─────────────────────────────────── */
.p9pf-ai-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
  font-size: 11.5px;
}

.p9pf-ai-table th,
.p9pf-ai-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--p9pf-border-lt);
  vertical-align: top;
  line-height: 1.45;
}

.p9pf-ai-table th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--p9pf-muted);
  background: var(--p9pf-bg);
  border-bottom-color: var(--p9pf-border);
}

.p9pf-ai-table td:first-child {
  font-weight: 600;
  color: var(--p9pf-dark);
  white-space: nowrap;
}

.p9pf-ai-table tr:last-child td {
  border-bottom: none;
}

/* ── Capital stack section ───────────────────────────────────────────────── */
.p9pf-capital-stack {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--p9pf-border-lt);
}

.p9pf-stack-bar {
  display: flex;
  height: 10px;
  border-radius: var(--p9pf-radius);
  overflow: hidden;
  gap: 2px;
  margin: 8px 0;
}

.p9pf-stack-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Mezz subsection ─────────────────────────────────────────────────────── */
.p9pf-subsection--mezz {
  border-top: 1px solid var(--p9pf-border-lt);
  margin-top: 12px;
  padding-top: 10px;
}

/* ── Skeleton loading state ─────────────────────────────────────────────── */
.p9pf-skeleton {
  background: linear-gradient(90deg, var(--p9pf-bg) 25%, var(--p9pf-border-lt) 50%, var(--p9pf-bg) 75%);
  background-size: 200% 100%;
  animation: p9pf-shimmer 1.4s infinite;
  border-radius: 3px;
}

@keyframes p9pf-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Results gate overlay ────────────────────────────────────────────────── */
.p9pf-results-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  box-shadow: var(--p9pf-shadow);
  flex: 1 1 auto;
  min-height: 280px;
  position: relative;
  overflow: hidden;
}

/* Gold accent strip across the top */
.p9pf-results-gate::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--p9pf-gold);
  border-radius: var(--p9pf-radius) var(--p9pf-radius) 0 0;
}

.p9pf-gate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  gap: 4px;
  color: var(--p9pf-text);
}

/* Circular gold icon badge */
.p9pf-gate-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--p9pf-gold-pale);
  border: 1px solid var(--p9pf-gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--p9pf-gold);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.p9pf-gate-eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--p9pf-gold);
}

.p9pf-gate-title {
  margin: 0 0 10px;
  font-family: var(--p9pf-font-serif);
  font-size: clamp(19px, 3.4vw, 24px);
  font-weight: 400;
  line-height: 1.35;
  color: var(--p9pf-text);
}

.p9pf-gate-body {
  margin: 0 auto 16px;
  font-size: 13px;
  color: var(--p9pf-muted);
  line-height: 1.6;
  max-width: 340px;
}

.p9pf-gate-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.p9pf-gate-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--p9pf-muted);
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border-lt);
  border-radius: 20px;
  padding: 4px 10px;
}
.p9pf-gate-pill svg { color: var(--p9pf-gold); flex-shrink: 0; }

.p9pf-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.p9pf-gate-cta {
  min-width: 200px;
  justify-content: center;
  background: var(--p9pf-gold) !important;
  border-color: var(--p9pf-gold) !important;
  color: #fff !important;
}
.p9pf-gate-cta:hover { opacity: 0.88 !important; }

.p9pf-gate-login {
  font-size: 12px;
  color: var(--p9pf-muted);
  text-decoration: none;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s;
}
.p9pf-gate-login:hover { color: var(--p9pf-gold); }

/* ── "Start Now" gate (guest bot-check) ──────────────────────────────────── */
/* Covers just the intake chat box (.p9pf-intake-box, its parent here) until
   a guest clicks through — see initStartGate() / initStartGateAcq() in
   p9-proforma.js / p9-acquisition.js. Absolutely positioned over
   .p9pf-start-gated, which just needs position:relative. While the gate is
   actually showing, showStartGate()/hideStartGate() toggle .p9pf-gate-active
   on the box to give the content below a bit of breathing room so it
   doesn't clip against overflow:hidden. */
/* :not(--floating) — while popped out, the box is already position:fixed
   (itself a valid containing block for the absolutely-positioned
   .p9pf-start-gate overlay), and that :fixed must win. Without this
   exclusion, this rule's position:relative has equal specificity to (and
   loads after) .p9pf-intake-box--floating's position:fixed, so it silently
   clobbers it — collapsing the floating box out of position:fixed and into
   normal flow as the last element on <body>, which is what made it appear
   to "jump to the bottom-left" the moment the chat popped out. */
.p9pf-start-gated:not(.p9pf-intake-box--floating) { position: relative; min-height: 220px; }
.p9pf-start-gated.p9pf-gate-active { min-height: 340px; }
.p9pf-start-gate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px 20px;
  background: var(--p9pf-bg-lt);
  border-radius: var(--p9pf-radius);
  overflow-y: auto;
}
.p9pf-start-gate .p9pf-gate-eyebrow { margin-bottom: 4px; }
.p9pf-start-gate .p9pf-gate-title { font-size: 16px; margin-bottom: 6px; }
.p9pf-start-gate .p9pf-gate-body { max-width: 320px; font-size: 12.5px; line-height: 1.5; margin-bottom: 10px; }
.p9pf-start-gate .p9pf-turnstile-widget { margin-bottom: 6px; }
.p9pf-start-gate-status {
  min-height: 1.2em;
  font-size: 12px;
  color: var(--p9pf-muted);
  margin: 6px 0 0;
}

/* ── Gate modal (popup nudge when a guest tries a gated action from
   somewhere other than the results panel, e.g. the intake chat's "Run
   Parcl9 Analysis" button, which stays visible/clickable on purpose as a
   tease even while gated) ──────────────────────────────────────────────── */
/* <dialog>.showModal() renders in the browser's top layer, so this is
   immune to any ancestor transform/filter/contain hijacking position:fixed's
   containing block (which is what confined the old div-based overlay to a
   narrow box instead of the full viewport). */
dialog.p9pf-gate-modal {
  position: fixed;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  margin: auto;
  opacity: 1;
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  padding: 40px 24px;
  animation: p9pf-gate-modal-pop-in 0.18s ease-out forwards;
}

dialog.p9pf-gate-modal::backdrop {
  /* Darker + blurred (not just a light tint) so the busy dashboard behind
     doesn't visually compete with the card — a thin rgba wash alone let too
     much of the page bleed through and made the popup hard to focus on. */
  background: rgba(15, 12, 6, 0.78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: p9pf-gate-modal-fade-in 0.15s ease-out forwards;
}

@keyframes p9pf-gate-modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes p9pf-gate-modal-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Gold accent strip, matching the inline results gate */
dialog.p9pf-gate-modal::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--p9pf-gold);
  border-radius: var(--p9pf-radius) var(--p9pf-radius) 0 0;
}

.p9pf-gate-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--p9pf-muted-lt);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.p9pf-gate-modal-close:hover {
  background: var(--p9pf-border-lt);
  color: var(--p9pf-text);
}

/* ── Saved-analyses toolbar ──────────────────────────────────────────────── */
.p9pf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 9px 12px;
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  box-shadow: var(--p9pf-shadow);
  position: relative;
}

.p9pf-toolbar-left,
.p9pf-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.p9pf-saved-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--p9pf-gold);
  background: var(--p9pf-gold-pale);
  border-radius: 999px;
}

.p9pf-saved-count:empty {
  display: none;
}

/* Spins next to "My Analyses" itself while loadSavedList()'s initial
   request is in flight (see p9-proforma.js) — visible feedback that the
   count badge/panel aren't just empty yet, without needing to open the
   panel to find out. Hidden the rest of the time (toggled via
   #p9pf-saved-toggle.is-loading), including while the badge/list already
   have real data to show. Reuses the existing p9pf-spin keyframe. */
.p9pf-saved-toggle-spinner {
  display: none;
  width: 10px;
  height: 10px;
  border: 2px solid var(--p9pf-gold-pale);
  border-top-color: var(--p9pf-gold);
  border-radius: 50%;
  animation: p9pf-spin 0.6s linear infinite;
}
#p9pf-saved-toggle.is-loading .p9pf-saved-toggle-spinner { display: inline-block; }
#p9pf-saved-toggle.is-loading .p9pf-saved-count { display: none; }

.p9pf-save-msg {
  font-size: 12px;
  font-weight: 600;
  min-height: 16px;
}

@media (max-width: 640px) {
  .p9pf-toolbar       { flex-direction: column; align-items: stretch; }
  .p9pf-toolbar-right { flex-wrap: wrap; }
  .p9pf-saved-panel   { left: 0; right: 0; width: auto; }
}

.p9pf-save-new {
  font-size: 12px;
  color: var(--p9pf-muted);
}
.p9pf-save-new:hover { color: var(--p9pf-gold); }

/* Dropdown panel */
.p9pf-saved-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--p9pf-bg-lt);
  border: 1px solid var(--p9pf-border);
  border-radius: var(--p9pf-radius);
  box-shadow: var(--p9pf-shadow-md);
  padding: 6px;
}

.p9pf-saved-panel-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--p9pf-muted);
  padding: 6px 8px;
}

.p9pf-saved-list { list-style: none; margin: 0; padding: 0; }

.p9pf-saved-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--p9pf-radius);
}
.p9pf-saved-item:hover { background: var(--p9pf-bg); }
.p9pf-saved-item.is-current { background: var(--p9pf-gold-pale); }

.p9pf-saved-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.p9pf-saved-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--p9pf-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
}
.p9pf-saved-date { font-size: 11px; color: var(--p9pf-muted-lt); }

.p9pf-saved-rename,
.p9pf-saved-del {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--p9pf-radius);
  color: var(--p9pf-muted-lt);
  cursor: pointer;
}
.p9pf-saved-del { margin-right: 4px; }
.p9pf-saved-rename:hover { color: var(--p9pf-gold); background: var(--p9pf-gold-pale); }
.p9pf-saved-del:hover { color: var(--p9pf-red); background: var(--p9pf-red-pale); }

.p9pf-saved-empty {
  font-size: 12px;
  color: var(--p9pf-muted);
  padding: 10px 8px;
}

.p9pf-saved-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px;
  font-size: 12px;
  color: var(--p9pf-muted);
  text-align: center;
}
.p9pf-saved-loading-spinner {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border: 2px solid var(--p9pf-gold-pale);
  border-top-color: var(--p9pf-gold);
  border-radius: 50%;
  animation: p9pf-spin 0.6s linear infinite;
}

/* Ghost button variant used by gate */
/* ── Upgrade / access notice ─────────────────────────────────────────────── */
.p9pf-upgrade-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--p9pf-muted);
  padding: 6px 10px;
  background: rgba(108, 143, 255, 0.07);
  border: 1px solid rgba(108, 143, 255, 0.2);
  border-radius: 6px;
  margin-top: 6px;
}

.p9pf-upgrade-notice svg {
  flex-shrink: 0;
  color: var(--p9pf-accent, #6c8fff);
}

.p9pf-upgrade-notice a {
  color: var(--p9pf-accent, #6c8fff);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.p9pf-upgrade-notice a:hover {
  text-decoration: underline;
}

/* ── AI usage remaining badge ────────────────────────────────────────────── */
.p9pf-usage-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  color: var(--p9pf-muted);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.6;
}

.p9pf-usage-badge--empty {
  color: var(--p9pf-red, #f87171);
  background: rgba(248,113,113,0.08);
  border-color: rgba(248,113,113,0.2);
}
