/* DRIVEOS_ADMIN_SCREEN_STANDARD_V1
 * Admin-only dark/lime surfaces and mobile record cards.
 * Presentation layer only: no data, permissions, or financial behavior changes.
 */
body:not(.driveos-driver-lime) #appView .page {
  color: var(--driveos-color-text) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.page-header h1,.card-header h2,.page h2,.page h3,.page h4) {
  color: var(--driveos-color-text) !important;
  -webkit-text-fill-color: var(--driveos-color-text) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.page-header p,.card-header p,.muted,.hint,.label,.activity-list .content span,.empty) {
  color: var(--driveos-color-muted) !important;
  -webkit-text-fill-color: var(--driveos-color-muted) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.card,.kpi,.entity-card,.table-wrap,.activity,.empty,.maintenance-rule,.maintenance-rule-grid>div,.v45-hero,.v45-toolbar,.v45-kpi,.v45-card,.v45-table-wrap,.v45-period-compare-labels>div,.v45-drill-summary,.v45-compare-controls,.v45-compare-head>div,.fleet-compare-summary-card,.fleet-compare-note,.fleet-vehicle-card,.fleet-detail-hero>div,.fleet-detail-grid>div,.fleet-vehicle-main-metrics>div,.driveos-audit-kpi) {
  background: var(--driveos-color-surface) !important;
  color: var(--driveos-color-text) !important;
  border-color: var(--driveos-color-border) !important;
  box-shadow: none !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.kpi,.v45-kpi,.driveos-audit-kpi) {
  border-radius: 16px !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.kpi .value,.entity-card h3,.v45-kpi>strong,.maintenance-rule-grid strong,.driveos-audit-kpi strong) {
  color: var(--driveos-color-text) !important;
  -webkit-text-fill-color: var(--driveos-color-text) !important;
  opacity: 1 !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.kpi .label,.kpi .hint,.v45-kpi>span,.v45-kpi>small,.v45-eyebrow,.v45-section-title span,.v45-card-head span,.maintenance-rule-grid span,.maintenance-rule-grid small,.driveos-audit-kpi span) {
  color: var(--driveos-color-muted) !important;
  -webkit-text-fill-color: var(--driveos-color-muted) !important;
  opacity: 1 !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.v45-tabs,.v45-period-compare-labels>div,.v45-rank b,.v45-trend-track,.v45-drill-summary,.v45-compare-head>div,.maintenance-rule-grid>div) {
  background: var(--driveos-color-surface-raised) !important;
  color: var(--driveos-color-text) !important;
  border-color: var(--driveos-color-border) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.v45-tabs button,.v45-comparison-head,.v45-comparison-row,.v45-trend-row,.v45-rank,.v45-period-compare-labels span,.v45-compare-head span,.v45-table th) {
  color: var(--driveos-color-muted) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.v45-tabs button.active,.v45-card-head h3,.v45-section-title h2,.v45-period-compare-labels strong,.v45-compare-head strong) {
  color: var(--driveos-color-text) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.v45-table,.v45-table thead,.v45-table tbody,.v45-table tr,.v45-table th,.v45-table td) {
  background: var(--driveos-color-surface) !important;
  border-color: var(--driveos-color-border) !important;
}
body:not(.driveos-driver-lime) #appView .page .v45-table th {
  background: var(--driveos-color-surface-inset) !important;
  color: var(--driveos-color-muted-strong) !important;
}
body:not(.driveos-driver-lime) #appView .page .v45-table td {
  color: var(--driveos-color-text) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.v45-delta.good,.v45-delta.bad,.v45-delta.neutral) {
  -webkit-text-fill-color: currentColor !important;
}
body:not(.driveos-driver-lime) #appView .page .v45-delta.good { background: var(--driveos-color-positive-surface) !important; color: #8ee0a8 !important; }
body:not(.driveos-driver-lime) #appView .page .v45-delta.bad { background: var(--driveos-color-negative-surface) !important; color: var(--driveos-color-negative) !important; }
body:not(.driveos-driver-lime) #appView .page .v45-delta.neutral { background: #242a25 !important; color: var(--driveos-color-muted-strong) !important; }

body:not(.driveos-driver-lime) #appView .page :is(.analytics-bars,.analytics-insights,.bonus-board) {
  background: var(--driveos-color-surface) !important;
  color: var(--driveos-color-text) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.analytics-bar-row,.analytics-insight,.bonus-row) {
  border-color: var(--driveos-color-border) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.analytics-bar-label span,.analytics-insight span,.bonus-main span,.bonus-main small,.bonus-score span,.bonus-score em) {
  color: var(--driveos-color-muted) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.analytics-bar-track,.bonus-progress) {
  background: #263126 !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.maintenance-rule.ok,.maintenance-rule.soon,.maintenance-rule.overdue,.maintenance-rule.baseline,.maintenance-rule.draft) {
  background: var(--driveos-color-surface) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.activity-list .activity,.activity-list .empty,.maintenance-rule-grid>div) {
  border: 1px solid var(--driveos-color-border) !important;
  border-radius: 12px !important;
}
body:not(.driveos-driver-lime) #appView .page .badge {
  -webkit-text-fill-color: currentColor !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.badge.bad,.badge.negative,.negative,.v45-delta.bad) {
  color: var(--driveos-color-negative) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.badge.good,.badge.positive,.positive,.v45-delta.good) {
  color: var(--driveos-color-positive) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.badge.warn,.warning) {
  color: var(--driveos-color-warning) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.btn.primary,.btn.primary:hover) {
  background: var(--driveos-color-accent) !important;
  color: var(--driveos-color-accent-ink) !important;
  -webkit-text-fill-color: var(--driveos-color-accent-ink) !important;
  border-color: var(--driveos-color-accent) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.btn.secondary,.tiny-btn,.icon-btn) {
  background: var(--driveos-color-surface-raised) !important;
  color: var(--driveos-color-text) !important;
  -webkit-text-fill-color: var(--driveos-color-text) !important;
  border-color: #3c4c3b !important;
}
body:not(.driveos-driver-lime) #appView .page :is(input,select,textarea) {
  background: var(--driveos-color-surface-inset) !important;
  color: var(--driveos-color-text) !important;
  -webkit-text-fill-color: var(--driveos-color-text) !important;
  border-color: var(--driveos-color-border-strong) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(input,select,textarea)::placeholder {
  color: var(--driveos-color-muted) !important;
  -webkit-text-fill-color: var(--driveos-color-muted) !important;
  opacity: 1 !important;
}
body:not(.driveos-driver-lime) #appView .page :is(table.data-table,table.v45-table,table.driveos-standard-table) {
  border-color: var(--driveos-color-border) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(table.data-table th,table.v45-table th,table.driveos-standard-table th) {
  background: var(--driveos-color-surface-inset) !important;
  color: var(--driveos-color-muted-strong) !important;
  border-color: var(--driveos-color-border) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(table.data-table td,table.v45-table td,table.driveos-standard-table td) {
  background: var(--driveos-color-surface) !important;
  color: var(--driveos-color-text) !important;
  border-color: var(--driveos-color-border) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(table.data-table td.positive,table.v45-table td.positive,table.driveos-standard-table td.positive) {
  color: var(--driveos-color-positive) !important;
  -webkit-text-fill-color: var(--driveos-color-positive) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(table.data-table td.negative,table.v45-table td.negative,table.driveos-standard-table td.negative) {
  color: var(--driveos-color-negative) !important;
  -webkit-text-fill-color: var(--driveos-color-negative) !important;
}
body:not(.driveos-driver-lime) #appView .page :is(.empty,.empty-state) {
  background: var(--driveos-color-surface) !important;
  color: var(--driveos-color-muted) !important;
  border-color: var(--driveos-color-border) !important;
}

/* On mobile, turn each administrative table record into a labeled card.
   The headers remain in the DOM for accessible names, but are visually hidden. */
@media (max-width: 760px) {
  body.driveos-admin-mobile #appView .page .table-wrap:has(table[data-driveos-mobile-cards="true"]) {
    overflow: visible !important;
    max-width: 100% !important;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    table-layout: auto !important;
    background: transparent !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] thead {
    display: none !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody {
    display: grid !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 8px 10px 14px !important;
    background: transparent !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody tr {
    display: grid !important;
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 0 12px !important;
    width: 100% !important;
    padding: 8px 12px !important;
    background: var(--driveos-color-surface-raised) !important;
    border: 1px solid var(--driveos-color-border) !important;
    border-radius: 14px !important;
    box-sizing: border-box !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody td {
    display: block !important;
    min-width: 0 !important;
    padding: 8px 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-bottom: 1px solid var(--driveos-color-border) !important;
    color: var(--driveos-color-text) !important;
    -webkit-text-fill-color: var(--driveos-color-text) !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    text-align: left !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody td::before {
    content: attr(data-driveos-mobile-label);
    display: block;
    margin: 0 0 3px;
    color: var(--driveos-color-muted) !important;
    -webkit-text-fill-color: var(--driveos-color-muted) !important;
    font-size: 10px !important;
    font-weight: 750 !important;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody td[colspan] {
    grid-column: 1 / -1 !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody td[hidden],
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody td[style*="display: none"] {
    display: none !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody td:last-child {
    grid-column: 1 / -1 !important;
    border-bottom: 0 !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody tr:has(td:nth-child(1):only-child) {
    grid-template-columns: 1fr !important;
  }
  body.driveos-admin-mobile #appView .page table[data-driveos-mobile-cards="true"] tbody td :is(.tiny-btn,button) {
    min-height: 40px !important;
    margin: 3px 5px 3px 0 !important;
    white-space: normal !important;
  }
}

/* Driver directory filters are a custom surface and do not carry .card. */
body:not(.driveos-driver-lime) #appView #page-drivers .driveos-driver-filterbar {
  color: var(--driveos-color-text) !important;
  background: var(--driveos-color-surface) !important;
  border-color: var(--driveos-color-border) !important;
}
body:not(.driveos-driver-lime) #appView #page-drivers .driveos-driver-filterbar label,
body:not(.driveos-driver-lime) #appView #page-drivers .driveos-driver-count {
  color: var(--driveos-color-muted) !important;
}
body:not(.driveos-driver-lime) #appView #page-drivers .driveos-driver-filterbar :is(input, select) {
  color: var(--driveos-color-text) !important;
  background: var(--driveos-color-surface-inset) !important;
  border-color: var(--driveos-color-border-strong) !important;
  color-scheme: dark;
}
body:not(.driveos-driver-lime) #appView #page-drivers .driveos-driver-filterbar :is(input, select):focus-visible {
  outline: 2px solid var(--driveos-color-focus) !important;
  outline-offset: 1px;
}


body:not(.driveos-driver-lime) #appView #page-analytics .v45-tabs button.active {
  background: var(--driveos-color-accent) !important;
  color: var(--driveos-color-accent-ink) !important;
  -webkit-text-fill-color: var(--driveos-color-accent-ink) !important;
}

body:not(.driveos-driver-lime) #appView #page-trips :is(.dispatch-board-card,.dispatch-lane,.dispatch-lane-head,.dispatch-card) {
  background: var(--driveos-color-surface) !important;
  color: var(--driveos-color-text) !important;
  border-color: var(--driveos-color-border) !important;
}
body:not(.driveos-driver-lime) #appView #page-trips .dispatch-lane-body {
  background: var(--driveos-color-surface-inset) !important;
}
body:not(.driveos-driver-lime) #appView #page-trips .dispatch-board-head h2 {
  color: var(--driveos-color-text) !important;
}
body:not(.driveos-driver-lime) #appView #page-trips .dispatch-board-head p {
  color: var(--driveos-color-muted) !important;
}

body:not(.driveos-driver-lime) #appView .driveos-filter-views > [data-driveos-view-save] {
  background: var(--driveos-color-surface-raised) !important;
  color: var(--driveos-color-accent) !important;
  border-color: var(--driveos-color-border) !important;
}


body:not(.driveos-driver-lime) #appView #page-cashflow.active > #driveosFinanceRecordSearchButton.is-cashflow-inline {
  position: static;
  display: block !important;
  width: max-content;
  max-width: 100%;
  margin: 8px 0 12px auto;
  box-shadow: none;
}

body:not(.driveos-driver-lime) #modal #driveosV4515SingleExpense .driveos-v4515-section,
body:not(.driveos-driver-lime) #appView #page-accounts .accounts-payable-card :is(.driveos-account-kpi,.driveos-accounts-pro-kpi) {
  background: var(--driveos-color-surface-raised) !important;
  border-color: var(--driveos-color-border) !important;
  color: var(--driveos-color-text) !important;
}

body:not(.driveos-driver-lime) #modal #driveosV4515SingleExpense :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
body:not(.driveos-driver-lime) #appView #page-accounts #payableAccountKpis {
  background: var(--driveos-color-surface-inset) !important;
  border-color: var(--driveos-color-border) !important;
  color: var(--driveos-color-text) !important;
  color-scheme: dark;
}

body:not(.driveos-driver-lime) #modal #driveosV4515SingleExpense :is(input,select,textarea,option) {
  -webkit-text-fill-color: var(--driveos-color-text) !important;
}

body:not(.driveos-driver-lime) #modal #driveosV4515SingleExpense :is(input,textarea)::placeholder {
  color: var(--driveos-color-muted) !important;
  -webkit-text-fill-color: var(--driveos-color-muted) !important;
}

body:not(.driveos-driver-lime) #modal #driveosV4515SingleExpense :is(label,.driveos-v4515-section-head span),
body:not(.driveos-driver-lime) #appView #page-accounts .accounts-payable-card :is(.driveos-account-kpi,.driveos-accounts-pro-kpi) :is(span,small) {
  color: var(--driveos-color-muted) !important;
  -webkit-text-fill-color: currentColor !important;
}

body:not(.driveos-driver-lime) #appView #page-accounts .accounts-payable-card :is(.driveos-account-kpi,.driveos-accounts-pro-kpi) strong {
  color: var(--driveos-color-text) !important;
}

body:not(.driveos-driver-lime) #appView #page-accounts[data-accounts-view="payables"] .accounts-payable-card > .card-header h2 {
  display: none;
}


body:not(.driveos-driver-lime) #appView #page-accounts .accounts-receivable-card .driveos-receivable-load-number {
  color: var(--driveos-color-accent) !important;
  -webkit-text-fill-color: currentColor !important;
}

#driveosFinanceRecordSearchDialog {
  max-width: min(720px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  color-scheme: dark;
}

#driveosFinanceRecordSearchDialog .driveos-finance-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

#driveosFinanceRecordSearchDialog .driveos-finance-filter-grid :is(input, select) {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  margin-top: 4px;
  padding: 8px;
  background: var(--driveos-color-surface-inset);
  color: var(--driveos-color-text);
  border: 1px solid var(--driveos-color-border);
  border-radius: 8px;
}

#driveosFinanceRecordSearchDialog .driveos-finance-filter-actions {
  margin-top: 16px;
}

#driveosFinanceRecordSearchDialog .btn.primary {
  background: var(--driveos-color-accent);
  color: var(--driveos-color-accent-ink);
}

#driveosFinanceRecordSearchDialog .driveos-finance-search-result {
  display: block;
  width: 100%;
  text-align: left;
  overflow-wrap: anywhere;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--driveos-color-surface-raised);
  color: var(--driveos-color-text);
  border: 1px solid var(--driveos-color-border);
  border-radius: 8px;
}

#driveosFinanceRecordSearchDialog .driveos-finance-search-result span {
  display: block;
  margin-top: 4px;
  color: var(--driveos-color-muted);
}

@media (max-width: 420px) {
  #driveosFinanceRecordSearchDialog .driveos-finance-filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

body:not(.driveos-driver-lime) #appView #driverLedgerTable .badge {
  --ledger-status-background: var(--driveos-color-surface-raised);
  --ledger-status-text: var(--driveos-color-muted-strong);
  background: var(--ledger-status-background) !important;
  color: var(--ledger-status-text) !important;
  -webkit-text-fill-color: currentColor !important;
}

body:not(.driveos-driver-lime) #appView #driverLedgerTable .badge.good {
  --ledger-status-background: var(--driveos-color-positive-surface);
  --ledger-status-text: var(--driveos-color-positive);
}

body:not(.driveos-driver-lime) #appView #driverLedgerTable .badge.warn {
  --ledger-status-background: var(--driveos-color-warning-surface);
  --ledger-status-text: var(--driveos-color-warning);
}

/* Legacy admin surfaces use the same palette as shared cards and controls. */
@media screen {
  html[data-driveos-theme="dark"] body:not(.driveos-driver-lime) {
    & #appView :is(#tripsTable, #driveosBrokerFilters, .cashflow-pro-table-wrap),
    & #modal #smartRateFileList:not(:empty) {
      background: var(--driveos-color-surface) !important;
      border-color: var(--driveos-color-border) !important;
      color: var(--driveos-color-text) !important;
    }

    & #appView :is(.entity-card .mini-stat, .entity-card .entity-icon,
      .form-note, .telemetry-note, .driveos-table-density, .cashflow-pro-segmented),
    & #modal :is(.driveos-broker-form-note, .driveos-v360-edit-note, .smart-rate-icon) {
      background: var(--driveos-color-surface-raised) !important;
      border-color: var(--driveos-color-border) !important;
      color: var(--driveos-color-muted-strong) !important;
    }

    & #appView :is(.cashflow-pro-alert, .cashflow-pro-badge.attention, .badge.v4513a-bank-wait) {
      background: var(--driveos-color-warning-surface) !important;
      border-color: var(--driveos-color-warning-border) !important;
      color: var(--driveos-color-warning) !important;
    }

    & #appView .cashflow-pro-alert :is(strong, span) {
      color: var(--driveos-color-warning) !important;
    }

    & #appView :is(.cashflow-pro-badge.confirmed, .driveos-v4522-alert.good) {
      background: var(--driveos-color-positive-surface) !important;
      border-color: var(--driveos-color-border) !important;
      color: var(--driveos-color-positive) !important;
    }

    & #appView :is(.cashflow-pro-segmented button.active, .cashflow-pro-badge.expected) {
      background: var(--driveos-color-surface-raised) !important;
      border-color: var(--driveos-color-border-strong) !important;
      color: var(--driveos-color-accent) !important;
    }

    & #modal.driveos-modal-standard-v1 :is(.driveos-modal-control, .field input,
      .field select, .field textarea):not([type="checkbox"], [type="radio"]) {
      color-scheme: dark;
      background: var(--driveos-color-surface-inset) !important;
      border-color: var(--driveos-color-border-strong) !important;
      color: var(--driveos-color-text) !important;
      caret-color: currentColor !important;
      -webkit-text-fill-color: currentColor !important;

      &::placeholder {
        color: var(--driveos-color-muted) !important;
        -webkit-text-fill-color: currentColor !important;
      }

      &:is(:disabled, [readonly]) {
        background: var(--driveos-color-surface-raised) !important;
        color: var(--driveos-color-muted) !important;
      }
    }

    & #modal :is(.bank-resolve-transaction, .bank-resolve-option, .bank-resolve-ignore, .checkbox-line) {
      background: var(--driveos-color-surface) !important;
      border-color: var(--driveos-color-border) !important;
      color: var(--driveos-color-text) !important;
    }

    & #modal :is(.bank-resolve-option-primary, .bank-resolve-icon,
      .bank-resolve-option:hover, .bank-resolve-ignore:hover) {
      background: var(--driveos-color-surface-raised) !important;
      border-color: var(--driveos-color-border-strong) !important;
    }

    & #modal .bank-resolve-icon {
      color: var(--driveos-color-accent) !important;
    }

    & #modal :is(.bank-resolve-copy strong, .bank-resolve-ignore span, .checkbox-line strong) {
      color: var(--driveos-color-text) !important;
    }

    & #modal :is(.bank-resolve-copy small, .bank-resolve-ignore small, .checkbox-line small,
      .bank-resolve-transaction-main > span, .bank-resolve-section-title span) {
      color: var(--driveos-color-muted-strong) !important;
    }

    & #modal .bank-resolve-transaction-main > strong {
      color: var(--driveos-color-text) !important;
      white-space: normal;
      overflow-wrap: anywhere;
    }

    & #modal :is(.bank-resolve-option, .bank-resolve-ignore):focus-visible {
      outline: 2px solid var(--driveos-color-focus);
      outline-offset: 2px;
    }

    & #modal.driveos-modal-standard-v1 select option {
      background: var(--driveos-color-surface-inset);
      color: var(--driveos-color-text);
    }
  }
}
