/* Estimator-specific styling leaves the other screens unchanged. */
.estimator-compact.page { max-width:1800px; padding-top:22px; }
.estimator-compact .context-bar { margin-bottom:18px; gap:14px; }
.estimator-compact .context-bar h1 { font-size:1.7rem; }
.estimator-compact .page-intro { font-size:.85rem; }
.estimator-compact .summary-grid { display:grid; grid-template-columns:2fr 1fr 1fr; gap:0; border:1px solid var(--border); border-radius:10px; background:var(--surface); margin-bottom:12px; overflow:hidden; }
.estimator-compact .summary-card { min-height:0; padding:14px 20px; background:transparent; border:0; border-radius:0; box-shadow:none; }
.estimator-compact .summary-card + .summary-card { border-left:1px solid var(--border); }
.estimator-compact .summary-card.hero { grid-column:auto; }
.estimator-compact .summary-card::after { display:none; }
.estimator-compact .summary-label { margin-bottom:4px; font-size:.75rem; }
.estimator-compact .summary-value { font-size:1.7rem; margin-bottom:2px; }
.estimator-compact .summary-note { font-size:.72rem; }
.estimator-compact .estimate-help { padding:9px 12px; margin-bottom:12px; border:0; background:transparent; }
.estimator-compact .estimate-help p { font-size:.76rem; }
.estimator-compact .section-heading { margin:16px 0 10px; }
.estimator-compact .section-heading h2 { font-size:1.05rem; }
.estimator-compact .section-heading p { font-size:.78rem; }
.estimator-compact .category-list { gap:12px; }
.estimator-compact .panel { border-radius:10px; box-shadow:none; }
.estimator-compact .panel-header { min-height:52px; padding:7px 10px; gap:10px; }
.estimator-compact .panel-number { width:24px; height:24px; border-radius:6px; font-size:.7rem; }
.estimator-compact .title-input { font-size:.88rem; min-height:34px; padding:5px 8px; }
.estimator-compact .panel-summary { min-width:110px; margin-right:0; }
.estimator-compact .panel-summary strong { font-size:.9rem; }
.estimator-compact .panel-summary span { font-size:.65rem; }
.estimator-compact .panel-header .icon-button { width:30px; min-height:32px; padding:5px; }
.estimator-compact .panel-footer { padding:6px 12px; }
.estimator-compact .panel-footer .button { min-height:30px; padding:3px 8px; border-color:transparent; background:transparent; color:var(--primary-hover); font-size:.76rem; }
.estimator-compact .empty-state { padding:16px; font-size:.8rem; }
.estimator-compact .empty-state p { margin:0; }
.estimator-compact .estimator-table-scroll { overflow-x:auto; scrollbar-gutter:auto; }
.estimator-compact .estimator-grid { display:table; width:var(--estimate-width,1259px) !important; min-width:100%; table-layout:fixed; }
.estimator-compact .estimator-grid colgroup { display:table-column-group; }
.estimator-compact .estimator-grid thead { display:table-header-group; }
.estimator-compact .estimator-grid tbody { display:table-row-group; }
.estimator-compact .estimator-grid tr { display:table-row; padding:0; }
.estimator-compact .estimator-grid th { padding:7px 8px; font-size:.65rem; letter-spacing:.04em; background:var(--panel-footer-bg); }
.estimator-compact .estimator-grid th:last-child .column-resizer { right:0; }
.estimator-compact .estimator-grid td { display:table-cell; width:auto; height:40px; padding:3px 5px; border-bottom:1px solid var(--row-border); vertical-align:middle; }
.estimator-compact .estimator-grid td::before { display:none; }
.estimator-compact .estimator-grid tr:last-child td { border-bottom:0; }
.estimator-compact .estimator-grid td:not(:last-child) { border-right:1px solid color-mix(in srgb,var(--border) 35%,transparent); }
.estimator-compact .estimator-grid input, .estimator-compact .estimator-grid select { min-height:30px; padding:4px 6px; font-size:.8rem; }
.estimator-compact .estimator-grid input[type="number"] { appearance:textfield; text-align:right; font-variant-numeric:tabular-nums; }
.estimator-compact .estimator-grid input::-webkit-inner-spin-button { appearance:none; }
.estimator-compact .estimator-grid .description input { font-weight:550; }
.estimator-compact .estimator-grid .tags input { font-size:.73rem; color:var(--muted); }
.estimator-compact .estimator-grid .enabled-col { text-align:center; }
.estimator-compact .estimator-grid .research-mark-col { text-align:center; }
.estimator-compact .research-cell { display:flex; align-items:center; justify-content:center; gap:2px; }
.estimator-compact .research-mark { position:relative; display:inline-grid; width:27px; min-height:28px; place-items:center; border-radius:7px; cursor:pointer; color:var(--subtle); }
.estimator-compact .research-mark:hover { background:var(--primary-soft); color:var(--primary-hover); }
.estimator-compact .research-mark.is-marked { color:var(--primary); }
.estimator-compact .research-mark svg { width:17px; height:17px; }
.estimator-compact .research-mark input { position:absolute; width:1px; height:1px; opacity:0; pointer-events:none; }
.estimator-compact .research-mark:focus-within { outline:2px solid var(--primary); outline-offset:1px; }
.estimator-compact .item-enabled-toggle { width:30px; min-height:30px; }
.estimator-compact .estimator-grid .item-enabled-toggle input { width:17px; height:17px; min-height:17px; padding:0; }
.estimator-compact .estimator-field { gap:3px; }
.estimator-compact .estimator-field > .field-mode { appearance:none; flex:0 0 30px; width:30px; padding:4px; text-align:center; color:var(--muted); font-size:.75rem; border:1px solid var(--border); background:var(--surface); }
.estimator-compact .estimator-field.formula-mode > .field-mode { color:var(--primary-hover); background-color:var(--primary-soft); }
.estimator-compact .estimator-field.formula-mode .formula-editor { min-width:0; }
.estimator-compact .estimator-field.formula-mode .formula-editor input { min-width:0; width:100%; font-size:.75rem; }
.estimator-compact .estimator-field.formula-mode .insert-variable { min-width:24px; width:24px; padding:0; background-position:center; }
.estimator-compact .research-match-button { width:25px; min-width:25px; height:25px; border-radius:7px; }
.estimator-compact .research-match-button svg { width:15px; height:15px; }
.estimator-compact .estimator-grid .calculated-value { min-height:30px; justify-content:flex-end; padding:3px 5px; font-size:.82rem; }
.estimator-compact .estimator-grid .total { background:var(--primary-soft); }
.estimator-compact .estimator-grid .row-actions { justify-content:flex-end; gap:0; }
.estimator-compact .estimator-grid .row-actions .icon-button { width:28px; min-width:28px; min-height:30px; padding:5px; }
.estimator-compact .estimator-grid .row-actions svg { width:16px; height:16px; }
.estimator-compact .estimator-grid .formula-editor:focus-within { position:relative; z-index:3; min-width:240px; padding:2px; border:1px solid var(--primary); border-radius:6px; background:var(--surface); box-shadow:var(--shadow); }
.estimator-compact .estimator-grid tr.item-disabled > td { opacity:1; background:var(--panel-footer-bg); }
.estimator-compact .estimator-grid tr.item-disabled input:not([type="checkbox"]), .estimator-compact .estimator-grid tr.item-disabled .calculated-value { color:var(--subtle); }
.estimator-compact .estimator-grid tr:focus-within { background:var(--row-hover); }
@media (max-width:640px) {
  .estimator-compact .summary-grid { grid-template-columns:1fr 1fr; }
  .estimator-compact .summary-card.hero { grid-column:1 / -1; border-bottom:1px solid var(--border); }
  .estimator-compact .summary-card { padding:12px; }
  .estimator-compact .summary-card:nth-child(2) { border-left:0; }
  .estimator-compact .panel-header { flex-wrap:wrap; }
  .estimator-compact .panel-title-group { width:100%; }
  .estimator-compact .panel-summary { order:initial; margin-left:8px; text-align:left; }
  .estimator-compact .section-heading { flex-direction:row; align-items:center; }
}

/* Estimate audit */
.audit-toolbar { display:flex; align-items:end; justify-content:space-between; gap:16px; margin-bottom:12px; padding:14px 16px; }
.audit-history { display:grid; min-width:min(520px, 100%); gap:5px; }
.audit-history label, .audit-mode legend { color:var(--muted); font-size:.72rem; font-weight:750; }
.audit-history select { width:100%; }
.audit-history-actions, .audit-start-actions { display:flex; flex-wrap:wrap; gap:8px; }
.audit-start { display:grid; grid-template-columns:minmax(280px, 1fr) minmax(360px, 480px); gap:18px 32px; margin-bottom:18px; padding:20px; }
.audit-start h2 { margin:3px 0 5px; }
.audit-start p { max-width:64ch; margin:0; color:var(--muted); }
.audit-mode { display:grid; align-content:start; gap:8px; margin:0; padding:12px; border:1px solid var(--border); border-radius:10px; background:var(--panel-footer-bg); }
.audit-mode legend { padding:0 5px; }
.audit-mode-options { display:grid; gap:7px; }
.audit-mode-option { display:grid; grid-template-columns:18px minmax(0, 1fr); min-height:0; align-items:center; gap:10px; padding:9px 10px; border:1px solid transparent; border-radius:8px; color:var(--text); cursor:pointer; transition:border-color var(--speed), background var(--speed); }
.audit-mode-option:hover { border-color:var(--border-strong); background:var(--surface-raised); }
.audit-mode-option:has(input:checked) { border-color:var(--primary); background:var(--primary-soft); }
.audit-mode-option input { width:18px; height:18px; min-height:18px; margin:0; padding:0; accent-color:var(--primary); cursor:pointer; }
.audit-mode-option span, .audit-mode-option strong, .audit-mode-option small { display:block; }
.audit-mode-option strong { font-size:.8rem; }
.audit-mode-option small { margin-top:2px; color:var(--muted); font-size:.7rem; line-height:1.35; }
.audit-start-actions { grid-column:1 / -1; align-items:center; }
.audit-export-group { display:flex; align-items:stretch; gap:6px; }
.audit-prompt-option { display:flex; width:auto; min-height:44px; align-items:center; gap:7px; padding:0 10px; border:1px solid var(--border); border-radius:9px; background:var(--input-bg); color:var(--muted); font-size:.72rem; cursor:pointer; }
.audit-prompt-option:hover { border-color:var(--border-strong); }
.audit-prompt-option input { width:17px; height:17px; min-height:17px; margin:0; padding:0; accent-color:var(--primary); cursor:pointer; }
.audit-progress { display:none; grid-column:1 / -1; padding-top:13px; border-top:1px solid var(--border); }
.audit-progress.visible { display:block; }
.audit-progress > div:first-child { display:flex; justify-content:space-between; margin-bottom:7px; font-size:.76rem; text-transform:capitalize; }
.audit-progress > div:first-child span, .audit-progress p { color:var(--muted); }
.audit-progress p { margin:7px 0 0; font-size:.74rem; }
.audit-progress-track { height:8px; overflow:hidden; border-radius:999px; background:var(--border); }
.audit-progress-track i { display:block; height:100%; border-radius:inherit; background:var(--primary); transition:width .3s ease; }
.audit-loading, .audit-awaiting { margin-top:18px; padding:24px; }
.audit-awaiting h2 { margin:5px 0; }
.audit-awaiting p { margin:0; color:var(--muted); }
.audit-summary { display:grid; grid-template-columns:170px minmax(280px, 1fr) minmax(250px, .8fr); gap:0; margin:18px 0; overflow:hidden; border:1px solid var(--border); border-radius:14px; background:var(--surface); }
.audit-summary.confidence-low { border-color:color-mix(in srgb, var(--negative) 48%, var(--border)); }
.audit-summary.confidence-medium { border-color:color-mix(in srgb, var(--warning) 48%, var(--border)); }
.audit-summary.confidence-high { border-color:color-mix(in srgb, var(--positive) 48%, var(--border)); }
.audit-score { display:grid; align-content:center; justify-items:center; padding:24px 18px; border-right:1px solid var(--border); background:var(--surface-raised); text-align:center; }
.audit-score > span { color:var(--muted); font-size:.72rem; font-weight:750; text-transform:uppercase; letter-spacing:.05em; }
.audit-score strong { margin:2px 0; font-size:3.2rem; line-height:1; font-variant-numeric:tabular-nums; }
.audit-score small { font-size:.85rem; color:var(--muted); }
.audit-score em { font-style:normal; font-size:.76rem; font-weight:800; text-transform:uppercase; }
.confidence-low .audit-score em { color:var(--negative); }
.confidence-medium .audit-score em { color:var(--warning); }
.confidence-high .audit-score em { color:var(--positive); }
.audit-summary-copy { padding:20px 22px; }
.audit-summary-copy h2 { margin:7px 0; }
.audit-summary-copy > p { margin:0; color:var(--muted); line-height:1.55; }
.audit-report-meta { display:flex; flex-wrap:wrap; gap:7px 12px; color:var(--subtle); font-size:.69rem; }
.audit-source { display:inline-flex; width:max-content; padding:3px 7px; border-radius:999px; background:var(--primary-soft); color:var(--primary-hover); font-size:.68rem; font-weight:800; text-transform:uppercase; }
.audit-change-warning { margin-top:12px; padding:9px 10px; border-left:3px solid var(--warning); background:var(--warning-soft); color:var(--warning); font-size:.74rem; }
.audit-metrics { display:grid; grid-template-columns:1fr 1fr; margin:0; border-left:1px solid var(--border); }
.audit-metrics div { padding:15px; border-right:1px solid var(--row-border); border-bottom:1px solid var(--row-border); }
.audit-metrics dt { color:var(--muted); font-size:.68rem; }
.audit-metrics dd { margin:3px 0 0; font-size:.88rem; font-weight:800; }
.audit-concerns { display:flex; grid-column:1 / -1; flex-wrap:wrap; align-items:center; gap:8px; padding:11px 16px; border-top:1px solid var(--border); background:var(--panel-footer-bg); font-size:.76rem; }
.audit-concerns button { padding:4px 7px; border:0; border-radius:6px; background:var(--negative-soft); color:var(--negative); font-size:inherit; font-weight:700; }
.audit-details { display:grid; gap:14px; }
.audit-category { overflow:hidden; }
.audit-category > header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:13px 16px; border-bottom:1px solid var(--border); background:var(--panel-header-bg); }
.audit-category > header h2 { margin:0; font-size:.95rem; }
.audit-category > header span { color:var(--muted); font-size:.72rem; }
.audit-item-list { display:grid; }
.audit-item { padding:17px; border-bottom:1px solid var(--row-border); scroll-margin-top:100px; }
.audit-item:last-child { border-bottom:0; }
.audit-item-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:18px; }
.audit-item-heading h3 { margin:3px 0 1px; font-size:.92rem; }
.audit-item-heading p { margin:0; color:var(--muted); font-size:.7rem; }
.audit-item-status { color:var(--muted); font-size:.68rem; font-weight:800; text-transform:uppercase; letter-spacing:.04em; }
.status-underestimated .audit-item-status, .status-unable_to_assess .audit-item-status { color:var(--negative); }
.status-overestimated .audit-item-status, .status-insufficient_research .audit-item-status { color:var(--warning); }
.status-within_range .audit-item-status { color:var(--positive); }
.audit-item-confidence { display:grid; min-width:84px; justify-items:end; }
.audit-item-confidence strong { font-size:1.45rem; line-height:1; font-variant-numeric:tabular-nums; }
.audit-item-confidence span { margin-top:3px; color:var(--muted); font-size:.65rem; text-transform:capitalize; }
.audit-range { margin:16px 0 12px; }
.audit-range-track { position:relative; display:flex; height:14px; margin:0 7px; overflow:visible; border:1px solid var(--border); border-radius:999px; background:var(--surface-raised); }
.audit-range-track .range-segment { position:absolute; top:1px; bottom:1px; min-width:1px; }
.audit-range-track .range-zero-low { left:0; width:var(--range-low); border-radius:999px 0 0 999px; background:var(--negative-soft); }
.audit-range-track .range-low-typical { left:var(--range-low); width:calc(var(--range-typical) - var(--range-low)); background:color-mix(in srgb, var(--positive-soft) 64%, var(--surface-raised)); }
.audit-range-track .range-typical-high { left:var(--range-typical); width:calc(var(--range-high) - var(--range-typical)); background:var(--positive-soft); }
.audit-range-track .range-high-plus { left:var(--range-high); right:0; border-radius:0 999px 999px 0; background:var(--warning-soft); }
.audit-range-track i { position:absolute; top:-3px; z-index:2; width:2px; height:18px; translate:-1px 0; background:var(--muted); }
.audit-range-track .range-typical { width:3px; background:var(--text); }
.audit-range-track b { position:absolute; top:-6px; z-index:3; width:12px; height:24px; translate:-6px 0; border:3px solid var(--primary); border-radius:5px; background:var(--surface); box-shadow:0 0 0 2px var(--surface); }
.audit-range-labels { position:relative; height:39px; margin:7px 7px 0; color:var(--muted); font-size:.68rem; line-height:1.2; }
.audit-range-labels .range-label { position:absolute; left:var(--label-position); top:0; width:max-content; max-width:25%; translate:-50% 0; white-space:nowrap; }
.audit-range-labels .range-label-estimate { top:20px; color:var(--primary-hover); }
.audit-range-labels .label-at-start { translate:0 0; }
.audit-range-labels .label-at-end { translate:-100% 0; }
.audit-no-range { margin:13px 0; padding:10px 12px; border:1px dashed var(--border); border-radius:8px; color:var(--muted); font-size:.76rem; }
.audit-comment { margin:10px 0; color:var(--text); font-size:.8rem; line-height:1.5; }
.audit-item footer { display:flex; align-items:center; justify-content:space-between; gap:14px; }
.audit-sources { display:flex; min-width:0; flex-wrap:wrap; gap:5px 10px; color:var(--subtle); font-size:.68rem; }
.audit-sources a { color:var(--primary-hover); overflow-wrap:anywhere; }
@media (max-width:1050px) {
  .audit-start { grid-template-columns:1fr; }
  .audit-start-actions, .audit-progress { grid-column:1; }
  .audit-summary { grid-template-columns:150px 1fr; }
  .audit-metrics { grid-column:1 / -1; grid-template-columns:repeat(4, 1fr); border-left:0; border-top:1px solid var(--border); }
}
@media (max-width:720px) {
  .audit-toolbar, .audit-start, .audit-item footer { align-items:stretch; flex-direction:column; }
  .audit-toolbar { display:flex; }
  .audit-history { min-width:0; }
  .audit-start { grid-template-columns:1fr; }
  .audit-start-actions, .audit-progress { grid-column:1; }
  .audit-export-group { flex-wrap:wrap; }
  .audit-summary { grid-template-columns:1fr; }
  .audit-score { border-right:0; border-bottom:1px solid var(--border); }
  .audit-metrics { grid-template-columns:1fr 1fr; }
  .audit-item-heading { gap:10px; }
}

/* Sale plan compact layout mirrors the estimator without changing plan behavior. */
.planner-compact.page { max-width:1800px; padding-top:22px; }
.planner-compact .context-bar { margin-bottom:18px; gap:14px; }
.planner-compact .context-bar h1 { font-size:1.7rem; }
.planner-compact .page-intro { font-size:.85rem; }
.planner-compact .summary-grid { display:grid; grid-template-columns:2fr 1fr 1fr; gap:0; border:1px solid var(--border); border-radius:10px; background:var(--surface); margin-bottom:12px; overflow:hidden; }
.planner-compact .summary-card { min-height:0; padding:14px 20px; background:transparent; border:0; border-radius:0; box-shadow:none; }
.planner-compact .summary-card + .summary-card { border-left:1px solid var(--border); }
.planner-compact .summary-card.hero { grid-column:auto; }
.planner-compact .summary-card::after { display:none; }
.planner-compact .summary-label { margin-bottom:4px; font-size:.75rem; }
.planner-compact .summary-value { font-size:1.7rem; margin-bottom:2px; }
.planner-compact .summary-note { font-size:.72rem; }
.planner-compact .section-heading { margin:16px 0 10px; }
.planner-compact .section-heading h2 { font-size:1.05rem; }
.planner-compact .section-heading p { font-size:.78rem; }
.planner-compact .stage-list { gap:12px; }
.planner-compact .stage-list > .panel { border-radius:10px; box-shadow:none; }
.planner-compact .panel-header { min-height:52px; padding:7px 10px; gap:10px; }
.planner-compact .panel-number { width:24px; height:24px; border-radius:6px; font-size:.7rem; }
.planner-compact .title-input { font-size:.88rem; min-height:34px; padding:5px 8px; }
.planner-compact .panel-summary { min-width:110px; margin-right:0; }
.planner-compact .panel-summary strong { font-size:.9rem; }
.planner-compact .panel-summary span { font-size:.65rem; }
.planner-compact .panel-header .icon-button { width:30px; min-height:32px; padding:5px; }
.planner-compact .plan-grid { display:table; width:100%; table-layout:fixed; }
.planner-compact .plan-grid col.plan-col-enabled { width:44px; }
.planner-compact .plan-grid col.plan-col-name { width:27%; }
.planner-compact .plan-grid col.plan-col-direction { width:115px; }
.planner-compact .plan-grid col.plan-col-calculation { width:31%; }
.planner-compact .plan-grid col.plan-col-amount { width:130px; }
.planner-compact .plan-grid col.plan-col-actions { width:150px; }
.planner-compact .plan-grid th { padding:7px 8px; font-size:.65rem; letter-spacing:.04em; background:var(--panel-footer-bg); }
.planner-compact .plan-grid td { height:40px; padding:3px 5px; vertical-align:middle; }
.planner-compact .plan-grid td::before { display:none; }
.planner-compact .plan-grid td:not(:last-child) { border-right:1px solid color-mix(in srgb,var(--border) 35%,transparent); }
.planner-compact .plan-grid input, .planner-compact .plan-grid select { min-height:30px; padding:4px 6px; font-size:.8rem; }
.planner-compact .plan-calculation-cell { display:flex; min-width:0; align-items:center; gap:5px; }
.planner-compact .plan-calculation-cell .calculation-select { appearance:none; flex:0 0 32px; width:32px; margin:0; padding:4px; text-align:center; background-image:none; cursor:pointer; }
.planner-compact .plan-mode-label { color:var(--subtle); font-size:.76rem; }
.planner-compact .plan-calculation-cell .formula-editor { grid-template-columns:minmax(0,1fr) auto; min-width:0; flex:1; gap:4px; }
.planner-compact .plan-calculation-cell .formula-editor input { min-width:0; }
.planner-compact .plan-calculation-cell .source-select { flex:1 1 120px; min-width:0; margin:0; }
.planner-compact .plan-calculation-cell .percent-wrap { flex:0 0 88px; }
.planner-compact .money-wrap::before, .planner-compact .percent-wrap::after { content:none; }
.planner-compact .affix-field { display:grid; width:100%; min-width:0; min-height:30px; align-items:center; overflow:hidden; border:1px solid var(--border); border-radius:9px; background:var(--surface); }
.planner-compact .money-wrap.affix-field { grid-template-columns:auto minmax(0,1fr); }
.planner-compact .percent-wrap.affix-field { grid-template-columns:minmax(0,1fr) auto; }
.planner-compact .affix-field .input-affix { display:grid; align-self:stretch; place-items:center; min-width:28px; padding:0 7px; color:var(--subtle); background:var(--panel-footer-bg); font-size:.75rem; line-height:1; }
.planner-compact .affix-field .input-affix-prefix { border-right:1px solid var(--border); }
.planner-compact .affix-field .input-affix-suffix { border-left:1px solid var(--border); }
.planner-compact .affix-field input { width:100%; min-width:0; min-height:28px; padding:4px 6px; border:0; border-radius:0; background:transparent; box-shadow:none; }
.planner-compact .affix-field:focus-within { border-color:var(--primary); box-shadow:0 0 0 2px var(--primary-soft); }
.planner-compact .affix-field input:focus { box-shadow:none; }
.planner-compact .affix-field .field-error { grid-column:1 / -1; }
.planner-compact .plan-grid .field-error:empty { display:none; }
.planner-compact .plan-grid .enabled-col { text-align:center; }
.planner-compact .item-enabled-toggle { width:30px; min-height:30px; }
.planner-compact .plan-grid .item-enabled-toggle input { width:17px; height:17px; min-height:17px; padding:0; }
.planner-compact .plan-grid .name-col input { font-weight:550; }
.planner-compact .plan-grid th.actions-col { text-align:center; }
.planner-compact .plan-grid td.amount-col { text-align:right; background:var(--primary-soft); }
.planner-compact .plan-grid .amount-col input { width:100%; }
.planner-compact .plan-grid .type-col select { width:100%; }
.planner-compact .plan-grid .row-actions { justify-content:flex-end; gap:0; }
.planner-compact .plan-grid .row-actions .icon-button { width:28px; min-width:28px; min-height:30px; padding:5px; }
.planner-compact .plan-grid .row-actions svg { width:16px; height:16px; }
.planner-compact .panel-footer { padding:6px 12px; }
.planner-compact .panel-footer .button { min-height:30px; padding:3px 8px; border-color:transparent; background:transparent; color:var(--primary-hover); font-size:.76rem; }
.planner-compact .running-balance { font-size:.76rem; }
.planner-compact .running-balance strong { font-size:.86rem; }

@media (max-width:900px) {
  .planner-compact .plan-grid { display:block; width:100%; table-layout:auto; }
  .planner-compact .plan-grid colgroup { display:none; }
  .planner-compact .plan-grid thead { display:none; }
  .planner-compact .plan-grid tbody { display:grid; }
  .planner-compact .plan-grid tr { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); padding:10px; border-bottom:1px solid var(--border); }
  .planner-compact .plan-grid tr:last-child { border-bottom:0; }
  .planner-compact .plan-grid td, .planner-compact .plan-grid .enabled-col, .planner-compact .plan-grid .name-col, .planner-compact .plan-grid .amount-col, .planner-compact .plan-grid .type-col, .planner-compact .plan-grid .actions-col { width:auto; padding:7px; border:0; text-align:left; }
  .planner-compact .plan-grid td::before { display:block; margin-bottom:4px; color:var(--subtle); content:attr(data-label); font-size:.66rem; font-weight:800; letter-spacing:.06em; text-transform:uppercase; }
  .planner-compact .plan-grid .name-col, .planner-compact .plan-grid .actions-col { grid-column:1 / -1; }
  .planner-compact .plan-calculation-cell { align-items:stretch; flex-direction:column; gap:5px; }
  .planner-compact .plan-calculation-cell .calculation-select, .planner-compact .plan-calculation-cell .source-select, .planner-compact .plan-calculation-cell .percent-wrap { width:100%; flex-basis:auto; }
  .planner-compact .plan-calculation-cell .formula-editor { width:100%; }
}

@media (max-width:640px) {
  .planner-compact .summary-grid { grid-template-columns:1fr 1fr; }
  .planner-compact .summary-card.hero { grid-column:1 / -1; border-bottom:1px solid var(--border); }
  .planner-compact .summary-card { padding:12px; }
  .planner-compact .summary-card:nth-child(2) { border-left:0; }
  .planner-compact .panel-header { flex-wrap:wrap; }
  .planner-compact .panel-title-group { width:100%; }
  .planner-compact .panel-summary { order:initial; margin-left:8px; text-align:left; }
  .planner-compact .section-heading { flex-direction:row; align-items:center; }
}

/* Research hub */
.research-hub-toolbar { display:flex; align-items:center; justify-content:space-between; gap:20px; margin:4px 0 16px; padding:16px 18px; }
.research-hub-heading { min-width:0; }
.research-hub-heading h2 { margin:3px 0 2px; font-size:1.08rem; }
.research-hub-heading p { margin:0; color:var(--muted); font-size:.78rem; }
.research-hub-toolbar .toolbar-actions, .research-hub-actions { display:flex; flex-wrap:wrap; gap:8px; }
.research-hub-actions { flex:0 0 auto; }
.research-hub-count { color:var(--muted); font-size:.82rem; }
.research-hub-grid { display:grid; grid-template-columns:minmax(0,1.18fr) minmax(360px,.82fr); gap:16px; align-items:start; }
.research-queue, .research-brief { min-width:0; }
.research-queue-list { display:grid; gap:9px; }
.research-queue { display:grid; gap:10px; }
.research-queue-item { padding:14px 16px; border-radius:10px; background:var(--surface); }
.research-queue-item header { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.research-queue-item h3 { margin:0; font-size:.92rem; line-height:1.25; }
.research-queue-item .item-category { margin:3px 0 0; color:var(--muted); font-size:.72rem; }
.research-item-context { display:flex; flex-wrap:wrap; gap:6px 12px; margin:9px 0; color:var(--muted); font-size:.74rem; }
.research-queue-item > label, .research-field > label, .research-preview-label label { display:block; margin-bottom:5px; color:var(--muted); font-size:.72rem; font-weight:700; }
.research-queue-item textarea { width:100%; min-height:48px; resize:vertical; padding:7px 8px; font-size:.78rem; }
.research-item-actions { display:flex; align-items:center; flex-wrap:wrap; gap:6px; margin-top:10px; padding-top:10px; border-top:1px solid var(--border); }
.research-item-actions .button { min-height:30px; padding:4px 9px; font-size:.73rem; }
.research-brief { position:sticky; top:14px; padding:0; overflow:hidden; }
.research-brief-header { padding:16px 18px 13px; border-bottom:1px solid var(--border); background:var(--panel-header-bg); }
.research-brief-header h2 { margin:3px 0 3px; font-size:1.08rem; }
.research-brief-header p { margin:0; color:var(--muted); font-size:.78rem; line-height:1.45; }
.research-field, .research-preview-field { padding-inline:18px; }
.research-field { margin-top:13px; }
.research-field input, .research-field select { width:100%; min-height:34px; padding:6px 8px; font-size:.8rem; }
.research-preview-field { margin-top:13px; }
.research-preview-label { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.research-preview-label span { color:var(--subtle); font-size:.7rem; }
.research-brief textarea { width:100%; min-height:410px; resize:vertical; padding:10px; font: .76rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.research-brief-footer { display:flex; align-items:center; gap:10px; margin:13px 18px 0; padding-top:13px; border-top:1px solid var(--border); }
.research-brief-footer .button { flex:0 0 auto; }
.research-brief-help { margin:0; color:var(--muted); font-size:.72rem; line-height:1.4; }
#research-copy-status { min-height:18px; margin:7px 18px 12px; color:var(--success, var(--primary-hover)); font-size:.75rem; }
.connection-badge { padding:3px 7px; border:1px solid var(--border); border-radius:999px; color:var(--muted); font-size:.67rem; font-weight:800; letter-spacing:.02em; }
.connection-badge.connected { border-color:color-mix(in srgb, var(--success, var(--primary)) 45%, var(--border)); color:var(--success, var(--primary-hover)); background:color-mix(in srgb, var(--success, var(--primary)) 10%, transparent); }
.research-run-box > p { margin:6px 0 0; color:var(--muted); font-size:.69rem; line-height:1.45; }
.research-run-box { margin:13px 18px 0; }
.research-service-status { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:9px; color:var(--subtle); font-size:.68rem; overflow-wrap:anywhere; }
.research-run-button { width:100%; min-height:44px; }
.research-progress { display:none; margin-top:11px; padding:11px; border:1px solid var(--border); border-radius:9px; background:var(--surface-soft); }
.research-progress.visible { display:block; }
.research-progress-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:7px; font-size:.72rem; }
.research-progress-heading strong { text-transform:capitalize; }
.research-progress-heading span { color:var(--muted); font-variant-numeric:tabular-nums; }
.research-progress-track { height:7px; overflow:hidden; border-radius:999px; background:var(--border); }
.research-progress-track i { display:block; height:100%; border-radius:inherit; background:var(--primary); transition:width .3s ease; }
#research-run-status { min-height:18px; margin:8px 0 0; color:var(--muted); font-size:.72rem; line-height:1.4; }
.research-failures { margin-top:9px; padding-top:9px; border-top:1px solid var(--border); }
.research-failures summary { cursor:pointer; color:var(--warning); font-size:.72rem; font-weight:750; }
.research-failures ul { display:grid; gap:7px; margin:8px 0 0; padding:0; list-style:none; }
.research-failures li { display:grid; gap:2px; min-width:0; }
.research-failures li strong { font-size:.72rem; }
.research-failures li span { color:var(--muted); font-size:.68rem; line-height:1.4; overflow-wrap:anywhere; }
.research-manual-divider { display:flex; align-items:center; gap:9px; margin:13px 18px 0; color:var(--subtle); font-size:.67rem; text-transform:uppercase; letter-spacing:.06em; }
.research-manual-divider::before, .research-manual-divider::after { content:''; height:1px; flex:1; background:var(--border); }
.research-count { display:inline-flex; min-width:18px; height:18px; align-items:center; justify-content:center; margin-left:3px; padding:0 5px; border-radius:9px; background:var(--primary-soft); color:var(--primary-hover); font-size:.68rem; font-variant-numeric:tabular-nums; }
@media (max-width:900px) {
  .research-hub-grid { grid-template-columns:1fr; }
  .research-brief { position:static; }
}

.ai-settings-dialog { width:min(540px, calc(100% - 32px)); }
.ai-settings-dialog > form > p { color:var(--muted); line-height:1.5; }
.ai-settings-state { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:18px; padding:11px 12px; border:1px solid var(--border); border-radius:9px; background:var(--surface-soft); font-size:.8rem; }
.ai-settings-state span { color:var(--muted); }
.ai-settings-dialog .field-hint { color:var(--subtle); font-size:.72rem; line-height:1.4; }
.ai-settings-test-result { min-height:20px; margin-top:12px; font-size:.78rem; line-height:1.45; }
.ai-settings-test-result.testing { color:var(--muted); }
.ai-settings-test-result.success { color:var(--success, var(--primary-hover)); }
.ai-settings-test-result.error { color:var(--danger); }
.ai-prompt-test { margin-top:14px; padding:12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); }
.ai-prompt-test summary { cursor:pointer; font-size:.82rem; font-weight:750; }
.ai-prompt-test .dialog-field { margin-top:12px; }
.ai-prompt-test textarea { width:100%; resize:vertical; }
.ai-prompt-test > .button { margin-top:10px; }
.ai-test-prompt-result { min-height:20px; margin-top:10px; font-size:.78rem; line-height:1.45; }
.ai-test-prompt-result.testing { color:var(--muted); }
.ai-test-prompt-result.error { color:var(--danger); }
.ai-test-prompt-result.success { color:var(--text); }
.ai-test-response-meta { margin-bottom:6px; color:var(--muted); font-size:.69rem; overflow-wrap:anywhere; }
.ai-test-prompt-result pre { max-height:180px; margin:0; padding:10px; overflow:auto; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:var(--text); font:.75rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space:pre-wrap; overflow-wrap:anywhere; }
@media (max-width:640px) {
  .research-hub-toolbar { align-items:flex-start; flex-direction:column; }
  .research-hub-actions { width:100%; }
  .research-hub-actions .button { flex:1 1 180px; }
  .research-brief-footer { align-items:stretch; flex-direction:column; }
  .research-brief-footer .button { width:100%; }
}
