/* Guided onboarding and documentation                                */
/* ------------------------------------------------------------------ */

.tour-active { overflow: hidden; }
.guided-tour[popover] { inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; overflow: visible; border: 0; background: transparent; color: inherit; }
.tour-veil { position: fixed; z-index: 900; background: rgba(26, 23, 18, .58); transition: all 140ms ease-out; }
.tour-target { position: relative; z-index: 901; outline: 2px solid var(--warn); outline-offset: 5px; border-radius: 0 !important; animation: tour-target-arrive 220ms ease-out both; }
.tour-popover {
  position: fixed;
  z-index: 902;
  width: min(360px, calc(100vw - 24px));
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(26, 23, 18, .18);
  animation: tour-enter 140ms ease-out both;
}
.tour-popover.is-positioned {
  transition: left 140ms ease-out, top 140ms ease-out;
}
.tour-popover h2 { margin: 3px 0 7px; font-size: 25px; line-height: 1.1; }
.tour-popover p { margin: 0; color: var(--ink-2); font-size: 14px; }
.tour-progress { color: var(--ink-3); font: 600 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; }
.tour-actions > span { display: flex; gap: 8px; }
.tour-actions button { min-width: 68px; padding: 9px 12px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); font: 600 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.tour-actions .tour-next { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.tour-actions button:disabled { opacity: .35; cursor: default; }
.tour-actions .tour-skip { min-width: 0; border-color: transparent; color: var(--ink-2); }
.tour-arrow { position: absolute; width: 0; height: 0; }
.tour-arrow::after { position: absolute; width: 0; height: 0; content: ""; }
.tour-arrow--top { top: -12px; border-right: 11px solid transparent; border-bottom: 12px solid var(--line-strong); border-left: 11px solid transparent; }
.tour-arrow--top::after { top: 2px; left: -10px; border-right: 10px solid transparent; border-bottom: 11px solid var(--panel); border-left: 10px solid transparent; }
.tour-arrow--bottom { bottom: -12px; border-top: 12px solid var(--line-strong); border-right: 11px solid transparent; border-left: 11px solid transparent; }
.tour-arrow--bottom::after { bottom: 2px; left: -10px; border-top: 11px solid var(--panel); border-right: 10px solid transparent; border-left: 10px solid transparent; }
.tour-arrow--top,.tour-arrow--bottom { transform: translateX(-50%); }
.tour-arrow--left { left: -12px; border-top: 11px solid transparent; border-right: 12px solid var(--line-strong); border-bottom: 11px solid transparent; transform: translateY(-50%); }
.tour-arrow--left::after { top: -10px; left: 2px; border-top: 10px solid transparent; border-right: 11px solid var(--panel); border-bottom: 10px solid transparent; }
.tour-arrow--right { right: -12px; border-top: 11px solid transparent; border-bottom: 11px solid transparent; border-left: 12px solid var(--line-strong); transform: translateY(-50%); }
.tour-arrow--right::after { top: -10px; right: 2px; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-left: 11px solid var(--panel); }
@keyframes tour-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes tour-target-arrive { from { outline-color: transparent; } to { outline-color: var(--warn); } }

.documentation-start { display: grid; grid-template-columns: minmax(230px, .55fr) 1fr; gap: 30px; align-items: start; }
.documentation-start h2 { margin-top: 0; }
.documentation-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; counter-reset: guide; border: 1px solid var(--line); }
.documentation-steps li { min-width: 0; padding: 17px; border-right: 1px solid var(--line); counter-increment: guide; }
.documentation-steps li:last-child { border-right: 0; }
.documentation-steps b,.documentation-steps span { display: block; }
.documentation-steps b::before { content: counter(guide) ". "; color: var(--warn); }
.documentation-steps span { margin-top: 5px; color: var(--ink-2); }
.documentation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.documentation-contextual { display: grid; grid-template-columns: minmax(260px, .65fr) minmax(320px, 1.35fr) auto; gap: 24px; align-items: center; margin-top: 18px; }
.documentation-contextual h2,.documentation-contextual p { margin-top: 0; margin-bottom: 0; }
.documentation-contextual .secondary { white-space: normal; text-align: center; }
.documentation-card { display: flex; flex-direction: column; align-items: flex-start; min-height: 280px; }
.documentation-card h2 { margin: 1px 0 8px; }
.documentation-card p { margin-top: 0; }
.documentation-card ul { margin: 4px 0 20px; padding-left: 19px; color: var(--ink-2); }
.documentation-card .secondary { margin-top: auto; }

@media (max-width: 760px) {
  .documentation-start,.documentation-grid,.documentation-contextual { grid-template-columns: 1fr; }
  .documentation-steps { grid-template-columns: 1fr; }
  .documentation-steps li { border-right: 0; border-bottom: 1px solid var(--line); }
  .documentation-steps li:last-child { border-bottom: 0; }
  .documentation-card { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tour-veil { transition: none; }
  .tour-popover,.tour-popover.is-positioned,.tour-target { animation: none; transition: none; }
}
.evidence-job-list { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.evidence-job-list > div {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.evidence-job-list span b,.evidence-job-list span small { display: block; }
.evidence-job-list span small { margin-top: 3px; color: var(--muted); }
.fund-underwriting-inputs { align-items: start; }
.case-planning-assumptions { margin: 26px 0; }
.diligence-score-grid {
  display: grid;
  grid-template-columns: repeat(5,minmax(0,1fr));
  border: 1px solid var(--line);
  margin: 18px 0;
}
.diligence-score-grid > div { min-width: 0; padding: 14px; border-right: 1px solid var(--line); }
.diligence-score-grid > div:last-child { border-right: 0; }
.diligence-score-grid span {
  display: block;
  color: var(--muted);
  font: 10px/1.35 var(--mono);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.diligence-score-grid strong { display: block; margin-top: 6px; font: 600 24px/1 var(--serif); }

@media (max-width: 1000px) {
  .fund-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .fund-summary > div { border-bottom: 1px solid var(--line); }
  .fund-grid { grid-template-columns: 1fr; }
  .fund-kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .fund-kpi-grid article { border-bottom: 1px solid var(--line); }
  .fund-workspace-grid { grid-template-columns: 1fr; }
  .scenario-results { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .scenario-results > div:nth-child(2n) { border-right: 0; }
  .scenario-results > div { border-bottom: 1px solid var(--line); }
  .scenario-results > div:nth-last-child(-n+2) { border-bottom: 0; }
  .scenario-runner { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .fund-pipeline-tools { grid-template-columns: 1fr 1fr; }
  .diligence-score-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .diligence-score-grid > div { border-bottom: 1px solid var(--line); }
  .planning-visuals-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .planning-visuals-head > small { max-width: none; text-align: left; }
  .comparison-row { grid-template-columns: 135px 72px minmax(120px,1fr) 72px; gap: 9px; }
}
@media (max-width: 600px) {
  .model-banner { align-items: flex-start; flex-direction: column; }
  .search { flex-direction: column; }
  .search input,.search button { width: 100%; }
  .page-head { gap: 18px; }
  .page-head > div:first-child { width: 100%; }
  .page-head h1 { font-size: 31px; line-height: 1.08; }
  .page-head .page-actions { justify-content: flex-start; width: 100%; }
  .page-head .page-actions > * { max-width: 100%; }
  .fund-hero .page-actions {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    width: 100%;
  }
  .fund-hero .page-actions button { width: 100%; min-height: 46px; }
  .fund-hero [data-dialog-open="new-investment-case"] {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .fund-summary, .fund-summary--compact { grid-template-columns: 1fr; }
  .fund-summary > div { border-right: 0; }
  .model-readiness-summary { grid-template-columns: 1fr; }
  .model-readiness-summary > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .readiness-list--plain > .readiness-row { grid-template-columns: 1fr; }
  .readiness-list--plain .badge { justify-self: start; }
  .outcome-horizon { grid-template-columns: 62px minmax(70px,1fr) 42px; }
  .fund-kpi-grid { grid-template-columns: 1fr; }
  .fund-kpi-grid article { border-right: 0; }
  .scenario-runner,.fund-pipeline-tools { grid-template-columns: 1fr; }
  .source-register--collapsed > summary { align-items: flex-start; flex-direction: column; }
  .source-register--collapsed > summary small { margin-left: 0; }
  .readiness-list > div,.review-rows > article { grid-template-columns: 1fr; }
  .fund-vehicle-stat { text-align: left; }
  .diligence-score-grid { grid-template-columns: 1fr; }
  .diligence-score-grid > div { border-right: 0; }
  .visual-tabs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .visual-tab { min-width: 0; border-bottom: 1px solid var(--line-strong); white-space: normal; }
  .visual-tab:nth-child(2n) { border-right: 0; }
  .visual-tab:nth-last-child(-n+2) { border-bottom: 0; }
  .planning-visual-panel { padding: 12px; }
  .visual-card { padding: 13px; }
  .visual-card-title { align-items: flex-start; flex-direction: column; gap: 6px; }
  .visual-card-title small { text-align: left; }
  .probability-row { grid-template-columns: 1fr 52px; gap: 7px 10px; }
  .probability-row .probability-track { grid-column: 1 / -1; grid-row: 2; }
  .probability-scale { margin: 4px 0 0; }
  .planning-visual-metrics--four { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .planning-visual-metrics--four > div:nth-child(2) { border-right: 0; }
  .planning-visual-metrics--four > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .scenario-range-labels { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .scenario-range-labels span:nth-child(2),.scenario-range-labels span:nth-child(3),.scenario-range-labels span:last-child { text-align: left; }
  .capital-allocation-track button span { writing-mode: vertical-rl; }
  .comparison-row { grid-template-columns: 1fr auto; gap: 5px 10px; }
  .comparison-row .comparison-track { grid-column: 1 / -1; grid-row: 2; }
  .comparison-row > small:first-of-type { text-align: right; }
  .comparison-row > small:last-child { grid-column: 2; grid-row: 1; }

  /* Capital detail is a long working surface. Keep every module inside the
     phone viewport and let header actions form a clean second row. */
  .capital-module > header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }
  .capital-module > header > div:first-child {
    flex: 1 1 calc(100% - 78px);
    min-width: 0;
  }
  .capital-module > header h2 { overflow-wrap: anywhere; }
  .capital-module > header .autofill-header-actions {
    order: 3;
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .capital-module > header .autofill-header-actions > * { width: 100%; }
  .capital-module > header .autofill-header-actions button { width: 100%; min-height: 42px; }
  .capital-module > header > .primary { order: 3; width: 100%; }
  .capital-module > header .module-collapse { margin-left: auto; min-height: 34px; }
  .autofill-run-status--applied { grid-template-columns: 1fr; }
  .autofill-evidence-summary { align-items: flex-start; flex-direction: column; gap: 6px; }
  .scorecard-status { align-items: flex-start; flex-direction: column; }
  .fund-scorecard .fund-summary strong { white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 720px) {
  .report-grid { grid-template-columns: 1fr; }
  .report-summary { flex-direction: column; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; }
  dialog form,
  .form-grid { grid-template-columns: 1fr; }
  .main { padding: 20px 14px 48px; }
  .account b { display: block; }
  .panel { padding: 18px; }
  .panel > header { margin: -18px -18px 18px; padding: 15px 18px; }
  .small,
  .danger { min-height: 40px; }
}

/* ------------------------------------------------------------------ */
/* Batch A additions                                                   */
/* ------------------------------------------------------------------ */

/* title row: status badge inline with the H1 */
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0 8px; }
.title-row h1 { margin: 0; }

/* quiet danger text button (Archive in panel headers) */
.header-actions { display: flex; gap: 14px; align-items: center; }
.danger-text {
  border: 0;
  background: none;
  padding: 0;
  color: var(--crit-ink);
  font: 600 10px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
}
.danger-text:hover { color: var(--crit); }

/* quiet "Completed" action cards */
.card--done h2, .card--done p { color: var(--ink-3); }

/* collapsible section (details + summary) */
.section-details { margin: 0 0 32px; min-width: 0; }
.section-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-details > summary::-webkit-details-marker { display: none; }
.section-details > summary::before {
  content: "▸";
  font: 400 11px var(--mono);
  color: var(--ink-3);
}

.section-details[open] > summary::before { content: "▾"; }
.section-details > summary.section-title { margin: 0; }
.section-details[open] > summary.section-title { margin: 0 0 16px; }

/* collapsible panel boxes (opportunity groups, enrichment sections) */
details.panel-details {
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  padding: 14px 24px 20px;
}

.panel-details > summary { padding: 2px 0; }
.panel-details > summary .panel-summary { display: grid; gap: 4px; }
.panel-details > summary h2 { margin: 0; }
.panel-details > summary .eyebrow { margin: 0; }
.panel .ledger-table,
.panel-details .ledger-table { margin: 0; }
.deferred-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 2px;
  border-top: 1px solid var(--line);
}
.deferred-section p { margin: 0; color: var(--ink-3); }

/* proposal outline sections + teaming fetch row (opportunity detail) */
.outline-section { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.outline-section h3 { font: 500 15px var(--serif); margin: 0 0 4px; }
.outline-section > p { margin: 0 0 8px; }
.outline-section .chip-row { margin: 0 0 8px; }
.teaming-actions { margin: 12px 0 0; }

/* collapsible sidebar rail */
.sidebar nav a .rail { display: none; }

.sidebar-toggle {
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  padding: 6px;
  border-radius: 2px;
  color: var(--ink-3);
  cursor: pointer;
}

.sidebar-toggle:hover { background: var(--panel-hi); color: var(--ink); }

@media (min-width: 901px) {
  body.shell--collapsed .sidebar { width: 56px; padding: 20px 8px; }
  body.shell--collapsed .content-wrap { margin-left: 56px; }
  body.shell--collapsed .sidebar-top { flex-direction: column; gap: 14px; padding: 0; }
  body.shell--collapsed .brand { justify-content: center; padding: 0; }
  body.shell--collapsed .brand span,
  body.shell--collapsed .sidebar nav a .label,
  body.shell--collapsed .account span { display: none; }
  body.shell--collapsed .sidebar nav a { display: flex; justify-content: center; padding: 9px 0; }
  body.shell--collapsed .sidebar nav a .rail {
    display: block;
    font: 600 10px var(--mono);
    letter-spacing: .08em;
  }
  body.shell--collapsed .account { align-items: center; padding: 12px 0 0; }
  body.shell--collapsed .company-switch { display: none; }
}

/* ------------------------------------------------------------------ */
/* Batch B additions                                                   */
/* ------------------------------------------------------------------ */

.is-hidden { display: none !important; }

/* inline status/priority selects on action cards */
.inline-edit { display: flex; gap: 8px; }

.inline-edit select {
  width: auto;
  padding: 6px 8px;
  font: 500 10px var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--panel);
  color: var(--ink-2);
}

.inline-edit select:hover { background: var(--panel-hi); color: var(--ink); }

/* paired badges in row lists */
.row-badges { display: flex; gap: 6px; flex: 0 0 auto; }

/* quiet sort control rows */
.sort-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font: 600 10px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: -16px 0 20px;
}

.sort-row a { color: var(--ink-3); text-decoration: none; }
.sort-row a:hover { color: var(--ink); }
.sort-row a[aria-current] { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* scroll-capped relationship lists */
.rows-scroll { max-height: 420px; overflow-y: auto; }

/* input + inline button row inside labels */
.field-row { display: flex; gap: 8px; align-items: stretch; }
.field-row input { flex: 1; width: auto; }
.field-row .small { white-space: nowrap; }

/* tag filter chips */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 24px; }

/* tag chips on memory cards */
.card .card-tags { margin: 12px 0 0; }

.chip {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  font: 600 10px var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

a.chip:hover, button.chip:hover { background: var(--panel-hi); color: var(--ink); }
.chip--active { background: var(--ink-fill); border-color: var(--ink-fill); color: var(--paper); }

/* AI suggestion block (interview panel) */
.suggested-questions { margin: 0 0 20px; }
.suggested-questions .source-note { margin: 0 0 8px; }

/* AI follow-up thread (analysis result) */
.follow-up-form { display: flex; gap: 10px; margin-top: 16px; }
.follow-up-form input { flex: 1; width: auto; }
.follow-up-form .small { white-space: nowrap; }
.follow-up-thread { margin-top: 12px; }
.follow-up-q { font: 600 11px var(--mono); color: var(--ink-2); margin: 10px 0 2px; }
.follow-up-a { margin: 0; color: var(--ink); }
.follow-up-error { color: var(--crit-ink); }
.follow-up-meta {
  font: 600 10px var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 8px 0 2px;
}

/* Monolith AI answer block (memory Ask panel) */
.ai-answer { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.ai-answer .eyebrow { margin: 0 0 6px; }
.ai-answer > p { margin: 0 0 8px; }
.ai-sources { color: var(--ink-3); font: 400 11px var(--mono); }

/* read-only profile values may contain line-broken lists */
.profile-view-list dd { white-space: pre-line; }


/* ------------------------------------------------------------------ */
/* Feedback round additions                                            */
/* ------------------------------------------------------------------ */

/* equal-height, fill relationship panels (CRM overview) */
.fill-panels > .panel { display: flex; flex-direction: column; }
.fill-panels .rows { flex: 1; }


/* collapsed older analysis runs (assessment detail) */
.old-analysis { margin: 0 0 16px; }
.old-analysis > summary {
  font: 600 11px var(--mono);
  letter-spacing: .08em;
  color: var(--ink-2);
  padding: 10px 0;
}

/* AI draft-context note inside the new-assessment dialog */
.draft-context-row { margin: -12px 0 0; }


/* ------------------------------------------------------------------ */
