.fact-period { display:flex; align-items:end; gap:16px; flex-wrap:wrap; }
.fact-period .field { margin:0; min-width:160px; }
.fact-period .field-hint { align-self:center; }
.fact-table { border-collapse:separate; border-spacing:0; table-layout:fixed; width:max-content; min-width:0; font-size:13px; font-variant-numeric:tabular-nums; }
.fact-table th { background:#312339; padding:18px 12px; text-align:center; vertical-align:middle; border-bottom:1px solid var(--line); color:var(--soft); font-size:11px; font-weight:600; white-space:normal; overflow-wrap:anywhere; }
.fact-table td { padding:16px 12px; border-bottom:1px solid var(--line); vertical-align:middle; text-align:center; white-space:normal; }
.fact-table .fact-day { position:sticky; left:0; background:var(--panel); z-index:1; min-width:135px; box-shadow:1px 0 var(--line); }
.fact-table .fact-detail { background:#342938; }
.fact-table .cell-sub { margin-top:6px; display:block; line-height:1.35; font-size:11px; font-weight:400; color:var(--muted); }
.fact-table td.fact-empty { padding:50px; text-align:left; color:var(--muted); }
.fact-table .expense-group-toggle { flex-direction:column; gap:6px; white-space:normal; justify-content:center; text-align:center; line-height:1.6; font:inherit; }
.fact-table .expense-group-toggle > span { position:static; flex-shrink:0; }
.fact-notices { padding:16px 20px; margin:16px 0; background:#3a2e2e; border:1px solid #635044; border-radius:12px; font-size:12px; line-height:1.6; color:#e3cdb6; }
.fact-notices p { margin:4px 0; }
.fact-notices summary { cursor:pointer; font-weight:600; }
.fact-panel .table-scroll { max-height:65vh; }
.fact-table thead th { position:sticky; top:0; z-index:1; }
.fact-table thead th.fact-day { z-index:3; background:#312339; }
.fact-table tbody tr:hover td { background:#362b40; }
.fact-table td.red { color:var(--red); }
.fact-table-actions,.fact-history-controls { display:flex;gap:16px;align-items:center;flex-wrap:wrap; }
.fact-history-controls { margin-top:20px;padding-top:16px;border-top:1px solid var(--line);font-size:12px;color:var(--muted); }
.fact-table-layout { display:flex;align-items:stretch;position:relative; }
.fact-table-layout > .table-scroll { flex:1;min-width:0; }
.fact-columns { width:340px;flex:0 0 340px;border-left:1px solid var(--line);background:var(--panel);padding:16px;max-height:65vh;display:flex;flex-direction:column;gap:12px; }
.fact-columns-head { display:flex;align-items:center;justify-content:space-between; }
.fact-column-options { overflow:auto;flex:1; }
.fact-column-options label { display:flex;gap:8px;align-items:center;padding:8px 0;font-size:12px;cursor:pointer;flex:1;min-width:0; }
.fact-column-options label[hidden] { display:none; }
.fact-column-options input { width:16px;height:16px;flex:0 0 16px;accent-color:var(--coral); }
.fact-column-options small { color:var(--muted);margin-left:auto; }
.fact-metric { display:flex;align-items:baseline;justify-content:center;gap:6px;min-width:0; }
.fact-number { color:var(--text);font-size:14px;font-weight:500;white-space:nowrap;flex:0 0 auto; }
.fact-change { display:inline;font-size:10px;font-weight:300;line-height:1.45;margin:0;min-width:0;overflow-wrap:anywhere; }
.fact-table .cell-sub .fact-number { font-size:13px; }
.fact-table .fact-up { color:#6cdeb0; }
.fact-table .fact-down { color:#ff888f; }
.fact-header { display:flex;align-items:center;justify-content:center;gap:8px;min-width:0;padding-right:4px; }
.fact-header > span { min-width:0; }
.fact-header .expense-group-toggle { min-width:0; }
.fact-comparison-label { display:flex;align-items:center;justify-content:center;flex:0 0 28px;width:28px;height:28px;cursor:pointer; }
.fact-comparison-label input { appearance:none;-webkit-appearance:none;box-sizing:border-box;width:14px;height:14px;min-width:14px;min-height:14px;margin:0;padding:0;border:1px solid #9a8ba6;border-radius:3px;background:transparent;cursor:pointer;display:grid;place-content:center; }
.fact-comparison-label input:checked { background:#b8a4e8;border-color:#b8a4e8; }
.fact-comparison-label input:checked::after { content:'';width:7px;height:4px;border-left:2px solid #241d30;border-bottom:2px solid #241d30;transform:translateY(-1px) rotate(-45deg); }
.fact-comparison-label input:focus-visible { outline:2px solid #e8e1ee;outline-offset:3px; }
.fact-comparison-label:hover input { border-color:#e8e1ee; }
.fact-no-comparison .fact-change { display:none; }
.fact-reasons { margin-top:8px;font-size:11px;line-height:1.5;text-align:left;white-space:normal; }
.fact-reasons summary { color:#e3cdb6;cursor:pointer; }
.fact-reasons p { margin:7px 0;color:var(--muted); }
.fact-reasons .fact-missing-ids { color:var(--text);overflow-wrap:anywhere; }
.fact-reasons .text-link { font-size:11px;white-space:normal;text-align:left;margin:4px 0; }
.fact-table .cell-sub.fact-missing-cost { color:#e3cdb6; }
@media(forced-colors:active){.fact-comparison-label input{appearance:auto}.fact-comparison-label input::after{display:none}}
.fact-row-toggle { border:1px solid var(--line);border-radius:5px;background:none;color:var(--coral);width:24px;height:24px;cursor:pointer;margin-right:6px; }
.fact-table .fact-day { min-width:0;max-width:none;white-space:normal; }
.fact-child td { background:#292132;font-size:12px; }
.fact-child .fact-day { padding-left:28px;text-align:left; }
.fact-child .fact-number { font-weight:400; }
.fact-article { display:flex;align-items:center;gap:10px;text-align:left; }
.fact-article-photo { position:relative;display:flex;align-items:center;justify-content:center;flex:0 0 36px;width:36px;height:48px;border-radius:5px;overflow:hidden;background:#413249;color:var(--muted); }
.fact-article-photo img { position:absolute;inset:0;width:36px;height:48px;object-fit:cover; }
.fact-article-text { min-width:0;overflow-wrap:anywhere; }
.fact-progress { margin:18px 0 24px;padding:20px 24px;border:1px solid var(--line);background:var(--panel);border-radius:16px; }
.fact-progress.is-active { border-color:var(--coral);box-shadow:0 0 0 1px #ff917522; }
.fact-progress.has-error { border-color:#b25e65; }
.fact-progress-title { display:flex;gap:10px;align-items:center; }
.fact-progress p { margin:10px 0 0;font-size:12px;color:var(--muted);line-height:1.6; }
.fact-progress progress { display:block;width:100%;height:7px;margin-top:14px;accent-color:var(--coral); }
.fact-live { margin-left:auto;color:var(--coral);font-size:11px; }
.fact-period select { min-height:44px; }
@media(max-width:850px){.fact-columns{position:absolute;right:0;top:0;z-index:5;box-shadow:-12px 0 30px #0005;max-width:85vw}.fact-progress{padding:16px}.fact-period .field{min-width:140px;flex:1}}
.fact-column-row { display:flex;align-items:center;gap:5px;border-bottom:1px solid var(--line); }
.fact-column-row label > span { min-width:0;overflow-wrap:anywhere; }
.fact-column-row small { display:block;font-size:10px; }
.fact-drag { flex:0 0 22px;min-height:32px;padding:2px;color:var(--muted);cursor:grab;font-size:15px;touch-action:none; }
.fact-drag:active { cursor:grabbing; }
.fact-col-buttons { display:flex;flex:0 0 auto; }
.fact-col-buttons button { width:24px;min-height:30px;padding:2px;color:var(--soft); }
.fact-column-hint,.fact-column-notice { font-size:11px;line-height:1.5;color:var(--muted);margin:0; }
.fact-column-notice:empty { display:none; }
.fact-drop-before { box-shadow:inset 0 2px var(--coral); }
.fact-drop-after { box-shadow:inset 0 -2px var(--coral); }
.fact-resizer { position:absolute;top:0;right:-4px;bottom:0;width:10px;padding:0;z-index:4;cursor:col-resize;touch-action:none;background:transparent; }
.fact-resizer::after { content:'';position:absolute;top:22%;bottom:22%;left:4px;width:1px;background:var(--line); }
.fact-resizer:hover::after,.fact-resizer:focus-visible::after { background:var(--coral); }
.fact-resizing,.fact-resizing * { cursor:col-resize !important;user-select:none !important; }
.fact-dragging,.fact-dragging * { cursor:grabbing !important;user-select:none !important; }
@media(pointer:coarse){.fact-resizer{width:20px;right:-8px}.fact-resizer::after{left:9px}.fact-col-buttons button{width:32px;min-height:44px}.fact-drag{min-height:44px}}

.fact-controls{position:relative;border-bottom:1px solid var(--line);padding:4px 0 30px;margin-bottom:16px}
.fact-control-row{display:flex;align-items:flex-end;gap:12px;flex-wrap:wrap}
.fact-control-row h1{font-size:20px;font-weight:550;letter-spacing:-.5px;margin:0 4px 7px 0;white-space:nowrap}
.fact-account{align-self:flex-end;margin-bottom:3px}
.fact-account .account-bar{border:0;margin:0;padding:0;display:block}
.fact-account .account-choice{gap:6px;flex-wrap:nowrap}
.fact-account .account-choice select{max-width:110px;padding:6px 20px 6px 1px;font-size:12px}
.fact-account .wb-logo{width:26px;height:26px;font-size:10px}
.fact-account .tag{font-size:9px;padding:4px 6px}
.fact-account .status-line{position:absolute;bottom:5px;left:0;font-size:10px;max-width:none}
.fact-controls .fact-period{display:grid;grid-template-columns:minmax(210px,1.1fr) minmax(100px,.65fr) minmax(120px,.75fr) minmax(130px,.85fr) minmax(150px,1fr) minmax(210px,1.5fr);gap:12px;align-items:end;min-width:0;width:100%;margin-top:14px}
.fact-controls .fact-period .field{min-width:0;max-width:none;font-size:11px;gap:4px}
.fact-controls .fact-period input,.fact-controls .fact-period select{height:34px;min-height:34px;padding:6px 8px;font-size:12px;min-width:0;width:100%}
.fact-controls .fact-period input{min-width:114px}
.fact-controls .fact-period select{min-width:0;text-overflow:ellipsis}
.fact-controls .fact-period .range-field{min-width:0;font-size:11px}
.fact-controls .fact-period .range-trigger{width:100%;justify-content:space-between}
.fact-controls .fact-account{margin-right:auto}
.fact-controls .btn{min-height:34px;padding:7px 10px;font-size:12px;white-space:nowrap}
.fact-control-status{display:flex;align-items:center;justify-content:flex-end;gap:5px;margin-top:7px;font-size:10px;line-height:1.5;color:var(--muted);min-height:20px}
.fact-control-status .icon-btn{min-height:24px;min-width:28px;padding:2px 5px;font-size:12px}
.fact-controls{padding-bottom:0}
.fact-controls .status-line{bottom:8px}
#fact-history-form .field-hint{margin:12px 0;line-height:1.6}
#fact-history-form .inline-error[hidden]{display:none}
#fact-history-form .btn{margin-top:8px}
@media(max-width:1200px){.fact-controls .fact-period{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:1100px){.fact-control-row{gap:10px}.fact-control-status{margin-top:10px;padding-top:5px}.fact-controls .status-line{bottom:7px;font-size:9px}}
@media(max-width:650px){.fact-control-row h1{font-size:18px}.fact-account .tag{display:none}.fact-account .account-choice select{max-width:90px}.fact-controls .fact-period{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.fact-controls .fact-period .range-field,.fact-controls .fact-period .fact-scope-nmId{grid-column:1/-1}.fact-controls .fact-period .btn{width:100%}.fact-controls .status-line{position:static;margin-top:5px;font-size:9px}.fact-control-status{justify-content:flex-start}.fact-control-row>.btn{flex:1}.fact-account{align-self:center}.fact-account .account-bar{max-width:160px}.fact-controls{padding-top:0}}

.fact-info { margin:16px 0; border:1px solid var(--line); border-radius:12px; background:var(--panel); overflow:hidden; }
.fact-info-toggle { display:flex; align-items:center; justify-content:space-between; gap:16px; width:100%; padding:13px 20px; border:0; background:transparent; color:var(--text); font:inherit; font-size:13px; text-align:left; cursor:pointer; }
.fact-info-toggle > span:first-child { flex-shrink:0; font-weight:600; }
.fact-info-toggle:hover { background:rgba(190,166,227,.06); }
.fact-info-toggle:focus-visible { outline:2px solid #bda5e3; outline-offset:-3px; }
.fact-info-caret { display:inline-block; margin-right:6px; color:#bda5e3; }
.fact-info-toggle[aria-expanded="true"] .fact-info-caret { transform:rotate(90deg); }
.fact-info-status { font-size:12px; font-weight:400; color:var(--muted); }
.fact-info-status.is-active { color:#bda5e3; }
.fact-info-status.has-error { color:#ffa293; }
.fact-info-body { padding:0 20px 16px; border-top:1px solid var(--line); }
.fact-info-body[hidden] { display:none; }
.fact-info-body .fact-progress { margin-bottom:0; }
@media(max-width:600px) { .fact-info-toggle { padding:12px; gap:8px; flex-wrap:wrap; } .fact-info-body { padding:0 12px 12px; } }
/* One stored height applies to summary and expanded data rows. */
.fact-table tbody td { padding:0 8px; height:var(--fact-row-height,64px); box-sizing:border-box; }
.fact-table .fact-cell-content { height:calc(var(--fact-row-height,64px) - 1px); overflow:hidden; display:flex; flex-direction:column; justify-content:center; min-width:0; }
.fact-table .fact-day>.fact-cell-content { display:block; align-content:center; white-space:nowrap; }
.fact-table .fact-child .fact-day { padding-left:10px; }
.fact-table .fact-article { height:100%; }
.fact-table .fact-article-text { overflow:hidden; }
.fact-table .fact-article-text,.fact-table .fact-article-text .cell-sub { text-overflow:ellipsis;white-space:nowrap; }
.fact-table .fact-article-photo { flex-basis:28px;width:28px;height:min(40px,calc(var(--fact-row-height,64px) - 8px)); }
.fact-table .fact-article-photo img { width:100%;height:100%; }
.fact-table .fact-number { min-width:0;flex:0 1 auto;overflow:hidden;text-overflow:ellipsis; }
.fact-table .fact-change { flex:0 1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.fact-table .fact-header { gap:3px;padding-right:0; }
.fact-table th { padding-left:5px;padding-right:5px; }
.fact-comparison-label { flex-basis:20px;width:20px; }
.fact-date-info { display:inline-block;vertical-align:middle;max-width:calc(100% - 32px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:help;outline-offset:2px; }
.fact-child .fact-date-info { max-width:100%; }
.fact-row-toggle { margin-right:5px; }
.fact-row-resizer { position:absolute;left:0;right:0;bottom:0;width:100%;height:7px;min-height:0;padding:0;border:0;background:transparent;cursor:row-resize;touch-action:none;z-index:4; }
.fact-row-resizer:hover,.fact-row-resizer:focus-visible { background:#b8a4e855;outline:1px solid #b8a4e8; }
body.fact-row-resizing,body.fact-row-resizing * { cursor:row-resize!important;user-select:none!important; }
.fact-date-tooltip { position:fixed;z-index:10000;max-width:min(420px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;white-space:pre-line;overflow-wrap:anywhere;background:var(--panel,#242033);color:var(--text,#eee);border:1px solid var(--line,#665577);border-radius:8px;padding:12px 14px;box-shadow:0 8px 30px #0004;font-size:12px;line-height:1.6;pointer-events:none; }
.fact-height-label { display:flex;align-items:center;gap:6px;font-size:11px;color:var(--muted); }
.fact-height-label input { width:64px;min-height:30px;padding:4px 6px; }

/* Expense comparison is outside the scrollable table; both display modes share it. */
[data-fact-expense-tip] { cursor:help; border-bottom:1px dotted var(--muted); }
[data-fact-expense-tip]:focus-visible { outline:2px solid var(--coral);outline-offset:2px; }
.fact-expense-tooltip { position:fixed;z-index:10000;box-sizing:border-box;width:610px;max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);overflow:auto;overscroll-behavior:contain;background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:12px;padding:18px;box-shadow:0 12px 40px #0005;font-size:13px;line-height:1.4;text-align:left; }
.fact-expense-tooltip h3 { margin:0 0 8px;font-size:18px;font-weight:700; }
.fact-expense-dates { display:flex;gap:4px 20px;flex-wrap:wrap;margin-bottom:14px;color:var(--text);font-size:12px; }
.fact-expense-tooltip table { width:100%;table-layout:fixed;border-collapse:collapse; }
.fact-expense-tooltip thead,.fact-expense-tooltip tr { background:transparent; }
.fact-expense-tooltip .fact-expense-name { width:46%; }
.fact-expense-tooltip th,.fact-expense-tooltip td { position:static;height:auto;min-width:0;padding:10px 6px;border:0;border-bottom:1px solid var(--line);background:transparent;color:var(--text);text-align:left;font-size:13px;font-weight:400;line-height:1.4;white-space:normal;overflow-wrap:anywhere;vertical-align:top;font-variant-numeric:tabular-nums; }
.fact-expense-tooltip thead th { font-weight:700; }
.fact-expense-tooltip th:first-child { padding-left:0; }
.fact-expense-tooltip tr:last-child>* { border-bottom:0; }
.fact-expense-tooltip td.expense-increase { color:#ff888f; }
.fact-expense-tooltip td.expense-decrease { color:#6cdeb0; }
[data-theme="light"] .fact-expense-tooltip td.expense-increase { color:#b42336; }
[data-theme="light"] .fact-expense-tooltip td.expense-decrease { color:#146b46; }
.fact-expense-empty { margin:0 0 10px;font-size:12px; }
@media(max-width:600px) { .fact-expense-tooltip { padding:12px; }.fact-expense-tooltip .fact-expense-name { width:40%; }.fact-expense-tooltip th,.fact-expense-tooltip td { padding:8px 4px;font-size:12px; } }

/* Profit captions wrap between words; narrow saved widths retain a full title. */
.fact-table .fact-profit-caption{display:block;min-width:0;width:100%;max-width:100%;overflow:hidden}
.fact-table .fact-profit-caption>span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fact-table .expense-group-toggle>.fact-profit-caption{flex-shrink:1;height:auto;border:0;border-radius:0;background:transparent;color:inherit;font:inherit;line-height:1.4}
.fact-table .fact-header>span:has(.fact-profit-caption){width:100%;min-width:0}
.fact-table .fact-header .expense-group-toggle:has(.fact-profit-caption){display:flex;width:100%;max-width:100%}
.fact-table .fact-header .expense-group-toggle{display:flex;width:100%;max-width:100%;padding:0;align-items:center}
.fact-table .expense-group-toggle>.fact-group-sign{display:grid;place-items:center;width:20px;height:20px;min-height:20px;flex:0 0 20px;border:1px solid var(--line);border-radius:3px;line-height:1}
.fact-table .expense-group-toggle>.fact-group-caption{display:block;width:100%;max-width:100%;min-width:0;height:auto;border:0;background:transparent;color:inherit;font:inherit;line-height:1.35;white-space:normal;overflow-wrap:normal;word-break:normal;overflow:hidden;text-overflow:ellipsis}
.fact-column-row .fact-column-context{font-size:11px;line-height:1.35;color:var(--muted);margin-top:3px}

/* Saved WB charges use the same accessible floating panel as margin dynamics. */
[data-fact-charge-tip] { cursor:help;border-bottom:1px dotted var(--muted); }
[data-fact-charge-tip]:focus-visible { outline:2px solid var(--coral);outline-offset:2px; }
.fact-charge-tooltip { width:650px; }
.fact-charge-tooltip .fact-charge-reason { width:48%; }
.fact-charge-tooltip .fact-charge-count { width:21%; }
.fact-charge-tooltip .fact-charge-sum { width:31%; }
.fact-charge-tooltip .fact-charge-section th { padding-top:16px;padding-bottom:5px;font-weight:700;border-bottom:1px solid var(--line); }
.fact-charge-tooltip .fact-charge-amount { font-variant-numeric:tabular-nums; }
.fact-charge-note { margin:12px 0 0;font-size:12px;line-height:1.5;color:var(--text); }
.fact-charge-totals { border-top:1px solid var(--line);margin-top:12px;padding-top:10px; }
.fact-charge-totals>div { display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-top:5px; }
.fact-charge-totals>div>:last-child { text-align:right;overflow-wrap:anywhere; }
@media(max-width:600px) { .fact-charge-tooltip .fact-charge-reason { width:44%; }.fact-charge-tooltip .fact-charge-count { width:23%; }.fact-charge-tooltip .fact-charge-sum { width:33%; } }
