/* Dashboard appearance. Data, layout and chart geometry are shared by both themes. */
:root { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151e; --surface: #192230; --surface-raised: #222e40;
  --navy: #c3d3ff; --navy-light: #9eb9ff; --navy-dark: #f5dfa1;
  --coffee: #e1c49d; --coffee-light: #cbaa7e;
  --cream: #242f40; --cream-dark: #2a3546; --border: #465369;
  --text: #eef2f7; --text-muted: #b8c2d1;
  --pos: #7de2a3; --neg: #ffa3aa; --warn: #f9cf79; --gold: #f4c35d; --red: #ffa3aa;
  --best-soft: #183e30; --best-strong: #7de2a3;
  --worst-soft: #482a32; --worst-strong: #ffa3aa;
  --recent-strong: #c4cfdf; --selected-outline: #f4c35d;
}
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; border: 1px solid #8291a8; border-radius: 50%; background: #202b41; color: #f9d67d; cursor: pointer; }
.theme-toggle:hover { background: #344764; border-color: #c3d3ff; }
.theme-toggle:focus-visible { outline: 3px solid #f4c35d; outline-offset: 3px; }
.theme-icon { width: 23px; height: 23px; }
.theme-sun { display: none; }
html[data-theme="dark"] .theme-moon { display: none; }
html[data-theme="dark"] .theme-sun { display: block; }
#dashboard-header { gap: 16px; flex-wrap: wrap; position: relative; }
#dashboard-header > div:first-child { min-width: 0; }
@media(max-width:767px) { #dashboard-header { padding-right: 72px; } .theme-toggle { position: absolute; right: 16px; top: 16px; } }
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] header { background: linear-gradient(120deg,#1b2143,#24262e); }
html[data-theme="dark"] :is(.card,.kpi,.pnl-wrap,.inv-card,.modal,.kpi-table,.bank-card,.ceo-kpi,.ceo-insight,nav.tabs,.filter-bar,.mobile-context,.mobile-nav) { background: var(--surface); }
html[data-theme="dark"] :is(#filter-bar,#section-menu,#sec-finanzas .subtabs) { background: var(--bg); }
html[data-theme="dark"] :is(.bank-card.total,.inventory-coverage-card) { background: linear-gradient(180deg,#202a39,var(--surface)); }
html[data-theme="dark"] :is(input,select,textarea,.diario-sort-btn,.filter-select,.today-hour-cat-btn,.combined-dow-v98-btn,#diario-registro-toggle,#sec-finanzas .subtab-btn,.section-menu-head button,.section-menu-grid button) { background-color: var(--surface); color: var(--text); border-color: var(--border); }
html[data-theme="dark"] input::placeholder { color: var(--text-muted); opacity: 1; }
html[data-theme="dark"] :is(input,select,textarea) { accent-color: #aac5ff; }
html[data-theme="dark"] :is(.slicer button.active,.chip.active,.diario-sort-btn.active,.today-hour-cat-btn.active,.combined-dow-v98-btn.active,#sec-finanzas .subtab-btn.active,.pnl-period-toggle button[aria-pressed="true"]) { background: #344b7a; color: #fff; border-color: #a9c3ff; }
html[data-theme="dark"] :is(.tab-btn:hover,.tab-btn.active,.bank-card.active,.diario-sort-btn:hover,.today-hour-cat-btn:hover,.combined-dow-v98-btn:hover,.section-menu-grid button[aria-current="page"],.mobile-nav button[aria-current="page"]) { background: #293c59; color: #e2ebff; }
html[data-theme="dark"] :is(.mobile-nav button,.section-menu-grid button span,.scroll-hint) { color: var(--text-muted) !important; }
html[data-theme="dark"] .mobile-nav button[aria-current="page"] { color: #e2ebff !important; }
html[data-theme="dark"] :is(.mobile-context,.mobile-nav,.section-menu-grid button,.section-menu-head button) { border-color: var(--border); }
html[data-theme="dark"] :is(.pnl thead th,.matrix th,.kpi-table th,.ceo-table th,.modal-head,#costos-table th,#costos-est-table th,#inv-days th,#diario-registro-dia thead th) { background: #293c59 !important; color: #f4f7ff !important; }
html[data-theme="dark"] :is(.pnl thead th:first-child,.pnl thead th.col-fy-h,.matrix th:first-child) { background: #344b7a !important; }
html[data-theme="dark"] .pnl thead th.col-total-h { background: #f4c35d !important; color: #171c26 !important; }
html[data-theme="dark"] :is(.pnl tbody tr td,.matrix td:first-child) { background: var(--surface); }
html[data-theme="dark"] :is(.pnl tbody tr:nth-child(even) td,.matrix tr:nth-child(even) td,.matrix tr:nth-child(even) td:first-child,.acc-children tr td,.level-cat td) { background: #1e2938 !important; }
html[data-theme="dark"] :is(table.data td,table.data th,.pnl td,.pnl th,.matrix td,.modal-body td,.ceo-table td) { border-color: var(--border); }
html[data-theme="dark"] :is(.pnl tbody tr.row-total td,.matrix .total-row td,.diario-compare .total-row td,.level-month td,#combined-monthly-table tr.total-row td,#barra-subcat-month-v93 .total-row td,#inv-days tr.inv-total td) { background: #2a3b52 !important; color: #e0eaff !important; }
html[data-theme="dark"] :is(.pnl tbody tr.row-margin td,.pnl tbody tr.section-hdr td,.diario-compare .avg-row td,.today-diff-row td,.diario-compare .ticket-row td,.diario-compare .ticket-avg-row td,#diario-registro-dia .total-row td) { background: #2b3442 !important; color: var(--text) !important; }
html[data-theme="dark"] .pnl .col-fy { background: #233349 !important; }
html[data-theme="dark"] .pnl .col-total { background: #403825 !important; }
html[data-theme="dark"] :is(.pnl tbody tr.row-total-primary td,.pnl tbody tr.row-total-secondary td) { background: #423923 !important; color: #ffe5a4 !important; box-shadow: none; border-color: #b39246 !important; }
html[data-theme="dark"] :is(.pnl tbody tr.row-total-primary td:first-child,.pnl tbody tr.row-total-secondary td:first-child,.pnl tbody tr.row-total-primary td.col-total,.pnl tbody tr.row-total-secondary td.col-total) { background: #514329 !important; }
html[data-theme="dark"] .pnl tbody tr.row-ebitda td { background: #344b7a !important; color: #fff; }
html[data-theme="dark"] .pnl tbody tr.row-ebitda-pct td { background: #293c59 !important; color: #dce7ff; }
html[data-theme="dark"] :is(.note,.bank-card.active,.today-hour-cats,.diario-registro-mobile-summary,.sf30-summary-item) { background: #273141 !important; }
html[data-theme="dark"] :is(.today-kpi.exp,#hoy-ticket-kpis .kpi.exp) { background: #3a3027; border-color: #cbaa7e; }
html[data-theme="dark"] :is(.today-kpi.barra,#hoy-ticket-kpis .kpi.barra) { background: #24374e; border-color: #9eb9ff; }
html[data-theme="dark"] #diario-registro-dia tr.reg-exp td { background: #352f29 !important; }
html[data-theme="dark"] #diario-registro-dia tr.reg-barra td { background: #26374d !important; }
html[data-theme="dark"] #diario-registro-dia .src-exp { color: #e1c49d; }
html[data-theme="dark"] #diario-registro-dia .src-barra { color: #c3d3ff; }
html[data-theme="dark"] :is(.rank.g,.rank.b) { color: #171c26; }
html[data-theme="dark"] .rank.s { background: #b7c6da; color: #171c26; }
html[data-theme="dark"] .rank { background: #31405a; color: #e5edff; }
html[data-theme="dark"] .rank.g { background: #f4c35d; }
html[data-theme="dark"] .rank.b { background: #d4a574; }
html[data-theme="dark"] :is(.inv-card .incoming,.source-badge.sant) { background: #223e59; color: #b9ddff; }
html[data-theme="dark"] .source-badge.hsbc { background: #3c2c50; color: #e3c5ff; }
html[data-theme="dark"] .source-badge.plata { background: #344254; color: #e2e8f0; }
html[data-theme="dark"] :is(.days-pill.critical,.inv-card.critical .days,.ceo-status.bad) { background: #482a32; color: #ffb5ba; }
html[data-theme="dark"] :is(.days-pill.low,.inv-card.low .days,.source-badge.est,.ceo-status.watch) { background: #493b24; color: #f9d99b; }
html[data-theme="dark"] :is(.days-pill.ok,.ceo-status.good) { background: #183e30; color: #9aebba; }
html[data-theme="dark"] #inv-days tr.inv-critical td { background: #35252d; }
html[data-theme="dark"] #inv-days tr.inv-low td { background: #342f25; }
html[data-theme="dark"] :is(.matrix td.best-cell,table.data td.best-cell,#barra-subcat-month-v93 td.best-cell,.diario-compare .rank-heat-1) { background: #183e30 !important; color: #9aebba !important; }
html[data-theme="dark"] :is(.matrix td.worst-cell,table.data td.worst-cell,#barra-subcat-month-v93 td.worst-cell,.diario-compare .rank-heat-3,.diario-compare .rank-heat-5) { background: #482a32 !important; color: #ffb5ba !important; }
html[data-theme="dark"] :is(.diario-compare .rank-heat-2,.diario-compare .rank-heat-4,.matrix tr.row-warn td) { background: #493b24 !important; color: #f9d99b !important; }
html[data-theme="dark"] :is(table.data th.perf-sale,table.data th.perf-avg) { background: #293c59 !important; color: #e2ebff !important; }
html[data-theme="dark"] table.data th.perf-ub { background: #493b24 !important; color: #f9d99b !important; }
html[data-theme="dark"] table.data th.perf-ebitda { background: #183e30 !important; color: #9aebba !important; }
html[data-theme="dark"] :is(#costos-table td.cost-cat,#costos-est-table td.est-cat,#costos-est-table td.est-desc,#costos-est-table td.est-subtotal,#costos-table td.cost-value) { background: #1e2938 !important; }
html[data-theme="dark"] #costos-table td.cost-value.has-cost { background: #343123 !important; }
html[data-theme="dark"] :is(.pnl .cell-drill:hover,table.data tr:hover td,table.data td.click:hover,.matrix tbody tr:hover td,.matrix tbody tr:hover td:first-child,.matrix td.cell-num:hover,.detail-row:hover td,.diario-compare .daily-compare-click:hover td,#barra-subcat-month-v93 tr:hover td,#barra-subcat-month-v93 tr:hover td:first-child,#exp-products-month tbody tr:hover td,#exp-products-month tbody tr:hover td:first-child,#inv-days tbody tr:hover td,#costos-table td.cell-num:hover,#costos-est-table td.cell-num:hover,#bank-table td.bank-flow-cell:hover,#bank-table td.bank-flow-total:hover,#hoy-gasto-kpi:hover) { background: #34445c !important; }
html[data-theme="dark"] :is(.matrix .col-hover,table.data .col-hover,#barra-subcat-month-v93 .col-hover,#costos-table .col-hover,#costos-est-table .col-hover,#combined-monthly-table .col-hover) { background: #3b3a29 !important; color: #f5dfa1 !important; }
html[data-theme="dark"] :is(.matrix .selected-month,table.data .selected-month,#barra-subcat-month-v93 .selected-month,.diario-compare .selected-day) { background: #3b3a29 !important; color: #ffe5a4 !important; box-shadow: inset 0 0 0 2px #b99449 !important; }
html[data-theme="dark"] .hbar-track { background: #303c4c; }
html[data-theme="dark"] .hbar-fill { background: linear-gradient(90deg,#b69569,#e1c49d); }
html[data-theme="dark"] .hbar-fill.expendio { background: linear-gradient(90deg,#88a8f2,#c3d3ff); }
html[data-theme="dark"] .tooltip:hover::before { background: #304666; color: #fff; }
html[data-theme="dark"] .tooltip:hover::after { border-top-color: #304666; }
html[data-theme="dark"] .modal-bg { background: #050910b8; }
html[data-theme="dark"] #section-menu::backdrop { background: #050910b8; }
html[data-theme="dark"] :is(.card > div[id^="chart-"],.pnl-wrap,.matrix-wrap)::-webkit-scrollbar-thumb { background: #697b97; }
html[data-theme="dark"] * { scrollbar-color: #697b97 #1a2330; }
html[data-theme="dark"] body.wadi-nav-ready :focus-visible { outline-color: #f4c35d; }
html[data-theme="dark"] ::selection { background: #5375ad; color: #fff; }
html[data-theme="dark"] .acapulco-weather-v116 .wday .temps .tmin { opacity: .85; }
/* SVG charts: preserve series colors, adapt labels, grid lines and label surfaces. */
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text[stroke="white"] { stroke: var(--surface); }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) :is(rect,circle,path)[fill="white"] { fill: var(--surface); }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) :is(rect,circle,path)[stroke="white"] { stroke: var(--surface); }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) [stroke="#eee"] { stroke: #455269; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text[fill="#111827"] { fill: var(--text); }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text[fill="#64748b"] { fill: var(--text-muted); }
/* Inline styles emitted by legacy detail renderers. */
html[data-theme="dark"] [style*="background:var(--navy)"] { background: #344b7a !important; color: #fff; }
html[data-theme="dark"] [style*="background: var(--navy)"] { background: #344b7a !important; color: #fff; }
html[data-theme="dark"] [style*="background: white"], html[data-theme="dark"] [style*="background:white"] { background: var(--surface) !important; }
html[data-theme="dark"] [style*="color:#64748b"], html[data-theme="dark"] [style*="color: #64748b"] { color: var(--text-muted) !important; }
@media print {
  .theme-toggle { display: none !important; }
}
/* Remaining legacy rules used by daily rankings and performance charts. */
html[data-theme="dark"] #hoy-refresh-btn { background: #344b7a; color: #fff; }
html[data-theme="dark"] #hoy-refresh-btn:hover { background: #435f95; }
html[data-theme="dark"] :is(#best-days-barra,#best-days-expendio) th { background: #293c59 !important; color: #fff !important; }
html[data-theme="dark"] :is(#best-days-barra,#best-days-expendio,#combined-best-days) .day-section-row td { background: #273141 !important; color: var(--navy) !important; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) rect[fill="#fff8e1"] { fill: #3b3425; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) .dow-avg-label { fill: var(--text) !important; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) :is(.dow-avg-label.best-avg,.dow-avg.best-avg) { fill: var(--pos) !important; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) :is(.dow-avg-label.worst-avg,.dow-avg.worst-avg) { fill: var(--neg) !important; }
html[data-theme="dark"] #pnl-table.pnl tbody :is(tr.row-total-primary,tr.row-total-secondary) td { background: #423923 !important; color: #ffe5a4 !important; }
html[data-theme="dark"] #pnl-table.pnl tbody :is(tr.row-total-primary,tr.row-total-secondary) :is(td:first-child,td.col-total) { background: #514329 !important; }
html[data-theme="dark"] #inv-days td { border-color: var(--border); }
/* Stronger chart palette: separate series from labels, with opaque value labels. */
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) {
  --navy: #78aaff; --navy-light: #92baff; --coffee: #f3bc75; --coffee-light: #e8a855;
  --gold: #ffd263; --pos: #63e5a3; --neg: #ff8e9d;
  --best-strong: #63e5a3; --worst-strong: #ff8e9d; --recent-strong: #e2eafa;
  --text-muted: #d1dbe9; --selected-outline: #ffe3a1;
}
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text { fill: #eef4ff; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text[fill="var(--coffee)"] { fill: #ffce8e; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text[fill="var(--gold)"] { fill: #ffe29c; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text:is([fill="var(--pos)"],[fill="var(--best-strong)"],.best-avg) { fill: #8ef0b8 !important; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text:is([fill="var(--neg)"],[fill="var(--worst-strong)"],.worst-avg) { fill: #ffb3bd !important; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) text[stroke="white"] { stroke: #101820; stroke-width: 3px; paint-order: stroke; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) rect:is([fill="white"],[fill="#fff8e1"]) { fill: #101820; stroke: #8296b5; opacity: 1; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) [stroke="#eee"] { stroke: #63728a; stroke-opacity: .8; }
html[data-theme="dark"] :is(svg.chart,.sf30-chart-scroll svg) path[stroke-width="3"] { stroke-width: 3.5; }
html[data-theme="dark"] .legend { color: #d1dbe9; }
@media(max-width:767px) {
  #dashboard-header h1 { display: grid; grid-template-columns: 40px minmax(0,1fr); align-items: center; }
  #dashboard-header .brand-title { grid-column: 2; }
  #dashboard-header .acapulco-clock-v104 { grid-column: 1 / -1; margin: 0; font-size: 12px; }
}

html[data-theme="dark"] .sf30-value { stroke: #101820; stroke-width: 3px; paint-order: stroke; }
/* Original overlaid crepe chart: stronger series contrast in dark mode only. */
html[data-theme="dark"] :is(#chart-crepa-diario,#chart-crepa-barra) rect[opacity="0.28"] {
  fill: #718eb4;
  opacity: 1;
}
html[data-theme="dark"] :is(#chart-crepa-diario,#chart-crepa-barra) rect[opacity="0.95"] { opacity: 1; }
