/* Tema escuro: notas e produtos (app.css), despesas e lançamentos (excel_dashboard.css) e login */
html[data-theme=dark]{
  color-scheme:dark;
  --ink:#dbe4ef;--muted:#97a9c0;--line:#2b3b4e;--border:#2b3b4e;--paper:#162230;--navy:#2b6a7c;--amber:#f0c674;--red:#f3a58b;
  --bg:#0e1823;--surface:#162230;--surface-2:#1c2a3a;--row-alt:#192636;--hover:#1f3647;--inner:#243445;--heading:#f1f5fa;--strong:#f4f7fb;--link:#7ab8ff;
  color:var(--ink);background:var(--bg)
}
html[data-theme=dark] body{background:var(--bg)}
html[data-theme=dark] h1,html[data-theme=dark] h2,html[data-theme=dark] .panel h2{color:var(--heading)}

/* Menu (lateral no PC, barra inferior e folha "Mais" no celular): só as cores mudam */
html[data-theme=dark] .site-sidebar{--menu-bg:linear-gradient(160deg,#0f1d2b,#0c1824);--menu-solid:#101d2a;--menu-hover:#1a3043;
  --menu-active:#163f4d;--menu-pill:#1f5a66;--menu-line:#26394c;--menu-muted:#8297ae;box-shadow:1px 0 0 #1f2e3e}
html[data-theme=dark] dialog.menu-sheet{background:var(--menu-solid);color:var(--menu-ink);border:0;box-shadow:0 -10px 40px #000a}
html[data-theme=dark] .menu-sheet-head h2{color:var(--menu-strong)}
@media(max-width:760px){html[data-theme=dark] .site-sidebar{box-shadow:0 -1px 0 #1f2e3e,0 -6px 18px #0006}}

/* Superfícies */
html[data-theme=dark] .filters,html[data-theme=dark] .metric,html[data-theme=dark] .panel,html[data-theme=dark] .kpi,
html[data-theme=dark] .table-scroll,html[data-theme=dark] .loading,html[data-theme=dark] .empty,
html[data-theme=dark] dialog,html[data-theme=dark] .detail-header,html[data-theme=dark] .login-card{background:var(--surface);border-color:var(--line);color:var(--ink)}
html[data-theme=dark] #products-view .table-scroll,html[data-theme=dark] #notes-view .table-scroll{background:transparent}
html[data-theme=dark] dialog{box-shadow:0 20px 80px #0009}
html[data-theme=dark] dialog::backdrop{background:#020810b0}

/* Controles */
html[data-theme=dark] button{color:var(--ink)}
html[data-theme=dark] :where(body:not(.view-expenses) button:not(.site-link)){background:var(--surface);border-color:#3a5068}
html[data-theme=dark] :where(body:not(.view-expenses) button:not(.site-link)):hover{background:var(--hover)}
html[data-theme=dark] .quiet{background:transparent;border-color:#3a5068}
html[data-theme=dark] .filter-bottom .quiet{border:0}
html[data-theme=dark] input,html[data-theme=dark] select{background-color:#111c28;border-color:#33465b;color:var(--ink)}
html[data-theme=dark] .view-expenses select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23c3d0df' stroke-width='2'/%3E%3C/svg%3E")}
html[data-theme=dark] input::placeholder,html[data-theme=dark] .search-field input::placeholder{color:#7d90a8}
html[data-theme=dark] .search-field{background:#111c28;border-color:#33465b;color:#8ea2ba}
html[data-theme=dark] .search-field input{background:transparent;color:var(--ink)}
html[data-theme=dark] .button,html[data-theme=dark] .outline{background:var(--surface);border-color:#3a5068;color:var(--ink)}
html[data-theme=dark] .outline:hover{background:var(--hover)}
html[data-theme=dark] .primary{background:#2b6a7c;border-color:#2b6a7c;color:white}
html[data-theme=dark] .primary:hover{background:#347f93}
html[data-theme=dark] .switch-track{background:#46556a}
html[data-theme=dark] .text-button,html[data-theme=dark] .back-to-notes{color:var(--link)}
html[data-theme=dark] .icon-button:hover{background:var(--hover)}

/* Abas e segmentos */
html[data-theme=dark] .tabs,html[data-theme=dark] .segments{background:var(--surface-2);border-color:var(--line)}
html[data-theme=dark] .tabs button,html[data-theme=dark] .segments button{background:transparent;color:var(--muted)}
html[data-theme=dark] .tabs button:hover,html[data-theme=dark] .segments button:hover{background:var(--hover);color:var(--ink)}
html[data-theme=dark] .tabs .active,html[data-theme=dark] .tabs .active:hover,
html[data-theme=dark] .segments button.active{background:#2f5578;color:white;box-shadow:0 1px 3px #0006}

/* Números */
html[data-theme=dark] .metric strong,html[data-theme=dark] .kpi strong{color:var(--strong)}
html[data-theme=dark] #review,html[data-theme=dark] .kpi.amber strong{color:#e9ac4c}
html[data-theme=dark] .expense-kpis .kpi-label{color:var(--ink)}
html[data-theme=dark] .kpi-icon{background:#1a4542;color:#8fe3d5}
html[data-theme=dark] .purple .kpi-icon{background:#342c52;color:#cbbdf4}
html[data-theme=dark] .gold .kpi-icon{background:#46361a;color:#f3cf8a}

/* Tabelas */
html[data-theme=dark] th,html[data-theme=dark] .entries-table th,html[data-theme=dark] .category-table th{background:var(--surface-2);color:var(--ink);border-color:var(--line)}
html[data-theme=dark] .entries-table th{border-right-color:var(--inner)}
html[data-theme=dark] td,html[data-theme=dark] .entries-table td,html[data-theme=dark] .category-table td{border-bottom-color:var(--inner)}
html[data-theme=dark] .entries-table td{border-right-color:#1f2e3e}
html[data-theme=dark] tbody tr:nth-child(even),html[data-theme=dark] .entries-table tbody tr:nth-child(even){background:var(--row-alt)}
html[data-theme=dark] tbody tr:hover,html[data-theme=dark] .entries-table tbody tr:hover{background:var(--hover)}
html[data-theme=dark] .group-row{background:#182433}
html[data-theme=dark] .group-row,html[data-theme=dark] .group-list .group-row{border-top-color:var(--line)}
html[data-theme=dark] .group-list .group-row{background:transparent}
html[data-theme=dark] .expand-group,html[data-theme=dark] .subcategory-name,html[data-theme=dark] .ranked-category-name,
html[data-theme=dark] .category-bar{color:var(--ink)}
html[data-theme=dark] .category-bar:hover{background:var(--hover)}
html[data-theme=dark] .category-name:hover,html[data-theme=dark] .subcategory-name:hover,html[data-theme=dark] .ranked-category-name:hover span{color:#7fd0dc}
html[data-theme=dark] .subcategory-row td:last-child,html[data-theme=dark] .no-subcategories,html[data-theme=dark] .entry-supplier,
html[data-theme=dark] .panel-subtitle,html[data-theme=dark] .expense-note,html[data-theme=dark] .expense-controls>p,html[data-theme=dark] .back-to-notes{color:var(--muted)}
html[data-theme=dark] .bar-track{background:var(--inner);border-left-color:#3a4d62}
html[data-theme=dark] .chart-value{fill:var(--heading)}
html[data-theme=dark] .chart-month{fill:var(--muted)}
html[data-theme=dark] .pagination button,html[data-theme=dark] .page-gap{background:var(--surface);border-color:var(--line);color:var(--ink)}
html[data-theme=dark] .pagination .quiet{background:transparent}
html[data-theme=dark] .pagination button:hover{background:var(--hover)}
html[data-theme=dark] .pagination button.current{background:#18404a;color:#86dbe4;border-color:#2a6470}
html[data-theme=dark] .table-hint{background:#162636;border-color:var(--line);color:#a9bdd5}
html[data-theme=dark] .table-hint .icon{color:#6cc3e0}

/* Selos e avisos */
html[data-theme=dark] .badge{background:#243243;color:#a9b8ca}
html[data-theme=dark] .badge.manual{background:#173f39;color:#8fd9c9}
html[data-theme=dark] .badge.sugestao{background:#43361a;color:#f0c674}
html[data-theme=dark] .badge.rever{background:#4a2a22;color:#f0a08a}
html[data-theme=dark] .forecast-cell .badge,html[data-theme=dark] .review-cell .badge{background:#4a3a16;color:#f3c562}
html[data-theme=dark] .notice{background:#3a3020;color:#ecd39e;border-color:#4d3f22}
html[data-theme=dark] .view-expenses .notice{background:#16303f;color:#a9cde6;border-color:#24475b}
html[data-theme=dark] .error{color:#f3a58b}
html[data-theme=dark] .view-expenses .error{background:#3d2019;border-color:#5c3125}
html[data-theme=dark] .category-source-note{background:#332a16;color:#e8cc8a;border-top-color:#4d3f1f}
html[data-theme=dark] .item-price .discount-price{color:#5cc7c4}
html[data-theme=dark] .empty>span,html[data-theme=dark] .empty>.icon{color:var(--muted)}

/* Login */
html[data-theme=dark] .login-page{background:radial-gradient(ellipse at 0 100%,#12323b,transparent 65%),var(--bg)}
html[data-theme=dark] .login-card{box-shadow:0 20px 70px #0007}
html[data-theme=dark] .brand-icon{background:#2b6a7c}

/* Histórico de preços */
html[data-theme=dark] .best-vendor{color:#5cc7c4!important}
html[data-theme=dark] .change.up{color:#f0907c}
html[data-theme=dark] .change.down{color:#5cc7c4}
html[data-theme=dark] .chart-grid{stroke:var(--inner)}
html[data-theme=dark] .chart-axis{fill:var(--muted)}
html[data-theme=dark] .chart-line{stroke:#4a5f77}
html[data-theme=dark] .chart-dot{stroke:var(--surface)}
html[data-theme=dark] .product-thumb{background:var(--surface-2);border-color:var(--line)}
html[data-theme=dark] .catalog-name{color:#5cc7c4!important}
@media(max-width:640px){html[data-theme=dark] .card-table tbody tr:nth-child(even){background:transparent}html[data-theme=dark] .card-table td{border-bottom:0}}
html[data-theme=dark] .filter-toggle.open{background:var(--hover)}
html[data-theme=dark] .filter-chip{background:#163a44;border-color:#24555f;color:#9fdde3}
html[data-theme=dark] .search-shortcut{background:#2b6a7c;color:white;box-shadow:0 6px 20px #000a}
html[data-theme=dark] .search-shortcut:hover{background:#347f93}
html[data-theme=dark] .total-spent{color:#5cc7c4}
html[data-theme=dark] .card-difference{color:#e9ac4c}
html[data-theme=dark] .checked-mark{color:#6fd3a0}
html[data-theme=dark] .comment-thread{background:var(--surface-2)}
html[data-theme=dark] .comment-actions textarea,html[data-theme=dark] .comment-new textarea{background:var(--surface);color:var(--ink)}
html[data-theme=dark] .comment-mark,html[data-theme=dark] .comment-thread.aberto .comment-status{color:var(--link)}
html[data-theme=dark] .comment-mark.pergunta,html[data-theme=dark] .comment-mark.respondido,html[data-theme=dark] .comment-thread.pergunta .comment-status,html[data-theme=dark] .comment-thread.respondido .comment-status{color:var(--amber)}
html[data-theme=dark] .rec-mes{background:#243243;color:#a9b8ca}
html[data-theme=dark] .rec-mes.confirmada{background:#173f2c;color:#7fd8a8}
html[data-theme=dark] .rec-mes.prevista{background:#43361a;color:#f0c674}
