/* TRIFE — compatibilidade visual global entre temas + redução de efeitos caros.
   Carregado pelo bootloader nas telas operacionais. */

:root[data-trife-theme-mode="light"] {
  color-scheme: light !important;
  --gold: #9A6700 !important;
  --warning-strong: #9A6700;
}

:root[data-trife-theme-mode="dark"] {
  color-scheme: dark !important;
}

html, body {
  background-color: var(--bg-body) !important;
  color: var(--text-main) !important;
}

body.trife-saas-layout {
  background-color: var(--bg-body) !important;
  color: var(--text-main) !important;
}

/* Shell global do app Web */
:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-topbar,
:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-saas-sidebar,
:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-app-bottom,
:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-app-fab-menu {
  background: color-mix(in srgb, var(--bg-surface) 96%, transparent) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .10) !important;
}

:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-nav-btn,
:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-menu-toggle,
:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-app-nav-item,
:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-app-fab-link {
  color: var(--text-main) !important;
}

:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-nav-btn:hover,
:root[data-trife-theme-mode="light"] body.trife-saas-layout .trife-app-fab-link:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-surface)) !important;
}

/* Dashboard */
:root[data-trife-theme-mode="light"] .android-card,
:root[data-trife-theme-mode="light"] .modal-card,
:root[data-trife-theme-mode="light"] .dashboard-toolbar,
:root[data-trife-theme-mode="light"] .category-filter-sheet,
:root[data-trife-theme-mode="light"] .dashboard-empty-state {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 8px 26px rgba(15, 23, 42, .08) !important;
}

:root[data-trife-theme-mode="light"] .square-btn,
:root[data-trife-theme-mode="light"] .btn-play-pause,
:root[data-trife-theme-mode="light"] .bonde-open-box,
:root[data-trife-theme-mode="light"] .star-badge,
:root[data-trife-theme-mode="light"] .category-option,
:root[data-trife-theme-mode="light"] .category-filter-button,
:root[data-trife-theme-mode="light"] .toolbar-app-btn,
:root[data-trife-theme-mode="light"] .payment-method-choice,
:root[data-trife-theme-mode="light"] .payment-decision-summary span {
  background: var(--surface-2) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

:root[data-trife-theme-mode="light"] .sugestoes-drop,
:root[data-trife-theme-mode="light"] .payment-decision-box {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 18px 52px rgba(15, 23, 42, .15) !important;
}

:root[data-trife-theme-mode="light"] .payment-decision-box h3,
:root[data-trife-theme-mode="light"] .payment-decision-summary strong {
  color: var(--text-main) !important;
}

:root[data-trife-theme-mode="light"] .payment-decision-overlay,
:root[data-trife-theme-mode="light"] .modal-overlay,
:root[data-trife-theme-mode="light"] .category-filter-overlay {
  background: rgba(15, 23, 42, .32) !important;
}

:root[data-trife-theme-mode="light"] .autocomplete-wrap input,
:root[data-trife-theme-mode="light"] .custom-input {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

/* Nova Locação: os estilos antigos eram fixos em dark. Agora espelham o tema real. */
:root[data-trife-theme-mode="light"] {
  --ride-bg: var(--bg-body) !important;
  --ride-surface: var(--bg-surface) !important;
  --ride-surface-strong: var(--surface-2) !important;
  --ride-border: var(--border-color) !important;
  --ride-text: var(--text-main) !important;
  --ride-muted: var(--text-muted) !important;
  --ride-primary: var(--primary) !important;
}

:root[data-trife-theme-mode="light"] body.addtime-page,
:root[data-trife-theme-mode="light"] body.addtime-page.trife-saas-layout,
:root[data-trife-theme-mode="light"] body.addtime-page.trife-saas-layout.trife-sidebar-collapsed {
  background: var(--ride-bg) !important;
  color: var(--ride-text) !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .trife-app-bottom {
  color-scheme: light !important;
  background: color-mix(in srgb, var(--ride-surface) 97%, transparent) !important;
  border-color: var(--ride-border) !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .action-card,
:root[data-trife-theme-mode="light"] .addtime-page .switch-row,
:root[data-trife-theme-mode="light"] .addtime-page .individual-time-config,
:root[data-trife-theme-mode="light"] .addtime-page .client-panel,
:root[data-trife-theme-mode="light"] .addtime-page .app-dialog-card,
:root[data-trife-theme-mode="light"] .addtime-page .quick-client-sheet,
:root[data-trife-theme-mode="light"] .addtime-page .vehicle-card,
:root[data-trife-theme-mode="light"] .addtime-page .queue-dropdown {
  background: var(--ride-surface) !important;
  color: var(--ride-text) !important;
  border-color: var(--ride-border) !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08) !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .action-card.primary {
  background: linear-gradient(145deg, #64748B, #475569) !important;
  color: #FFFFFF !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .action-card.add-person {
  background: linear-gradient(145deg, color-mix(in srgb, var(--ride-primary) 82%, #fff), var(--ride-primary)) !important;
  color: #fff !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .action-card.vehicles {
  background: color-mix(in srgb, var(--ride-primary) 8%, var(--ride-surface)) !important;
  color: var(--ride-primary) !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .outlined-field,
:root[data-trife-theme-mode="light"] .addtime-page .passenger-row .field,
:root[data-trife-theme-mode="light"] .addtime-page .individual-select select,
:root[data-trife-theme-mode="light"] .addtime-page .custom-plan-select,
:root[data-trife-theme-mode="light"] .addtime-page .custom-time-dropdown {
  background: var(--ride-surface) !important;
  color: var(--ride-text) !important;
  border-color: var(--ride-border) !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .outlined-field .field {
  color-scheme: light !important;
  color: var(--ride-text) !important;
  -webkit-text-fill-color: var(--ride-text) !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .outlined-field select.field,
:root[data-trife-theme-mode="light"] .addtime-page .outlined-field select.field option {
  background-color: var(--ride-surface) !important;
  color: var(--ride-text) !important;
  -webkit-text-fill-color: var(--ride-text) !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .form-label {
  background: var(--ride-bg) !important;
  color: var(--ride-muted) !important;
}

:root[data-trife-theme-mode="light"] .addtime-page .switch {
  background: #CBD5E1 !important;
}
:root[data-trife-theme-mode="light"] .addtime-page .switch::after { background: #FFFFFF !important; }
:root[data-trife-theme-mode="light"] .addtime-page .switch.on { background: color-mix(in srgb, var(--ride-primary) 34%, #DCEFF8) !important; }
:root[data-trife-theme-mode="light"] .addtime-page .switch.on::after { background: var(--ride-primary) !important; }

/* Componentes comuns de páginas antigas que ainda tinham preto fixo. */
:root[data-trife-theme-mode="light"] body.trife-saas-layout :is(.panel,.card,.box,.sheet,.dialog-card,.content-card):not(.no-theme):not([class*="status-"]) {
  border-color: color-mix(in srgb, var(--border-color) 80%, transparent);
}

/* Menos GPU/blur em celulares: ganha fluidez sem alterar funcionalidade. */
@media (max-width: 900px), (prefers-reduced-motion: reduce) {
  .bg-blob { display: none !important; }
  body.trife-saas-layout :is(.trife-topbar,.trife-app-bottom,.trife-saas-sidebar,.trife-app-fab-menu),
  .modal-overlay,
  .payment-decision-overlay,
  .category-filter-overlay {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .android-card,
  .addtime-page .action-card,
  .addtime-page .switch-row {
    transition-duration: .12s !important;
  }
}

/* Transições de navegação nativas quando o navegador suporta. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 120ms; }

/* ==========================================================
   MINHA CONTA — páginas antigas tinham superfícies dark fixas.
   ========================================================== */
:root[data-trife-theme-mode="light"] body.account-summary-page {
  background:
    radial-gradient(circle at 50% -12%, color-mix(in srgb, var(--primary) 8%, transparent), transparent 27rem),
    var(--bg-body) !important;
  color: var(--text-main) !important;
}

:root[data-trife-theme-mode="light"] body.account-summary-page .group,
:root[data-trife-theme-mode="light"] body.account-summary-page .plan-card {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08) !important;
}

:root[data-trife-theme-mode="light"] body.account-summary-page .plan-card {
  background: linear-gradient(145deg,
    color-mix(in srgb, #16A34A 5%, var(--bg-surface)),
    var(--bg-surface)) !important;
}

:root[data-trife-theme-mode="light"] body.account-summary-page .plan-fact,
:root[data-trife-theme-mode="light"] body.account-summary-page .mini-btn.secondary {
  background: var(--surface-2) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

:root[data-trife-theme-mode="light"] body.account-summary-page .plan-fact b,
:root[data-trife-theme-mode="light"] body.account-summary-page .row,
:root[data-trife-theme-mode="light"] body.account-summary-page .identity h1 {
  color: var(--text-main) !important;
}

:root[data-trife-theme-mode="light"] body.account-summary-page .plan-fact small,
:root[data-trife-theme-mode="light"] body.account-summary-page .plan-detail,
:root[data-trife-theme-mode="light"] body.account-summary-page .row-copy small,
:root[data-trife-theme-mode="light"] body.account-summary-page .identity p,
:root[data-trife-theme-mode="light"] body.account-summary-page .section-title,
:root[data-trife-theme-mode="light"] body.account-summary-page .foot,
:root[data-trife-theme-mode="light"] body.account-summary-page .chev {
  color: var(--text-muted) !important;
}

:root[data-trife-theme-mode="light"] body.account-summary-page .row:active {
  background: color-mix(in srgb, var(--primary) 7%, var(--bg-surface)) !important;
}

:root[data-trife-theme-mode="light"] body.account-summary-page .loading {
  background: var(--bg-body) !important;
  color: var(--text-main) !important;
}

:root[data-trife-theme-mode="light"] body.account-summary-page .spinner {
  border-color: color-mix(in srgb, var(--text-main) 14%, transparent) !important;
  border-top-color: var(--primary) !important;
}

/* ==========================================================
   MINHA FROTA / MEUS VEÍCULOS — versão light realmente clara.
   ========================================================== */
:root[data-trife-theme-mode="light"] body.fleet-page {
  background:
    radial-gradient(circle at 95% 0, color-mix(in srgb, var(--primary) 8%, transparent) 0, transparent 27%),
    var(--bg-body) !important;
  color: var(--text-main) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .top,
:root[data-trife-theme-mode="light"] body.fleet-page .toolbar {
  background: color-mix(in srgb, var(--bg-body) 96%, transparent) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  box-shadow: none !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .top-btn,
:root[data-trife-theme-mode="light"] body.fleet-page .stat,
:root[data-trife-theme-mode="light"] body.fleet-page .group,
:root[data-trife-theme-mode="light"] body.fleet-page .group-head,
:root[data-trife-theme-mode="light"] body.fleet-page .vehicle,
:root[data-trife-theme-mode="light"] body.fleet-page .photo,
:root[data-trife-theme-mode="light"] body.fleet-page .gate,
:root[data-trife-theme-mode="light"] body.fleet-page .modal,
:root[data-trife-theme-mode="light"] body.fleet-page .action,
:root[data-trife-theme-mode="light"] body.fleet-page .category-chip,
:root[data-trife-theme-mode="light"] body.fleet-page .op-card,
:root[data-trife-theme-mode="light"] body.fleet-page .cancel,
:root[data-trife-theme-mode="light"] body.fleet-page .save-more,
:root[data-trife-theme-mode="light"] body.fleet-page .toast {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .07) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .vehicle {
  background: linear-gradient(145deg, var(--bg-surface), var(--surface-2)) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .group-head,
:root[data-trife-theme-mode="light"] body.fleet-page .stat,
:root[data-trife-theme-mode="light"] body.fleet-page .category-chip,
:root[data-trife-theme-mode="light"] body.fleet-page .op-card,
:root[data-trife-theme-mode="light"] body.fleet-page .action,
:root[data-trife-theme-mode="light"] body.fleet-page .cancel,
:root[data-trife-theme-mode="light"] body.fleet-page .save-more {
  background: var(--surface-2) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .transfer-btn {
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-surface)) !important;
  color: var(--primary) !important;
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border-color)) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .transfer-btn.import {
  background: color-mix(in srgb, #7C3AED 7%, var(--bg-surface)) !important;
  color: #6D28D9 !important;
  border-color: color-mix(in srgb, #7C3AED 30%, var(--border-color)) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .search,
:root[data-trife-theme-mode="light"] body.fleet-page .input,
:root[data-trife-theme-mode="light"] body.fleet-page .select,
:root[data-trife-theme-mode="light"] body.fleet-page .category-add-btn {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  color-scheme: light !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .input::placeholder,
:root[data-trife-theme-mode="light"] body.fleet-page .search::placeholder {
  color: var(--text-muted) !important;
  opacity: .78;
}

:root[data-trife-theme-mode="light"] body.fleet-page .field label,
:root[data-trife-theme-mode="light"] body.fleet-page .empty b,
:root[data-trife-theme-mode="light"] body.fleet-page .name,
:root[data-trife-theme-mode="light"] body.fleet-page .brand,
:root[data-trife-theme-mode="light"] body.fleet-page .hero h1 {
  color: var(--text-main) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .hero p,
:root[data-trife-theme-mode="light"] body.fleet-page .meta,
:root[data-trife-theme-mode="light"] body.fleet-page .transfer-note,
:root[data-trife-theme-mode="light"] body.fleet-page .group-head small,
:root[data-trife-theme-mode="light"] body.fleet-page .stat span,
:root[data-trife-theme-mode="light"] body.fleet-page .modal > p,
:root[data-trife-theme-mode="light"] body.fleet-page .op-card small,
:root[data-trife-theme-mode="light"] body.fleet-page .gate p,
:root[data-trife-theme-mode="light"] body.fleet-page .empty {
  color: var(--text-muted) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .overlay {
  background: rgba(15, 23, 42, .34) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .op-card.active {
  background: color-mix(in srgb, var(--primary) 10%, var(--bg-surface)) !important;
  color: var(--primary) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .op-card[data-operation="BONDE"].active {
  background: color-mix(in srgb, var(--gold) 10%, var(--bg-surface)) !important;
  color: var(--gold) !important;
  border-color: var(--gold) !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .action.work,
:root[data-trife-theme-mode="light"] body.fleet-page .busy {
  color: #9A6700 !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .action.delete,
:root[data-trife-theme-mode="light"] body.fleet-page .maint {
  color: #BE123C !important;
}

:root[data-trife-theme-mode="light"] body.fleet-page .free,
:root[data-trife-theme-mode="light"] body.fleet-page .license {
  color: #15803D !important;
}

/* O dourado do tema claro precisa de contraste real sobre branco. */
:root[data-trife-theme-mode="light"] .gold,
:root[data-trife-theme-mode="light"] [data-tone="gold"],
:root[data-trife-theme-mode="light"] .text-gold,
:root[data-trife-theme-mode="light"] .gold-text {
  color: #8A5B00 !important;
}

/* Transições mais leves em celulares; não animar propriedades caras. */
@media (max-width: 760px) {
  body.trife-saas-layout *,
  body.addtime-page *,
  body.account-summary-page *,
  body.fleet-page * {
    transition-property: color, background-color, border-color, opacity, transform !important;
    transition-duration: .12s !important;
  }
}

/* ========================================================================
   TRIFE LIGHT SYSTEM V4 — superfícies claras consistentes nas telas operacionais
   ======================================================================== */
:root[data-trife-theme-mode="light"] {
  --trife-light-bg: #F6F8FB;
  --trife-light-surface: #FFFFFF;
  --trife-light-surface-2: #F1F5F9;
  --trife-light-surface-3: #E8EEF5;
  --trife-light-text: #0F172A;
  --trife-light-muted: #64748B;
  --trife-light-border: #CBD5E1;
  --trife-light-blue: #0369A1;
  --trife-light-gold: #8A5B00;
  --trife-light-shadow: 0 10px 28px rgba(15, 23, 42, .08);
}

/* Cabeçalho da Nova Locação precisa respirar em relação aos botões Cliente/Veículos. */
:root[data-trife-theme-mode="light"][data-trife-page="addtime"] .addtime-page .topbar,
:root[data-trife-theme-mode="dark"][data-trife-page="addtime"] .addtime-page .topbar {
  margin-bottom: 28px !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="addtime"] .addtime-page .rental-actions,
:root[data-trife-theme-mode="dark"][data-trife-page="addtime"] .addtime-page .rental-actions {
  margin-top: 2px !important;
}

/* Seleção de veículos — no Light os cards deixam de ser blocos pretos. */
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] body {
  --bg: var(--trife-light-bg) !important;
  --surface: var(--trife-light-surface) !important;
  --surface-2: var(--trife-light-surface-2) !important;
  --text: var(--trife-light-text) !important;
  --muted: var(--trife-light-muted) !important;
  --border: var(--trife-light-border) !important;
  background: radial-gradient(circle at 95% -10%, rgba(14,165,233,.07), transparent 27rem), var(--trife-light-bg) !important;
  color: var(--trife-light-text) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] :is(.topbar,.vehicle,.search input,.toast) {
  background: var(--trife-light-surface) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
  box-shadow: var(--trife-light-shadow) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .topbar {
  background: rgba(246,248,251,.97) !important;
  box-shadow: none !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .back,
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .vehicle-copy strong,
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .group-head { color: var(--trife-light-text) !important; }
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .vehicle-copy small,
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .topcopy span,
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .selection-tip { color: var(--trife-light-muted) !important; }
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .vehicle.selected {
  background: color-mix(in srgb, var(--vehicle) 9%, var(--trife-light-surface)) !important;
  color: var(--trife-light-text) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .selected .vehicle-copy small { color: var(--trife-light-muted) !important; }
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .check { border-color: #94A3B8 !important; }
:root[data-trife-theme-mode="light"][data-trife-page="addtime-veiculos"] .loading {
  background: var(--trife-light-bg) !important;
  color: var(--trife-light-blue) !important;
}

/* HISTÓRICO — cabeçalho azul preservado, conteúdo realmente Light. */
:root[data-trife-theme-mode="light"][data-trife-page="historico"] body {
  --bg: var(--trife-light-bg) !important;
  --surface: var(--trife-light-surface) !important;
  --surface2: var(--trife-light-surface-2) !important;
  --line: var(--trife-light-border) !important;
  --text: var(--trife-light-text) !important;
  --muted: var(--trife-light-muted) !important;
  background: var(--trife-light-bg) !important;
  color: var(--trife-light-text) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="historico"] :is(.calendar,.hist-card,.method-list,.balance-metric,.balance-unpaid,.detail,.font-scale-panel,.unpaid-summary,.unpaid-list,.filter-select) {
  background: var(--trife-light-surface) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
  box-shadow: var(--trife-light-shadow) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .calendar {
  background: rgba(255,255,255,.97) !important;
  backdrop-filter: none !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .day {
  background: var(--trife-light-surface-2) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .day.selected { background: var(--primary) !important; color:#fff !important; }
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .day.selected small { color:#E0F2FE !important; }
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .payment,
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .payment-ledger > span {
  background: var(--trife-light-surface-2) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .payment-ledger i,
:root[data-trife-theme-mode="light"][data-trife-page="historico"] :is(.hist-name,.client strong,.method-row span,.method-row strong,.balance-metric strong) {
  color: var(--trife-light-text) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .money strong { color:#15803D !important; }
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .pager-btn,
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .month-button {
  background: color-mix(in srgb, var(--primary) 7%, #fff) !important;
  color: var(--trife-light-blue) !important;
  border-color: color-mix(in srgb, var(--primary) 28%, var(--trife-light-border)) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="historico"] .loading { background:var(--trife-light-bg)!important;color:var(--trife-light-muted)!important; }

/* Relatórios: fiscal, gestão e gráfico detalhado usam o mesmo sistema de superfícies. */
:root[data-trife-theme-mode="light"][data-trife-page="relatorio-fiscal"] body,
:root[data-trife-theme-mode="light"][data-trife-page="gestao-historico"] body,
:root[data-trife-theme-mode="light"][data-trife-page="grafico-detalhado"] body {
  --bg: var(--trife-light-bg) !important;
  --surface: var(--trife-light-surface) !important;
  --surface2: var(--trife-light-surface-2) !important;
  --line: var(--trife-light-border) !important;
  --text: var(--trife-light-text) !important;
  --muted: var(--trife-light-muted) !important;
  background: radial-gradient(circle at 90% -10%, rgba(14,165,233,.06), transparent 27rem), var(--trife-light-bg) !important;
  color: var(--trife-light-text) !important;
}
:root[data-trife-theme-mode="light"]:is([data-trife-page="relatorio-fiscal"],[data-trife-page="gestao-historico"],[data-trife-page="grafico-detalhado"]) :is(.card,.methods,.chart-card,.quick,.visual,.daily,.insight) {
  background: var(--trife-light-surface) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
  box-shadow: var(--trife-light-shadow) !important;
}
:root[data-trife-theme-mode="light"]:is([data-trife-page="relatorio-fiscal"],[data-trife-page="gestao-historico"],[data-trife-page="grafico-detalhado"]) :is(.icon,.period) {
  background: var(--trife-light-surface) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="relatorio-fiscal"] .period.active { background:var(--primary)!important;color:#fff!important;border-color:var(--primary)!important; }
:root[data-trife-theme-mode="light"][data-trife-page="gestao-historico"] .donut:after { background:var(--trife-light-surface)!important; }
:root[data-trife-theme-mode="light"][data-trife-page="gestao-historico"] .method span,
:root[data-trife-theme-mode="light"][data-trife-page="grafico-detalhado"] :is(.chart-title,.legend,.chart-help),
:root[data-trife-theme-mode="light"][data-trife-page="relatorio-fiscal"] .method span { color:var(--trife-light-text)!important; }
:root[data-trife-theme-mode="light"]:is([data-trife-page="relatorio-fiscal"],[data-trife-page="gestao-historico"],[data-trife-page="grafico-detalhado"]) .loading { background:var(--trife-light-bg)!important;color:var(--trife-light-muted)!important; }

/* FILA */
:root[data-trife-theme-mode="light"][data-trife-page="fila"] body {
  background: var(--trife-light-bg) !important;
  color: var(--trife-light-text) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="fila"] :is(.topbar,.home-card,.wizard-shell,.list-shell,.queue-list,.dialog,.time-manager-list,.field,.switch-row,.toast) {
  background: var(--trife-light-surface) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
  box-shadow: var(--trife-light-shadow) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="fila"] :is(.lead,.home-card p,.field-wrap label,.time-manager-status) { color:var(--trife-light-muted)!important; }
:root[data-trife-theme-mode="light"][data-trife-page="fila"] .topbar { box-shadow:none!important; }

/* Clientes — ações ganham respiro; FAB de comunicação não encosta no conteúdo. */
:root[data-trife-theme-mode="light"][data-trife-page="clientes"] .client-card {
  background: var(--trife-light-surface) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
  box-shadow: 0 8px 24px rgba(15,23,42,.06) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="clientes"] :is(.name,.modal-title,.search-input,.modal-input,.more-options-btn) { color:var(--trife-light-text)!important; }
:root[data-trife-theme-mode="light"][data-trife-page="clientes"] :is(.search-input,.modal-input,.modal-card,.toolbar,.chip-btn,.pager-btn) {
  background: var(--trife-light-surface) !important;
  border-color: var(--trife-light-border) !important;
}
:root[data-trife-page="clientes"] .card-actions { margin-top: 14px !important; padding-top: 14px !important; }
:root[data-trife-page="clientes"] #trife-admin-fab { bottom: calc(96px + env(safe-area-inset-bottom)) !important; }

/* Fallback para telas operacionais antigas: remove apenas superfícies pretas, sem mexer em botões coloridos. */
:root[data-trife-theme-mode="light"]:is(
  [data-trife-page="dashboard"],[data-trife-page="addveiculos"],[data-trife-page="adicionarmassa"],
  [data-trife-page="tempopersonalizado"],[data-trife-page="recreacao"],[data-trife-page="bonde"],
  [data-trife-page="nao-pagos"],[data-trife-page="recentes"],[data-trife-page="historicodafila"],
  [data-trife-page="historicocorridas"],[data-trife-page="meuhistoricodecorridas"],[data-trife-page="cliente"],
  [data-trife-page="qrcodefidelidade"],[data-trife-page="pintura"],[data-trife-page="historicopintura"],[data-trife-page="rastreador"]
) body {
  background-color: var(--trife-light-bg) !important;
  color: var(--trife-light-text) !important;
}
:root[data-trife-theme-mode="light"]:is(
  [data-trife-page="dashboard"],[data-trife-page="addveiculos"],[data-trife-page="adicionarmassa"],
  [data-trife-page="tempopersonalizado"],[data-trife-page="recreacao"],[data-trife-page="bonde"],
  [data-trife-page="nao-pagos"],[data-trife-page="recentes"],[data-trife-page="historicodafila"],
  [data-trife-page="historicocorridas"],[data-trife-page="meuhistoricodecorridas"],[data-trife-page="cliente"],
  [data-trife-page="qrcodefidelidade"],[data-trife-page="pintura"],[data-trife-page="historicopintura"],[data-trife-page="rastreador"]
) :is(.card,.panel,.box,.sheet,.modal-card,.content-card,.list-card,.item-card,.queue-card):not(.danger):not(.success):not(.primary) {
  background-color: var(--trife-light-surface) !important;
  color: var(--trife-light-text) !important;
  border-color: var(--trife-light-border) !important;
}

@media (max-width: 760px) {
  :root[data-trife-page="addtime"] .addtime-page .topbar { margin-bottom: 24px !important; }
}

/* Tokens legados que não usam os nomes globais. */
:root[data-trife-theme-mode="light"][data-trife-page="clientes"] {
  --card-bg: #FFFFFF !important;
  --text-white: #0F172A !important;
  --text-gray: #64748B !important;
  --selection: #FFF8DC !important;
  --card-border: #CBD5E1 !important;
  --gold: #8A5B00 !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="clientes"] :is(.app-bar,.toolbar) {
  background: rgba(255,255,255,.97) !important;
  color: #0F172A !important;
  border-color: #CBD5E1 !important;
  box-shadow: 0 6px 20px rgba(15,23,42,.07) !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="clientes"] .avatar {
  background: linear-gradient(135deg,#E2E8F0,#CBD5E1) !important;
  color:#0F172A !important;
  border-color:#FFFFFF !important;
}

/* Command Center de veículos: no light mantém identidade/status sem fundo cyber preto. */
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] {
  --bg-deep: #F6F8FB !important;
  --bg-glass: rgba(255,255,255,.94) !important;
  --card-glass: #FFFFFF !important;
  --card-border: #CBD5E1 !important;
  --text-main: #0F172A !important;
  --text-muted: #64748B !important;
  --neon-blue: #0369A1 !important;
  --neon-green: #15803D !important;
  --neon-amber: #A16207 !important;
  --neon-red: #BE123C !important;
  --neon-gray: #64748B !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] body {
  background: radial-gradient(circle at 15% 15%,rgba(14,165,233,.055),transparent 25rem), #F6F8FB !important;
  color:#0F172A !important;
}
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] .hud-nav {
  background:rgba(255,255,255,.97)!important;
  border-color:#CBD5E1!important;
  box-shadow:0 6px 22px rgba(15,23,42,.08)!important;
  backdrop-filter:none!important;
}
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] .unit-card,
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] .timer-section,
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] .modal-panel,
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] .section-badge {
  background:#FFFFFF!important;
  color:#0F172A!important;
  border-color:#CBD5E1!important;
  box-shadow:0 8px 24px rgba(15,23,42,.07)!important;
  backdrop-filter:none!important;
}
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] :is(.unit-id,.time-display,.brand-text) { color:#0F172A!important; }
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] .client-detail { color:#64748B!important; }
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] .status-pill { background:color-mix(in srgb,var(--status-c) 7%,#fff)!important; }
:root[data-trife-theme-mode="light"][data-trife-page="veiculos"] .modal-backdrop { background:rgba(15,23,42,.30)!important;backdrop-filter:none!important; }

/* =====================================================================
   LIGHT V5 — diálogos operacionais que ainda possuíam Dark hardcoded
   ===================================================================== */
:root[data-trife-theme-mode="light"] .addtime-page .payment-confirm,
:root[data-trife-theme-mode="light"] .addtime-page .app-dialog,
:root[data-trife-theme-mode="light"] .finalized-modal {
  background: rgba(15,23,42,.28) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}
:root[data-trife-theme-mode="light"] .addtime-page .payment-sheet,
:root[data-trife-theme-mode="light"] .addtime-page .app-dialog-card,
:root[data-trife-theme-mode="light"] .addtime-page .quick-client-card {
  background: #fff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 24px 70px rgba(15,23,42,.17) !important;
}
:root[data-trife-theme-mode="light"] .addtime-page .payment-sheet h3,
:root[data-trife-theme-mode="light"] .addtime-page .app-dialog-card h3,
:root[data-trife-theme-mode="light"] .addtime-page .payment-detail,
:root[data-trife-theme-mode="light"] .addtime-page .app-dialog-card strong { color:#0f172a !important; }
:root[data-trife-theme-mode="light"] .addtime-page .payment-sheet p,
:root[data-trife-theme-mode="light"] .addtime-page .app-dialog-card > p { color:#64748b !important; }
:root[data-trife-theme-mode="light"] .addtime-page .payment-detail { background:#f1f5f9 !important;border-color:#dbe4ee !important; }
:root[data-trife-theme-mode="light"] .addtime-page .payment-choice.cancel { background:#fff !important;color:#334155 !important;border-color:#94a3b8 !important; }
:root[data-trife-theme-mode="light"] .addtime-page .quick-client-head { background:rgba(255,255,255,.96) !important;border-color:#dbe4ee !important; }

:root[data-trife-theme-mode="light"] .finished-dialog {
  color:#0f172a !important;
  background:radial-gradient(circle at 8% 0,rgba(239,68,68,.06),transparent 32%),#fff !important;
  border-color:rgba(220,38,38,.22) !important;
  box-shadow:0 30px 90px rgba(15,23,42,.2) !important;
}
:root[data-trife-theme-mode="light"] .finished-dialog-header,
:root[data-trife-theme-mode="light"] .finished-quick-summary,
:root[data-trife-theme-mode="light"] .finished-dialog-footer { border-color:#e2e8f0 !important; }
:root[data-trife-theme-mode="light"] .finished-dialog-heading h2,
:root[data-trife-theme-mode="light"] .finished-quick-summary strong,
:root[data-trife-theme-mode="light"] .finished-vehicle-identity h3,
:root[data-trife-theme-mode="light"] .finished-value-grid strong,
:root[data-trife-theme-mode="light"] .finished-empty-state strong { color:#0f172a !important; }
:root[data-trife-theme-mode="light"] .finished-dialog-heading p,
:root[data-trife-theme-mode="light"] .finished-vehicle-identity p,
:root[data-trife-theme-mode="light"] .finished-time-compact span,
:root[data-trife-theme-mode="light"] .finished-value-grid span,
:root[data-trife-theme-mode="light"] .finished-readonly,
:root[data-trife-theme-mode="light"] .finished-empty-state { color:#64748b !important; }
:root[data-trife-theme-mode="light"] .finished-dialog-close { background:#f8fafc !important;color:#334155 !important;border-color:#cbd5e1 !important; }
:root[data-trife-theme-mode="light"] .finished-quick-summary { background:#f8fafc !important;color:#475569 !important; }
:root[data-trife-theme-mode="light"] .finished-list { background:#f8fafc !important; }
:root[data-trife-theme-mode="light"] .finished-vehicle-card { background:#fff !important;border-color:#fecaca !important;box-shadow:0 10px 26px rgba(15,23,42,.07) !important; }
:root[data-trife-theme-mode="light"] .finished-value-grid > div,
:root[data-trife-theme-mode="light"] .finished-card-meta span,
:root[data-trife-theme-mode="light"] .finished-readonly { background:#f8fafc !important;border-color:#e2e8f0 !important; }
:root[data-trife-theme-mode="light"] .finished-time-panel { background:#fff1f2 !important;border-color:#fecdd3 !important; }
:root[data-trife-theme-mode="light"] .finished-time-panel strong { color:#991b1b !important; }
:root[data-trife-theme-mode="light"] .finished-time-panel span { color:#be123c !important; }
:root[data-trife-theme-mode="light"] .finished-time-panel small { color:#9f1239 !important; }
:root[data-trife-theme-mode="light"] .finished-dialog-footer { background:#fff !important;box-shadow:0 -10px 24px rgba(15,23,42,.06) !important; }
:root[data-trife-theme-mode="light"] .finished-footer-button.is-neutral { color:#334155 !important;background:#f8fafc !important;border-color:#cbd5e1 !important; }
:root[data-trife-theme-mode="light"] .finished-footer-button.is-success { color:#166534 !important;background:#f0fdf4 !important;border-color:#22c55e !important; }
:root[data-trife-theme-mode="light"] .finished-footer-button.is-danger { color:#b91c1c !important;background:#fff1f2 !important;border-color:#fda4af !important; }

/* Modal de seleção/filtro: nunca deixa card escuro no modo claro. */
:root[data-trife-theme-mode="light"] :is(.category-filter-sheet,.category-sheet,.modal-card,.sheet,.dialog-card):not(.no-theme) {
  background:#fff !important;color:#0f172a !important;border-color:#cbd5e1 !important;
}
