/* DriveOS unified dark/lime polish v1
   Shared visual tokens and mobile legibility; presentation only. */
:root {
  --driveos-lime: var(--driveos-color-accent);
  --driveos-bg: var(--driveos-color-bg);
  --driveos-surface: var(--driveos-color-surface);
  --driveos-surface-2: var(--driveos-color-surface-raised);
  --driveos-border: var(--driveos-color-border);
  --driveos-text: var(--driveos-color-text);
  --driveos-muted: var(--driveos-color-muted);
}
html[data-driveos-theme="dark"] {
  --primary: var(--driveos-lime);
  --primary-dark: var(--driveos-color-accent-hover);
  --bg: var(--driveos-bg);
  --surface: var(--driveos-surface);
  --surface-2: var(--driveos-surface-2);
  --text: var(--driveos-text);
  --muted: var(--driveos-muted);
  --line: var(--driveos-border);
}
html[data-driveos-theme="dark"] :is(.btn.primary,.driveos-theme-control button[aria-pressed="true"]) {
  background: var(--driveos-lime) !important;
  border-color: var(--driveos-lime) !important;
  color: #11180d !important;
}
html[data-driveos-theme="dark"] :is(.btn.primary,.tiny-btn,.driveos-filter-toggle):focus-visible,
body.driveos-admin-mobile :is(button,input,select,textarea,a):focus-visible,
body.driveos-driver-lime :is(button,input,select,textarea,a):focus-visible {
  outline: 2px solid var(--driveos-lime) !important;
  outline-offset: 2px;
}
html[data-driveos-theme="dark"] .page-header h1,
html[data-driveos-theme="dark"] .card-header h2,
html[data-driveos-theme="dark"] .card h2,
html[data-driveos-theme="dark"] .card h3 {
  color: var(--driveos-text) !important;
}
html[data-driveos-theme="dark"] :is(.page-header p,.card-header p,.muted,.hint) {
  color: var(--driveos-muted) !important;
}
html[data-driveos-theme="dark"] .driveos-filter-bar {
  margin: 8px 0;
}
html[data-driveos-theme="dark"] .driveos-filter-toggle {
  min-height: 42px;
  border: 1px solid var(--driveos-border) !important;
  border-radius: 12px !important;
  background: var(--driveos-surface) !important;
  color: var(--driveos-text) !important;
}
html[data-driveos-theme="dark"] .driveos-filter-count {
  background: var(--driveos-lime) !important;
  color: #11180d !important;
  border-radius: 99px;
  font-weight: 800;
}
html[data-driveos-theme="dark"] .driveos-filter-panel {
  border-color: var(--driveos-border) !important;
}
html[data-driveos-theme="dark"] :is(.saved-views,.driveos-saved-views,.driveos-filter-saved-views) :is(select,button) {
  min-height: 42px;
  border-radius: 11px;
}
html[data-driveos-theme="dark"] .topbar {
  background: #101612 !important;
  color: var(--driveos-text) !important;
  border-color: var(--driveos-border) !important;
}
html[data-driveos-theme="dark"] .topbar :is(select,button) {
  background: var(--driveos-surface-2) !important;
  border-color: var(--driveos-border) !important;
  color: var(--driveos-text) !important;
}

/* Legacy account modules receive a unified dark palette too. */
html[data-driveos-theme="dark"] #page-accounts :is(.accounts-receivable-card,.accounts-payable-card,.accounts-financial-card,.driveos-accounts-pro-toolbar,.driveos-accounts-pro-table-wrap) {
  background: var(--driveos-surface) !important;
  color: var(--driveos-text) !important;
  border-color: var(--driveos-border) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-kpi {
  background: var(--driveos-surface-2) !important;
  border-color: var(--driveos-border) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-kpi :is(span,small) {
  color: var(--driveos-muted) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-kpi strong,
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-section-title strong {
  color: var(--driveos-text) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-table :is(th,td) {
  border-color: var(--driveos-border) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-table th {
  background: var(--driveos-color-surface-inset) !important;
  color: var(--driveos-color-muted-strong) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-table td {
  background: var(--driveos-surface) !important;
  color: var(--driveos-text) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-table tr.is-overdue td {
  background: #291819 !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-toolbar :is(input,select) {
  background: var(--driveos-color-surface-inset) !important;
  color: var(--driveos-text) !important;
  border-color: var(--driveos-border) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-pro-toolbar .tiny-btn {
  background: var(--driveos-surface-2) !important;
  color: var(--driveos-text) !important;
  border-color: var(--driveos-border) !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-badge.good {
  background: #20351f !important;
  color: #c6f4a3 !important;
  border-color: #45633a !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-badge.bad {
  background: var(--driveos-color-negative-surface) !important;
  color: #ffb0b0 !important;
  border-color: #744147 !important;
}
html[data-driveos-theme="dark"] #page-accounts .driveos-accounts-badge.warn {
  background: var(--driveos-color-warning-surface) !important;
  color: var(--driveos-color-warning) !important;
  border-color: #6b592e !important;
}

/* Admin and driver mobile shells share the black/lime visual language.
   Navigation and role-specific content stay separate. */
body.driveos-admin-mobile,
body.driveos-driver-lime {
  background: var(--driveos-bg) !important;
  color: var(--driveos-text) !important;
}
body.driveos-admin-mobile .topbar,
body.driveos-driver-lime .topbar {
  background: #101612 !important;
  color: var(--driveos-text) !important;
  border-color: var(--driveos-border) !important;
}
body.driveos-admin-mobile .topbar :is(select,button),
body.driveos-driver-lime .topbar :is(select,button) {
  background: var(--driveos-surface-2) !important;
  border-color: var(--driveos-border) !important;
  color: var(--driveos-text) !important;
}
body.driveos-admin-mobile .page-header h1,
body.driveos-driver-lime .page-header h1,
body.driveos-admin-mobile .card-header h2,
body.driveos-driver-lime .card-header h2 {
  color: var(--driveos-text) !important;
}
body.driveos-admin-mobile :is(.page-header p,.card-header p,.muted),
body.driveos-driver-lime :is(.page-header p,.card-header p,.muted) {
  color: var(--driveos-muted) !important;
}
body.driveos-admin-mobile .btn.primary,
body.driveos-driver-lime .btn.primary {
  min-height: 44px;
  background: var(--driveos-lime) !important;
  border-color: var(--driveos-lime) !important;
  color: #11180d !important;
  font-weight: 750;
}
body.driveos-admin-mobile :is(.page,.card,.kpi,.entity-card),
body.driveos-driver-lime :is(.page,.card,.kpi,.entity-card) {
  color: var(--driveos-text);
}
body.driveos-admin-mobile .dam-bottom-nav,
body.driveos-driver-lime .dam-bottom-nav {
  background: #101612 !important;
  border-color: var(--driveos-border) !important;
}
body.driveos-admin-mobile .dam-bottom-nav button[aria-current="page"],
body.driveos-driver-lime .dam-bottom-nav button[aria-current="page"] {
  color: var(--driveos-lime) !important;
}

/* Mobile finance: show each payable/ledger record as a readable card.
   All columns and existing actions remain available; no financial logic changes. */
@media (max-width: 767px) {
  body.driveos-admin-mobile #page-accounts .accounts-financial-card,
  body.driveos-admin-mobile #page-accounts .accounts-payable-card {
    overflow: hidden;
    background: var(--driveos-surface) !important;
    color: var(--driveos-text) !important;
    border: 1px solid var(--driveos-border) !important;
    border-radius: 18px !important;
  }
  body.driveos-admin-mobile #page-accounts .accounts-financial-card .card-header,
  body.driveos-admin-mobile #page-accounts .accounts-payable-card .card-header {
    padding: 16px 16px 8px;
  }
  body.driveos-admin-mobile #financialTable .driveos-accounts-pro-table-wrap,
  body.driveos-admin-mobile #payablesTable.driveos-accounts-canonical-list {
    overflow: visible !important;
    max-width: 100% !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries],
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] thead,
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table thead {
    display: none !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody,
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody {
    display: grid;
    gap: 10px;
    padding: 10px 12px 14px;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody tr,
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 12px;
    padding: 8px 12px;
    background: var(--driveos-surface-2) !important;
    border: 1px solid var(--driveos-border);
    border-radius: 14px;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td,
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td {
    display: block;
    min-width: 0;
    padding: 8px 0 !important;
    border-bottom: 1px solid var(--driveos-color-border) !important;
    background: transparent !important;
    color: var(--driveos-text) !important;
    font-size: 13px !important;
    line-height: 1.35;
    white-space: normal !important;
    overflow-wrap: anywhere;
    position: static !important;
    box-shadow: none !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td::before,
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td::before {
    display: block;
    margin-bottom: 3px;
    color: var(--driveos-muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(1)::before { content: "Data"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(2)::before { content: "Tipo"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(3)::before { content: "Descrição"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(4)::before { content: "Categoria"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(5)::before { content: "Veículo"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(6)::before { content: "Motorista"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(7)::before { content: "Valor"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(8)::before { content: "Liquidado"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(9)::before { content: "Em aberto"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(10)::before { content: "Vencimento"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(11)::before { content: "Status"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(12)::before { content: "Ações"; }
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(1)::before { content: "Vencimento"; }
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(2)::before { content: "Prev. pagamento"; }
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(3)::before { content: "Credor"; }
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(4)::before { content: "Veículo"; }
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(5)::before { content: "Descrição"; }
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(6)::before { content: "Em aberto"; }
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(7)::before { content: "Status"; }
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(8)::before { content: "Ações"; }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(3),
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(12),
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(5),
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(8) {
    grid-column: 1 / -1;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(3) {
    font-weight: 650;
    color: var(--driveos-color-text) !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(7),
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(9) {
    color: var(--driveos-lime) !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(12) .actions,
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(8) .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] .tiny-btn,
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table .tiny-btn {
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #263326 !important;
    color: var(--driveos-text) !important;
    border-color: #465740 !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(2) .driveos-accounts-badge.good {
    color: #c6f4a3 !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(2) .driveos-accounts-badge.bad {
    color: #ffb0b0 !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td {
    text-align: left !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(7),
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(8),
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody td:nth-child(9) {
    text-align: right !important;
  }
  body.driveos-admin-mobile .dam-bottom-nav :is(button) { min-height: 56px; }
}


/* Keep common account-page controls in the same dark/lime language. */
body.driveos-admin-mobile .driveos-filter-bar { margin: 8px 12px; }
body.driveos-admin-mobile .driveos-filter-toggle {
  min-height: 42px;
  border: 1px solid var(--driveos-border) !important;
  border-radius: 12px !important;
  background: var(--driveos-surface) !important;
  color: var(--driveos-text) !important;
}
body.driveos-admin-mobile .driveos-filter-count {
  background: var(--driveos-lime) !important;
  color: #11180d !important;
  border-radius: 99px;
  font-weight: 800;
}
body.driveos-admin-mobile #page-accounts .driveos-page-tools,
body.driveos-admin-mobile #page-accounts .driveos-page-tools :is(button,select),
body.driveos-admin-mobile #page-accounts .page-header > button:not(.btn.primary) {
  background: var(--driveos-surface-2) !important;
  color: var(--driveos-text) !important;
  border: 1px solid var(--driveos-border) !important;
  border-radius: 12px;
  min-height: 44px;
}
body.driveos-admin-mobile :is(.btn.secondary,.tiny-btn,.icon-btn) {
  background: var(--driveos-surface-2) !important;
  color: var(--driveos-text) !important;
  border-color: var(--driveos-border) !important;
}
body.driveos-admin-mobile .dam-bottom-nav button[aria-current="page"] {
  color: var(--driveos-lime) !important;
}

@media (max-width: 767px) {
  body.driveos-admin-mobile #payablesTable table.driveos-accounts-pro-table tbody td:nth-child(6) {
    color: #ff9a9a !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody tr:has(td:nth-child(2) .driveos-accounts-badge.bad) td:nth-child(7),
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody tr:has(td:nth-child(2) .driveos-accounts-badge.bad) td:nth-child(9) {
    color: #ff9a9a !important;
  }
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody tr:has(td:nth-child(2) .driveos-accounts-badge.good) td:nth-child(7),
  body.driveos-admin-mobile #financialTable table[data-driveos-financial-entries] tbody tr:has(td:nth-child(2) .driveos-accounts-badge.good) td:nth-child(9) {
    color: var(--driveos-lime) !important;
  }
}
