#dialog:has(.portfolio-review) {
  width: min(1056px, calc(100% - 40px));
  max-width: none;
  max-height: 92dvh;
  overflow: hidden;
  background: var(--card);
}
#dialog[open]:has(.portfolio-review) { display: flex; flex-direction: column; }
#dialog:has(.portfolio-review) .modalhead { flex-shrink: 0; align-items: center; padding: 22px 30px 20px; }
#dialog:has(.portfolio-review) .modalhead h2 { font: 600 var(--type-dialog)/1.25 var(--display); }
#dialog:has(.portfolio-review) .modalhead p { margin-top: 6px; font-size: 14px; color: var(--muted-foreground); }
#dialog:has(.portfolio-review) .modalbody { display: flex; flex-direction: column; min-height: 0; padding: 0; max-height: none; overflow: hidden; }

.portfolio-review { --pr-line: #343a40; --pr-tint: #d5dcdf; display: flex; flex-direction: column; min-height: 0; background: #13181e; overflow-wrap: anywhere; }
.pr-layout { display: grid; grid-template-columns: minmax(205px, 24%) minmax(0,1fr); min-height: 0; overflow: auto; overscroll-behavior: contain; }
.pr-snapshot { padding: 24px 25px; border-right: 1px solid var(--pr-line); background: #10151a; }
.pr-snapshot h3, .pr-progress span { font: 500 14px/1.5 var(--font-sans); color: #c0c8cc; }
.pr-amount { color: var(--primary); font: 500 var(--type-metric)/1.1 Georgia, var(--display); margin: 8px 0 6px; }
.pr-amount small { font: 500 15px/1.4 var(--font-sans); margin-left: 6px; color: var(--primary); }
.pr-budget, .pr-usage { color: var(--muted-foreground); font-size: 14px; }
.pr-budget b { color: var(--pr-tint); font-weight: 550; }
.pr-capital meter { display: block; appearance: none; width: 100%; height: 4px; margin: 17px 0 8px; border: 0; background: #343638; border-radius: 3px; }
.pr-capital meter::-webkit-meter-inner-element { display: block; }
.pr-capital meter::-webkit-meter-bar { border: 0; border-radius: 3px; background: #343638; }
.pr-capital meter::-webkit-meter-optimum-value { background: var(--primary); border-radius: 3px; }
.pr-usage, .pr-progress { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pr-usage b { color: var(--primary); font-weight: 550; }
.pr-health { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--pr-line); }
.pr-health dl { margin: 10px 0 0; }
.pr-health dl > div { display: flex; align-items: baseline; justify-content: space-between; padding: 5px 0; }
.pr-risk { --pr-ink: #e5a093; }
.pr-watch { --pr-ink: #e7c087; }
.pr-healthy { --pr-ink: #99cbb6; }
.pr-health dt, .pr-health dd, .pr-health-text { color: var(--pr-ink, var(--pr-tint)); }
.pr-health dd { margin: 0; font-size: var(--type-stat); }
.pr-health small { color: var(--muted-foreground); font-size: 13px; }
.pr-progress { margin-top: 13px; border-top: 1px solid var(--pr-line); padding-top: 15px; font-size: var(--type-stat); font-weight: 550; }
.pr-work { min-width: 0; height: min(540px, calc(90dvh - 190px)); overflow-y: auto; overscroll-behavior: contain; padding: 0 clamp(18px,2.1vw,32px) 15px; scrollbar-color: #4d555c transparent; }
.pr-tabs { display: flex; gap: 24px; position: sticky; top: 0; z-index: 1; background: #13181e; border-bottom: 1px solid var(--pr-line); }
.pr-tabs button { background: none; border: 0; border-radius: 0; padding: 18px 0 14px; color: var(--muted-foreground); font: 550 17px/1.45 var(--font-sans); cursor: pointer; }
.pr-tabs button[aria-selected="true"] { color: var(--primary); box-shadow: inset 0 -2px var(--primary); }
.pr-tabs b { font-size: 13px; margin-left: 2px; font-weight: 550; }
.pr-tabs button:focus-visible { outline-offset: -3px; }
.portfolio-review [hidden] { display: none; }
.portfolio-review details { margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--pr-line); border-radius: 0; background: transparent; }
.portfolio-review details:last-child { border-bottom: 0; }
.portfolio-review summary { list-style: none; border: 0; border-radius: 0; color: var(--foreground); cursor: pointer; }
.portfolio-review summary::-webkit-details-marker { display: none; }
.pr-issue summary { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 4px 12px; padding: 15px 0; }
.pr-issue-caption { grid-column: 1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; color: #abb5ba; font-size: 13px; }
.pr-issue-caption .pr-health-text { padding-right: 10px; border-right: 1px solid #44484c; }
.pr-issue summary strong { grid-column: 1; font: 600 var(--type-card)/1.42 var(--display); }
.pr-issue[open] summary strong { font-size: var(--type-section); }
.pr-disclosure { grid-column: 2; grid-row: 1/3; color: var(--muted-foreground); }
.portfolio-review details[open] > summary .icon { transform: rotate(180deg); }
.pr-issue-body { padding: 0 0 15px; }
.pr-facts { margin: 0; }
.pr-facts > div { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 12px; margin: 5px 0; }
.pr-facts dt, .pr-evidence > span { color: #aab3b9; font-size: 14px; }
.pr-facts dd { margin: 0; color: #e2e2d9; font-size: 15px; line-height: 1.6; }
.pr-issue-body .pr-facts > div:last-child dd { color: #e8d0a8; }
.pr-evidence { margin-top: 12px; padding: 9px 12px; background: #1b2228; color: #c4cfd4; font-size: 14px; line-height: 1.6; border-radius: 4px; }
.pr-evidence > span { display: inline-block; margin-right: 10px; }
.pr-issue-foot, .pr-export { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pr-issue-foot { margin-top: 5px; }
.pr-issue-foot > span { color: var(--muted-foreground); font-size: 13px; }
.pr-link { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; color: var(--primary); font-size: 14px; font-weight: 550; }
.pr-project-cols, .pr-project summary { display: grid; grid-template-columns: minmax(130px,1fr) 48px 50px 128px 16px; gap: 10px; align-items: center; }
.pr-project-cols { color: var(--muted-foreground); font-size: 13px; padding: 14px 0 8px; border-bottom: 1px solid var(--pr-line); }
.pr-project summary { padding: 10px 0; font-size: 15px; }
.pr-project-name strong, .pr-project-name small { display: block; }
.pr-project-name strong { font: 600 17px/1.55 var(--display); }
.pr-project-name small { font-size: 12px; color: #abb5ba; }
.pr-project summary > .icon { color: var(--muted-foreground); }
.pr-pct small, .pr-cost small { display: none; }
.pr-cost i { color: var(--muted-foreground); font-style: normal; }
.pr-project-body { background: #181e25; padding: 9px 14px 5px; margin: 0 0 9px; }
.pr-empty { margin: 26px 0; color: var(--muted-foreground); }
.pr-export { flex-shrink: 0; border-top: 1px solid var(--pr-line); padding: 12px 25px; background: #161b21; }
.pr-export > span { color: #b7c0c5; font-size: 13px; }
.pr-export .pr-copy { flex-shrink: 0; color: #f1d39f; border-color: #71604a; background: #302a22; min-height: 40px; }
.pr-manual { display: block; flex: 0 1 105px; width: calc(100% - 32px); min-height: 60px; margin: 8px 16px; }
@media (hover: hover) {
  .portfolio-review summary:hover strong, .pr-tabs button:hover { color: var(--primary); }
  .pr-link:hover { text-decoration: underline; }
}
@media (max-width: 790px) {
  #dialog:has(.portfolio-review) { width: min(650px, calc(100% - 18px)); }
  #dialog:has(.portfolio-review) .modalhead { padding: 14px 16px; }
  #dialog:has(.portfolio-review) .modalhead p { font-size: 13px; }
  .pr-layout { display: block; }
  .pr-snapshot { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); column-gap: 18px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--pr-line); }
  .pr-capital { grid-row: span 2; padding-right: 16px; border-right: 1px solid var(--pr-line); }
  .pr-amount {  margin: 3px 0; }
  .pr-amount small, .pr-usage, .pr-budget { font-size: 13px; }
  .pr-capital meter { margin: 9px 0 5px; }
  .pr-health, .pr-progress { margin: 0; padding: 0; border: 0; }
  .pr-health dl { margin: 4px 0; }
  .pr-health dl > div { padding: 0; }
  .pr-health dt, .pr-health dd, .pr-progress { font-size: 14px; }
  .pr-progress { border-top: 1px solid var(--pr-line); padding-top: 3px; }
  .pr-work { height: auto; overflow: visible; padding: 0 16px 8px; }
  .pr-tabs button { min-height: 44px; padding-block: 13px 10px; font-size: 16px; }
  .pr-export { padding: 10px 16px; }
  .pr-export .pr-copy, .pr-link { min-height: 44px; }
}
@media (max-width: 600px) {
  .pr-project-cols { display: none; }
  .pr-project summary { grid-template-columns: 1fr auto 16px; gap: 1px 9px; padding: 12px 0; }
  .pr-project-name { grid-column: 1; grid-row: 1; }
  .pr-project summary .pr-health-text { grid-column: 2; grid-row: 1; }
  .pr-project summary > .icon { grid-column: 3; grid-row: 1; }
  .pr-pct { grid-column: 1; grid-row: 2; }
  .pr-cost { grid-column: 1/-1; grid-row: 3; }
  .pr-pct small, .pr-cost small { display: inline; color: var(--muted-foreground); }
  .pr-issue summary { padding: 12px 0; }
  .pr-export { flex-wrap: wrap; gap: 5px 12px; }
}
