:root{color-scheme:light}
.topline{position:sticky;top:0;z-index:25;background:var(--paper);align-items:center}
.topline-actions,.theme-switch{display:flex;align-items:center;gap:8px}.topline-actions{gap:16px}
.theme-switch button{min-height:34px;padding:6px 10px;font:600 12px/1.4 'Segoe UI',sans-serif;letter-spacing:0;white-space:nowrap}
#theme-system{font-size:10px;padding-inline:8px;color:var(--muted)}
@media(max-width:600px){.topline{gap:8px}.topline>span{max-width:95px;line-height:1.5}.topline-actions{gap:8px;flex-wrap:wrap;justify-content:flex-end}.topline-actions>#today{display:none}.theme-switch{gap:4px}.theme-switch button{min-height:34px}}
html[data-theme=dark]{color-scheme:dark;--ink:#dceae7;--muted:#a2bcb6;--paper:#101e24;--white:#192c33;--line:#375057;--green:#87d2bf;--lime:#294d48;--gold:#dfb182;--surface:#192c33;--surface-soft:#20363b;--surface-raised:#263f44;--chart-electricity:#dc8da3;--chart-water:#79b9dc;--chart-prepaid:#e0ae76;--chart-vat:#b49ad6;--chart-audiovisual:#e0b179}
html[data-theme=dark] body{background:radial-gradient(ellipse at top right,#193a3c,transparent 45%),#101e24;color:var(--ink)}
html[data-theme=dark] .topline{background:#101e24ed;color:var(--muted);border-color:var(--line);backdrop-filter:blur(12px)}
html[data-theme=dark] :is(.panel,.metrics article,.dash-score,.dash-insight,.dash-intro,.cash-hero,.treasury-hero,.treasury-history-card,.comparison-card,.growth-metric,.manual details,.territory-panel,.territory-region-grid>div,.region-card){background:var(--surface);color:var(--ink);border-color:var(--line);box-shadow:0 8px 24px #0002}
html[data-theme=dark] :is(.treasury-header,.treasury-history,.treasury-composition,.treasury-region,.hero-channel-grid>section,.cash-activity-grid>section,.analysis-tools,.receipt-rank-row,.territory-reconciliation,.counter-regions,.fiscal-mini>div,.billing-card-details,.manual-nav,.manual-hero,.manual-start){background:var(--surface-soft);border-color:var(--line);color:var(--ink)}
html[data-theme=dark] :is(.dash-score.prepaid,.prepaid-theme .dash-intro){background:#332c26;border-color:#8e6c4c}
html[data-theme=dark] :is(.dash-score.electricity,.electricity-theme .dash-intro,.electricity-theme .dash-insight.primary,.electricity-theme .metrics article:first-child){background:#342a34;border-color:#9f6379;color:var(--ink)}
html[data-theme=dark] :is(.dash-score.water,.water-theme .dash-intro,.water-theme .dash-insight.primary,.water-theme .metrics article:first-child,.water-insight){background:#203440;border-color:#568cab;color:var(--ink)}
html[data-theme=dark] :is(.vat-theme .dash-intro,.vat-theme .dash-insight.primary,.vat-theme .metrics article:first-child){background:#302b42;border-color:#9380b3;color:var(--ink)}
html[data-theme=dark] :is(.audiovisual-theme .dash-intro,.audiovisual-theme .dash-insight.primary,.audiovisual-theme .metrics article:first-child){background:#373026;border-color:#ac895b;color:var(--ink)}
html[data-theme=dark] :is(.electricity-theme){--green:#e09caf;--lime:#4e3542}
html[data-theme=dark] #workspace.water-theme{--green:#8ec9e7;--lime:#2b485c}
html[data-theme=dark] .vat-theme{--green:#baa1df;--lime:#443659}
html[data-theme=dark] .audiovisual-theme{--green:#e1b276;--lime:#51402c}
html[data-theme=dark] :is(h1,h2,h3,.money-value,.cash-total,.dash-score-value,.growth-metric>strong,.treasury-currency,.treasury-header .dash-overline,.treasury-composition b,.cash-hero h2,.cash-hero-details strong,.comparison-number){color:var(--ink)}
html[data-theme=dark] :is(.cash-hero p,.cash-hero .dash-overline,.cash-hero-details span,.cash-hero-details small,.dash-intro p,.dash-intro small,.dash-insight small,.dash-insight span,.dash-score-stats small,.receipt-regions .hint,.territory-reconciliation,.manual p,.hint){color:var(--muted)}
html[data-theme=dark] :is(.hero-channel-grid span,.hero-channel-grid small,.treasury-channel-label span){color:var(--muted)}
html[data-theme=dark] :is(.eyebrow,.water-theme .eyebrow,.manual-nav a,.manual-index a,details summary,a){color:var(--green)}
html[data-theme=dark] :is(button,input,select,textarea,.select-trigger,.control-popover,.select-menu,.date-line,.calendar,.calendar-year,.back-to-top){background:var(--surface);border-color:var(--line);color:var(--ink)}
html[data-theme=dark] :is(.select-option:hover,.select-option:focus-visible,.calendar-day:hover,tr:hover td){background:var(--surface-raised);color:var(--ink)}
html[data-theme=dark] :is(.select-option[aria-selected=true],.calendar-day.selected,.primary,.button){background:#26796d;color:#fff}
html[data-theme=dark] :is(.calendar-clear,th,table tfoot td,table tfoot th,.table-total td){background:var(--surface-soft);color:var(--ink);border-color:var(--line)}
html[data-theme=dark] :is(td,th,.job,.record-detail>div,.filter-dialog>.panel-heading,footer){border-color:var(--line)}
html[data-theme=dark] :is(dialog,.filter-dialog){background:var(--surface);color:var(--ink);border-color:var(--line);box-shadow:0 24px 80px #0008}
html[data-theme=dark] dialog::backdrop{background:#050e16bd}
html[data-theme=dark] :is(.coverage-badge,.source-delay-note,#notice){background:#3b3224;color:#f0cf94;border-color:#99794d}
html[data-theme=dark] :is(.badge,.receipt-change.neutral b){background:#344b51;color:#c9dcd7}
html[data-theme=dark] :is(.receipt-change.up b,.dash-trend.up,.completed){background:#23463e;color:#a2e4c9}
html[data-theme=dark] :is(.receipt-change.down b,.dash-trend.down,.failed,.retry){background:#4a303a;color:#f0b0bf}
html[data-theme=dark] .is-updating{background:#23443f;color:#c0eee0;border-color:#548a7e}
html[data-theme=dark] :is(.analytics-svg text,.management-svg text,.chart text){fill:var(--muted)}
html[data-theme=dark] :is(.analytics-svg .chart-value,.chart-value){fill:var(--ink)}
html[data-theme=dark] .chart-grid{stroke:#365057}html[data-theme=dark] .chart-baseline{stroke:#8ca9a3}
html[data-theme=dark] .water-theme .management-svg .series-0{fill:#79b9dc}html[data-theme=dark] .water-theme .management-svg .series-1{fill:#b2d7eb}html[data-theme=dark] .water-theme .management-svg .series-2{fill:#8fa9d6}
html[data-theme=dark] :is(.receipt-rank-track){background:#3a4b4e;fill:#30474c}
html[data-theme=dark] .rail{background:linear-gradient(165deg,#10272f,#133e3d);box-shadow:8px 0 26px #0002}
html[data-theme=dark] .rail nav button{background:transparent;color:#d3e8e3}
html[data-theme=dark] .rail nav button:hover{background:#284c4b}
html[data-theme=dark] .rail nav button.active{background:#092d2b;color:#fff}
html[data-theme=dark] .rail .brand{color:#e7f7de}html[data-theme=dark] .rail-details summary{color:#d3e8e3}
html[data-theme=dark] .theme-switch button:focus-visible{outline:2px solid #b9eddc;outline-offset:3px}

/* V21: superfícies, gráficos e controlos partilham a mesma paleta. */
.topline{margin-right:calc(-1 * clamp(20px,3.2vw,50px));padding-right:clamp(20px,3.2vw,50px)}
.theme-switch #theme-toggle{position:relative;display:inline-flex;align-items:center;justify-content:space-between;width:64px;height:34px;min-height:34px;padding:0 8px;border-radius:24px;overflow:hidden;background:#e2eeea;color:#366b62;transform:none;box-shadow:none}
.theme-switch #theme-toggle>span{pointer-events:none;font-size:15px;line-height:1;z-index:1}
.theme-switch #theme-toggle .theme-thumb{position:absolute;left:3px;top:3px;width:26px;height:26px;border-radius:50%;background:#fff;box-shadow:0 2px 5px #0003;transition:transform .2s;z-index:0}
html[data-theme=dark] .theme-switch #theme-toggle{background:#28434c;color:#d9e9e5;border-color:#54727a}
html[data-theme=dark] #theme-toggle .theme-thumb{transform:translateX(30px);background:#55727d}
html[data-theme=dark] :is(.territory-intro,.territory-region-grid section,.territory-water .territory-region-grid section,.territory-electricity .territory-region-grid section,.scope-bar,.cash-detail-figures>div,.manual-origin,.manual-callout,.manual-example,.manual-formula,.manual-index,.manual-nav a,.manual-steps>div,.manual-source-grid>div,.manual-view-grid>div){background:var(--surface-soft);border-color:var(--line);color:var(--ink)}
html[data-theme=dark] :is(.territory-intro p,.territory-intro h2,.cash-detail-figures strong,.manual-formula){color:var(--ink)!important}
html[data-theme=dark] .cash-detail-figures span{color:var(--muted)}
html[data-theme=dark] :is(.territory-track,.receipt-rank-track){background:#30474c}
html[data-theme=dark] :is(.analytics-svg,.chart-key) rect[fill="#dce8e4"]{fill:#49636b}
html[data-theme=dark] *{scrollbar-color:#658f88 #182e35}
html[data-theme=dark] ::-webkit-scrollbar-track{background:#182e35}
html[data-theme=dark] ::-webkit-scrollbar-thumb{background:#658f88;border:1px solid #182e35}
html[data-theme=dark] ::-webkit-scrollbar-corner{background:#182e35}
html[data-theme=dark] .manual-nav a:hover{background:var(--surface-raised)}
@media(min-width:1441px){
 .treasury-regional{display:grid;grid-template-rows:auto auto repeat(3,minmax(0,1fr));gap:14px}
 .treasury-regional>.treasury-region-list{display:contents}
 .treasury-regional .treasury-region{margin:0;min-height:0;display:flex;flex-direction:column;justify-content:center}
 .treasury-primary>.hero-channel-grid{flex:0 0 auto;min-height:120px;margin-top:0}
 .treasury-primary>.hero-channel-grid>section{height:auto;justify-content:center}
 .treasury-primary>.hero-channel-grid>section>small{margin-top:0}
}
.yesterday-grid{display:flex;justify-content:space-between;gap:24px;flex-wrap:wrap}.yesterday-grid>div{flex:0 1 auto;min-width:0}
@media(max-width:1250px){.topline{margin-right:-25px;padding-right:25px}.yesterday-grid>div{flex:1 1 220px}}
@media(max-width:900px){.topline{margin-right:-18px;padding-right:18px}}
@media(prefers-reduced-motion:reduce){.theme-thumb{transition:none!important}}

/* V22: montantes de canais legíveis e detalhe factual da localização pendente. */
.treasury-primary .hero-channel-grid strong{font-size:26px}
.treasury-history-card:last-child{margin-top:0}
.treasury-unlocated-detail{display:grid;gap:10px;margin-top:12px;font-size:10px;line-height:1.6;color:var(--muted)}
.treasury-unlocated-detail span,.treasury-unlocated-detail strong,.treasury-unlocated-detail small{display:block}
.treasury-unlocated-detail strong{font:700 14px 'Bahnschrift','Trebuchet MS',sans-serif;color:var(--ink);white-space:nowrap;margin:3px 0}
.treasury-unlocated-detail small{font-size:10px;line-height:1.6}
@container(max-width:600px){.treasury-primary .hero-channel-grid{grid-template-columns:1fr}}

/* Mesma altura intrínseca nos três cartões, incluindo quando o detalhe abre. */
.treasury-history-cards{display:grid;grid-auto-rows:1fr;gap:12px;min-width:0}
.treasury-history-cards>.treasury-history-card{margin:0;min-width:0}

/* Mesmo alinhamento, tipografia e respiro das parcelas Norte/Sul. */
.treasury-unlocated-detail .treasury-origin-row{display:flex;justify-content:space-between;align-items:baseline;gap:10px;min-height:40px}
.treasury-unlocated-detail .treasury-origin-row strong{font-size:17px;line-height:1.25;margin:0}
.treasury-unlocated-detail{display:block;margin-top:14px;min-height:50.5px}
.treasury-unlocated-detail .treasury-origin-row{min-height:0}
.treasury-unlocated-detail small{line-height:14.625px}
@media(min-width:1441px){.treasury-regional>.treasury-unlocated{min-height:160px}}

/* Cada bloco conserva a altura quando outra comparação é aberta. */
.treasury-layout{align-items:start}
.treasury-history-cards{grid-auto-rows:auto;align-items:start}
.treasury-history-card{min-height:147.5px}
.treasury-primary>.hero-channel-grid{margin-top:0}
@media(min-width:1441px){
 .treasury-regional{grid-template-rows:auto auto;grid-auto-rows:auto}
 .treasury-regional .treasury-region{min-height:160px}
}

/* Blocos de texto e colunas partilham o fundo do card que os contém. */
html[data-theme=dark] :is(.fiscal-mini>div,.billing-card-details,.treasury-history){background:transparent;box-shadow:none}
.treasury-composition li{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 12px;margin-top:12px}
.treasury-composition .channel-track{grid-column:1/-1;height:8px;border-radius:4px;overflow:hidden;background:var(--line)}
.treasury-composition .channel-track rect{rx:4px}
#dashboard,#operations{overflow-anchor:none}

/* Bases comuns sem esticar os cartões quando uma comparação abre. */
.treasury-composition .channel-track{border-radius:0}
.treasury-composition .channel-track rect{rx:0;ry:0}
@media(min-width:1441px){
 .treasury-layout{align-items:stretch}
 .treasury-history-cards{display:flex;flex-direction:column;flex:1;justify-content:space-between;align-items:stretch;gap:12px}
 .treasury-history-cards>.treasury-history-card{flex:0 0 auto}
 .treasury-primary>.treasury-composition{flex:1;display:flex;flex-direction:column}
 .treasury-composition ul{flex:1;align-content:space-between}
 .treasury-regional{display:flex;flex-direction:column;justify-content:space-between;gap:14px}
 .treasury-regional .treasury-region{flex:0 0 auto}
}
@supports(grid-template-rows:subgrid){
 @media(min-width:1101px){
  .dash-score-grid:has(>.dash-score>.receipt-regions){row-gap:0}
  .dash-score-grid:has(>.dash-score>.receipt-regions)>.dash-score{display:grid;grid-template-rows:subgrid;grid-row:span 8}
 }
}

.topline>span{white-space:nowrap}
.hamburger{display:flex;flex-direction:column;gap:5px;width:22px}
.hamburger i{display:block;height:2px;background:currentColor;width:100%}
.theme-switch #theme-toggle{width:48px;height:26px;min-height:26px;padding:0 5px;opacity:.85}
.theme-switch #theme-toggle>span{font-size:12px}
.theme-switch #theme-toggle .theme-thumb{width:18px;height:18px;left:3px;top:3px;box-shadow:none}
html[data-theme=dark] #theme-toggle .theme-thumb{transform:translateX(22px)}
@media(max-width:900px){
 .rail{position:sticky;top:0;z-index:40;padding:14px 18px;transition:transform .16s ease}
 .mobile-rail-hidden .rail:not(.menu-open){transform:translateY(-100%);pointer-events:none}
 .rail.menu-open{max-height:85dvh;overflow-y:auto}
 #menu-toggle{padding:10px;min-width:42px;min-height:42px;display:flex;justify-content:center;align-items:center}
 .rail-mobile-head .brand{font-size:28px}.rail-mobile-head .brand small{margin-top:5px;font-size:8px}
 .topline{position:static;padding-top:10px;padding-bottom:10px;gap:10px}
 .topline>span{max-width:none;flex:1;font-size:clamp(7px,2vw,9px);letter-spacing:.5px;line-height:1.4}
 .topline-actions{gap:8px;flex-wrap:nowrap}.topline-actions>#today{display:none}
 .heading{padding:18px 0 12px;gap:10px}.heading h1{margin:6px 0;font-size:32px}
 .treasury-primary{gap:16px}.treasury-history{gap:12px}
 .treasury-region-list{gap:12px}.treasury-regional>.treasury-unlocated{margin-top:12px}
 .treasury-regional>.treasury-caption{margin:6px 0 14px}
 .treasury-history>.treasury-caption{margin:0}
 .batch-note[aria-hidden=true]{display:none}
}
@media(prefers-reduced-motion:reduce){.rail{transition:none}}
