/* A preferência é aplicada no <html> antes das folhas de estilo carregarem. */
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:34px;padding:6px 11px;border:1px solid #dfe6f2;border-radius:9px;background:#f6f8ff;color:#4561c9;box-shadow:none;font-size:11px;font-weight:800}
.theme-toggle:hover{background:#eaf0ff;border-color:#b9c8f4;color:#3151be;transform:none}
.theme-toggle-icon{font-size:17px;line-height:1}
.guest-theme-toggle{position:fixed;top:20px;right:22px;z-index:5}
@media(max-width:480px){.theme-toggle{min-width:35px;padding:6px}.topbar .theme-toggle-text{display:none}.guest-theme-toggle .theme-toggle-text{display:inline}}

html[data-theme="dark"]{
    --dark-bg:#101827;
    --dark-surface:#182337;
    --dark-surface-raised:#1e2c43;
    --dark-field:#121d30;
    --dark-border:#30415b;
    --dark-text:#d8e2f2;
    --dark-heading:#f3f7ff;
    --dark-muted:#a4b4ce;
    --dark-link:#9fb5ff;
    color-scheme:dark;
    color:var(--dark-text);
    background:var(--dark-bg);
}
html[data-theme="dark"] body{background:var(--dark-bg);color:var(--dark-text)}
html[data-theme="dark"] :focus-visible{outline-color:#afc3ff}
html[data-theme="dark"] a{color:var(--dark-link)}
html[data-theme="dark"] a:hover{color:#d3dfff}
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3{color:var(--dark-heading)}
html[data-theme="dark"] .muted,
html[data-theme="dark"] .small,
html[data-theme="dark"] .page-heading p,
html[data-theme="dark"] .section-intro small,
html[data-theme="dark"] .step-note,
html[data-theme="dark"] .topbar-path,
html[data-theme="dark"] .topbar-date{color:var(--dark-muted)}

/* Estrutura e superfícies compartilhadas */
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .quick-link,
html[data-theme="dark"] .catalog-overview>div,
html[data-theme="dark"] .tool-disclosure,
html[data-theme="dark"] .catalog-filter,
html[data-theme="dark"] .catalog-bulk,
html[data-theme="dark"] .integration-stats>div,
html[data-theme="dark"] .setup-step,
html[data-theme="dark"] .login-panel,
html[data-theme="dark"] .erp-modal,
html[data-theme="dark"] details,
html[data-theme="dark"] .finance-tabs a,
html[data-theme="dark"] .product-image-card,
html[data-theme="dark"] .stock-product-results,
html[data-theme="dark"] .pos-results{
    background:var(--dark-surface);
    border-color:var(--dark-border);
    color:var(--dark-text);
    box-shadow:none;
}
html[data-theme="dark"] .sidebar-help,
html[data-theme="dark"] .finance-filter,
html[data-theme="dark"] .finance-method,
html[data-theme="dark"] .finance-total-row,
html[data-theme="dark"] .technical-details,
html[data-theme="dark"] .publish-card,
html[data-theme="dark"] .pos-line,
html[data-theme="dark"] .pos-discount,
html[data-theme="dark"] .axis-row,
html[data-theme="dark"] .grid-personalization-prices,
html[data-theme="dark"] details details,
html[data-theme="dark"] .image-links-preview,
html[data-theme="dark"] .image-links-option,
html[data-theme="dark"] .variant-thumb,
html[data-theme="dark"] .product-thumb{
    background:var(--dark-surface-raised);
    border-color:var(--dark-border);
    color:var(--dark-text);
}
html[data-theme="dark"] .guest-content{background:radial-gradient(circle at 80% 10%,#202e53 0,transparent 34%),radial-gradient(circle at 8% 83%,#27284b 0,transparent 30%),var(--dark-bg)}
html[data-theme="dark"] .brand,
html[data-theme="dark"] .brand:hover,
html[data-theme="dark"] .brand-copy strong,
html[data-theme="dark"] .topbar-path strong,
html[data-theme="dark"] .topbar-user,
html[data-theme="dark"] .sidebar-help strong,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .finance-method strong,
html[data-theme="dark"] .finance-total-row th,
html[data-theme="dark"] .catalog-overview strong,
html[data-theme="dark"] .integration-stats strong,
html[data-theme="dark"] .quick-link strong,
html[data-theme="dark"] .customer-name,
html[data-theme="dark"] .customer-profile-grid strong,
html[data-theme="dark"] .order-facts strong,
html[data-theme="dark"] .order-items-table td strong,
html[data-theme="dark"] .order-grand-total,
html[data-theme="dark"] .order-total-line strong,
html[data-theme="dark"] .empty-state strong,
html[data-theme="dark"] .pos-line strong,
html[data-theme="dark"] .pos-summary strong,
html[data-theme="dark"] .delete-product-modal strong{color:var(--dark-heading)}
html[data-theme="dark"] .brand-copy small,
html[data-theme="dark"] .sidebar-section,
html[data-theme="dark"] .sidebar-help small,
html[data-theme="dark"] .cards .card,
html[data-theme="dark"] .finance-method span,
html[data-theme="dark"] .finance-method small,
html[data-theme="dark"] .finance-cards .metric-note,
html[data-theme="dark"] .finance-goal-facts,
html[data-theme="dark"] .quick-link small,
html[data-theme="dark"] .catalog-overview span,
html[data-theme="dark"] .catalog-overview small,
html[data-theme="dark"] .integration-stats span,
html[data-theme="dark"] .step-heading p,
html[data-theme="dark"] .order-facts span,
html[data-theme="dark"] .order-heading p:last-child,
html[data-theme="dark"] .order-variant-name,
html[data-theme="dark"] .order-total-line,
html[data-theme="dark"] .customer-profile-grid span,
html[data-theme="dark"] .customer-profile-notes,
html[data-theme="dark"] .image-links-count,
html[data-theme="dark"] .catalog-pager,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .channel-card-footer,
html[data-theme="dark"] .pos-summary>div,
html[data-theme="dark"] .pos-result small,
html[data-theme="dark"] .pos-line small,
html[data-theme="dark"] .login-panel p{color:var(--dark-muted)}
html[data-theme="dark"] .sidebar-nav a{color:#bfcee4}
html[data-theme="dark"] .sidebar-nav a:hover,
html[data-theme="dark"] .sidebar-nav a.active{background:#26375a;color:#dce7ff}
html[data-theme="dark"] .nav-icon{stroke:#a6b7d5}
html[data-theme="dark"] .sidebar-nav a.active .nav-icon{stroke:#a8bbff}
html[data-theme="dark"] .logout-button{color:#b5c5de}
html[data-theme="dark"] .logout-button:hover{background:#332639;color:#ffa8b7}
html[data-theme="dark"] .avatar,
html[data-theme="dark"] .help-spark,
html[data-theme="dark"] .quick-link-icon,
html[data-theme="dark"] .step-marker,
html[data-theme="dark"] .metric-card:before,
html[data-theme="dark"] .empty-state>span{background:#2b3d67;color:#afc3ff}
html[data-theme="dark"] .metric-card:nth-child(2):before{background:#473724}
html[data-theme="dark"] .metric-card:nth-child(3):before{background:#1e493e}
html[data-theme="dark"] .metric-card:nth-child(4):before{background:#3b2d50}
html[data-theme="dark"] .quick-link{color:var(--dark-heading)}
html[data-theme="dark"] .quick-link:hover{border-color:#7089d6;color:#c5d3ff}
html[data-theme="dark"] .theme-toggle{background:#263653;border-color:#405679;color:#dae5ff}
html[data-theme="dark"] .theme-toggle:hover{background:#32476c;border-color:#7895cf;color:#fff}
html[data-theme="dark"] .positive{color:#63d9aa!important}
html[data-theme="dark"] .negative,
html[data-theme="dark"] .finance-cards .cash-out-metric{color:#ff9cac!important}
html[data-theme="dark"] .finance-goal-facts strong{color:#b6c7ff}

/* Campos, botões e tabelas */
html[data-theme="dark"] label,
html[data-theme="dark"] .catalog-filter .filter-checkbox{color:#c5d2e5}
html[data-theme="dark"] .catalog-bulk form>span{color:var(--dark-text)}
html[data-theme="dark"] .catalog-select:hover{background:#2a3c5b}
html[data-theme="dark"] input:not([type=checkbox]):not([type=radio]):not([type=file]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type=file]{background:var(--dark-field);border-color:#3a4c67;color:var(--dark-heading)}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{color:#91a3be}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus{border-color:#91a9f5;box-shadow:0 0 0 3px #435c9b66}
html[data-theme="dark"] input[type=checkbox]{accent-color:#809bff}
html[data-theme="dark"] button.secondary,
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] .finance-tabs a.active,
html[data-theme="dark"] .webhook-toggle{background:#293b5b;border-color:#40577a;color:#bdd0ff}
html[data-theme="dark"] button.secondary:hover,
html[data-theme="dark"] .button.secondary:hover,
html[data-theme="dark"] .finance-tabs a:hover,
html[data-theme="dark"] .webhook-toggle:hover{background:#354c72;border-color:#6982b0;color:#fff}
html[data-theme="dark"] th{background:#202e45;color:#b6c6df;border-color:var(--dark-border)}
html[data-theme="dark"] td{color:#cfdaea;border-color:var(--dark-border)}
html[data-theme="dark"] td:first-child{color:var(--dark-heading)}
html[data-theme="dark"] tbody tr:hover td{background:#21324c}
html[data-theme="dark"] .finance-total-row,
html[data-theme="dark"] .finance-total-row th{background:#26395a}
html[data-theme="dark"] details>summary{color:var(--dark-heading)}
html[data-theme="dark"] details>summary:hover,
html[data-theme="dark"] details[open]>summary{background:#22314a;border-color:var(--dark-border)}
html[data-theme="dark"] .customer-card,
html[data-theme="dark"] .customer-profile-notes,
html[data-theme="dark"] .pos-summary,
html[data-theme="dark"] .pos-discount,
html[data-theme="dark"] .order-total-line,
html[data-theme="dark"] #sale #total,
html[data-theme="dark"] .modal-footer{border-color:var(--dark-border)}
html[data-theme="dark"] code{background:#263650;color:#d9e4f8}
html[data-theme="dark"] .text-button{color:#a8bdff}
html[data-theme="dark"] .text-button:hover{color:#d5e0ff}
html[data-theme="dark"] .ok{background:#173a33;border-color:#2b6a55;color:#a9e8ce}
html[data-theme="dark"] .error{background:#462631;border-color:#8e4259;color:#ffd1d9}

/* Estados, integrações e componentes específicos */
html[data-theme="dark"] .catalog-status{background:#4b3523;color:#ffd09a}
html[data-theme="dark"] .catalog-status.linked,
html[data-theme="dark"] .connection-badge.connected,
html[data-theme="dark"] .step-state.done,
html[data-theme="dark"] .channel-state.connected,
html[data-theme="dark"] .log-status.success,
html[data-theme="dark"] .order-status.is-paid{background:#1e4538;color:#a8edcc}
html[data-theme="dark"] .order-status.is-pending{background:#4b3922;color:#ffd28e}
html[data-theme="dark"] .log-status.pending{background:#263650;color:#c2d0e6}
html[data-theme="dark"] .csv-import-run{border-color:#35445b}
html[data-theme="dark"] .csv-import-heading small{color:#a7b5cc}
html[data-theme="dark"] .order-status.is-cancelled,
html[data-theme="dark"] .log-status.failure{background:#4d2b37;color:#ffc1ce}
html[data-theme="dark"] .connection-badge,
html[data-theme="dark"] .step-state,
html[data-theme="dark"] .channel-state{background:#263650;color:#c2d0e6}
html[data-theme="dark"] .webhook-toggle.is-on{background:#1e4538;border-color:#31775a;color:#a8edcc}
html[data-theme="dark"] .webhook-toggle.is-on:hover{background:#255541;color:#c6ffe2}
html[data-theme="dark"] .store-line{background:#1c3c33;border-color:#2e6954;color:#a8e8cd}
html[data-theme="dark"] .goal-track{background:#30415b}
html[data-theme="dark"] .order-count{background:#30466f;color:#cfdbff}
html[data-theme="dark"] .delete-product-trigger{background:#492935;border-color:#8d4559;color:#ffc1ce}
html[data-theme="dark"] .delete-product-trigger:hover{background:#603342}
html[data-theme="dark"] .delete-product-modal p,
html[data-theme="dark"] .action-confirm-modal p{color:#c4d2e6}
html[data-theme="dark"] .modal-close{background:#2a3b56;color:#d5e2f5}
html[data-theme="dark"] .modal-close:hover{background:#3a4d6b;color:#fff}
html[data-theme="dark"] .image-links-option.is-selected{background:#2b3f69;border-color:#7795e8}
html[data-theme="dark"] #grid-preview{border-color:var(--dark-border)}
html[data-theme="dark"] .image-link-editor summary,
html[data-theme="dark"] .tool-disclosure>summary{color:#afc2ff}
html[data-theme="dark"] .stock-product-results button,
html[data-theme="dark"] .pos-result{background:var(--dark-surface);color:var(--dark-heading)}
html[data-theme="dark"] .stock-product-results button:hover,
html[data-theme="dark"] .stock-product-results button:focus,
html[data-theme="dark"] .pos-result:hover{background:#2a3c5b;color:#fff}
html[data-theme="dark"] .pos-summary>div,
html[data-theme="dark"] .pos-line,
html[data-theme="dark"] .pos-discount{border-color:var(--dark-border)}
html[data-theme="dark"] .page-loading{background:#0b1220e8;color:#c7d7ff}
html[data-theme="dark"] .loading-panel{background:var(--dark-surface);border-color:var(--dark-border);box-shadow:0 15px 45px #0008}
html[data-theme="dark"] .loading-spinner{border-color:#35476a;border-top-color:#a8bcff}

/* PDV: faixa do caixa, busca, carrinho e fechamento. */
html[data-theme="dark"] .pos-cash-bar,
html[data-theme="dark"] .pos-sale-panel,
html[data-theme="dark"] .pos-checkout-panel,
html[data-theme="dark"] .pos-history{background:var(--dark-surface);border-color:var(--dark-border);color:var(--dark-text)}
html[data-theme="dark"] .pos-line,
html[data-theme="dark"] .pos-credit-fields{background:var(--dark-surface-raised);border-color:var(--dark-border)}
html[data-theme="dark"] .pos-photo,
html[data-theme="dark"] .pos-step,
html[data-theme="dark"] .pos-empty-icon{background:#2b3d5d;border-color:#405575;color:#b9cbeb}
html[data-theme="dark"] .pos-cash-expected strong,
html[data-theme="dark"] .pos-clock,
html[data-theme="dark"] .pos-line-description strong,
html[data-theme="dark"] .pos-line-subtotal,
html[data-theme="dark"] .pos-empty strong,
html[data-theme="dark"] .pos-summary strong{color:var(--dark-heading)}
html[data-theme="dark"] .pos-cash-bar p,
html[data-theme="dark"] .pos-clock-wrap>span,
html[data-theme="dark"] .pos-cash-expected span,
html[data-theme="dark"] .pos-section-heading small,
html[data-theme="dark"] .pos-scan-hint,
html[data-theme="dark"] .pos-cart-heading span,
html[data-theme="dark"] .pos-empty,
html[data-theme="dark"] .pos-help,
html[data-theme="dark"] .pos-summary>div,
html[data-theme="dark"] .pos-checkout>div>span,
html[data-theme="dark"] .pos-history>summary span{color:var(--dark-muted)}
html[data-theme="dark"] .pos-cart-heading,
html[data-theme="dark"] .pos-clock-wrap,
html[data-theme="dark"] .pos-discount,
html[data-theme="dark"] .pos-summary{border-color:var(--dark-border)}
html[data-theme="dark"] .pos-discount{background:transparent}
html[data-theme="dark"] .pos-line-remove{color:#b9c8dd}
html[data-theme="dark"] .pos-line-remove:hover{background:#4d2b37;color:#ffc1ce}
html[data-theme="dark"] #pos-search-status{color:#b7c9ff}
