/* DriveOS dark/lime consistency layer v2
 * Presentation only. Existing role separation, filters, calculations, actions,
 * and record ownership remain unchanged.
 */
html[data-driveos-theme="dark"] {
  --primary: var(--driveos-color-accent);
  --primary-dark: var(--driveos-color-accent-hover);
  --surface: var(--driveos-color-surface);
  --surface-2: var(--driveos-color-surface-raised);
  --line: var(--driveos-color-border);
  --text: var(--driveos-color-text);
  --muted: var(--driveos-color-muted);
}

html[data-driveos-theme="dark"] :is(.page-header h1,.card-header h2,.page h2,.page h3) {
  color: var(--text) !important;
}
html[data-driveos-theme="dark"] :is(.page-header p,.card-header p,.page .muted,.page .hint) {
  color: var(--muted) !important;
}
html[data-driveos-theme="dark"] :is(.card,.kpi,.entity-card,.table-wrap) {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
html[data-driveos-theme="dark"] :is(.btn.primary,.page .btn.primary,.page-actions .btn.primary) {
  background: var(--driveos-color-accent) !important;
  border-color: var(--driveos-color-accent) !important;
  color: var(--driveos-color-accent-ink) !important;
}
html[data-driveos-theme="dark"] :is(.btn.secondary,.tiny-btn,.icon-btn,.driveos-page-tools button,.driveos-page-tools select) {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}
html[data-driveos-theme="dark"] :is(.page .data-table th,.page .v45-table th,.page table.driveos-standard-table th) {
  background: var(--driveos-color-surface-inset) !important;
  color: var(--driveos-color-muted-strong) !important;
  border-color: var(--line) !important;
}
html[data-driveos-theme="dark"] :is(.page .data-table td,.page .v45-table td,.page table.driveos-standard-table td) {
  background: var(--surface) !important;
  border-color: var(--line) !important;
}
html[data-driveos-theme="dark"] .page :is(.data-table,.v45-table,table.driveos-standard-table) td:not(.positive):not(.negative):not(.good):not(.bad):not(.warn):not(.driveos-value-positive):not(.driveos-value-negative) {
  color: var(--text) !important;
}
html[data-driveos-theme="dark"] :is(.page .data-table tbody tr:hover td,.page .v45-table tbody tr:hover td,.page table.driveos-standard-table tbody tr:hover td) {
  background: #202820 !important;
}
html[data-driveos-theme="dark"] :is(.page .data-table th[aria-sort="ascending"],.page .data-table th[aria-sort="descending"],.page table.driveos-standard-table th[aria-sort="ascending"],.page table.driveos-standard-table th[aria-sort="descending"]) {
  color: #d7ff8a !important;
}

/* One compact filter entry point across screens; advanced controls stay hidden
   until opened. Existing filter values, saved views and quick presets are intact. */
html[data-driveos-theme="dark"] .driveos-filter-bar {
  gap: 8px;
  margin: 8px 0 12px;
}
html[data-driveos-theme="dark"] .driveos-filter-toggle {
  min-height: 42px;
  padding: 9px 13px;
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: 12px !important;
  color: var(--text) !important;
  box-shadow: none;
}
html[data-driveos-theme="dark"] .driveos-filter-bar.has-active-filters .driveos-filter-toggle {
  border-color: #698a35 !important;
  background: #192318 !important;
}
html[data-driveos-theme="dark"] .driveos-filter-icon::before {
  border-top-color: #c3d0c0;
}
html[data-driveos-theme="dark"] .driveos-filter-icon::after {
  background: #c3d0c0;
}
html[data-driveos-theme="dark"] .driveos-filter-clear {
  min-height: 42px;
  padding: 8px 12px;
  background: transparent !important;
  border: 1px solid var(--line) !important;
  border-radius: 11px;
  color: var(--muted) !important;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
html[data-driveos-theme="dark"] .driveos-filter-clear:hover {
  border-color: #526e38 !important;
  color: #d7ff8a !important;
}
html[data-driveos-theme="dark"] .driveos-filter-clear[hidden],
html[data-driveos-theme="dark"] .driveos-filter-chips[hidden] {
  display: none !important;
}
html[data-driveos-theme="dark"] .driveos-filter-count {
  min-width: 20px;
  height: 20px;
  background: var(--driveos-color-accent) !important;
  color: var(--driveos-color-accent-ink) !important;
  font-weight: 850;
}
html[data-driveos-theme="dark"] .driveos-filter-chevron {
  color: #c3d0c0;
}
html[data-driveos-theme="dark"] .driveos-filter-panel.driveos-filter-expanded:not(.card) {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: 14px;
}
html[data-driveos-theme="dark"] .driveos-filter-panel :is(label,.field label) {
  color: #c2cdc1 !important;
}
html[data-driveos-theme="dark"] .driveos-filter-panel :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea) {
  min-height: 40px;
  background: #0f1510 !important;
  border-color: var(--driveos-color-border-strong) !important;
  color: #f2f7ee !important;
  color-scheme: dark;
}
html[data-driveos-theme="dark"] .driveos-filter-panel :is(input,select,textarea):focus-visible {
  outline: 2px solid var(--driveos-color-accent) !important;
  outline-offset: 1px;
}
html[data-driveos-theme="dark"] .driveos-filter-panel :is(input,textarea)::placeholder {
  color: var(--driveos-color-muted) !important;
  opacity: 1;
}
html[data-driveos-theme="dark"] .driveos-filter-panel :is(button:not(.primary),.tiny-btn) {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}
html[data-driveos-theme="dark"] .driveos-filter-panel .btn.primary {
  background: var(--driveos-color-accent) !important;
  border-color: var(--driveos-color-accent) !important;
  color: var(--driveos-color-accent-ink) !important;
}
html[data-driveos-theme="dark"] .driveos-filter-views :is(select,button),
html[data-driveos-theme="dark"] .driveos-filter-view-editor :is(input,button),
html[data-driveos-theme="dark"] .driveos-filter-view-confirm-delete button {
  min-height: 40px;
  background: var(--surface) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}
html[data-driveos-theme="dark"] .driveos-filter-views>[data-driveos-view-save] {
  border-color: #526e38 !important;
  color: #d7ff8a !important;
  background: #192318 !important;
}
html[data-driveos-theme="dark"] .driveos-filter-views>[data-driveos-view-delete],
html[data-driveos-theme="dark"] .driveos-filter-view-confirm-delete {
  color: var(--driveos-color-negative) !important;
}
html[data-driveos-theme="dark"] .driveos-filter-chips>strong {
  color: var(--muted) !important;
}
html[data-driveos-theme="dark"] .driveos-filter-chips button {
  background: #192318 !important;
  border-color: #526e38 !important;
  color: #d7ff8a !important;
}

/* Expenses used a separate light palette; align its filters, quick presets,
   summary cards and data grid with the same admin theme. */
html[data-driveos-theme="dark"] #page-expenses {
  --expense-ink: var(--driveos-color-text);
  --expense-muted: var(--driveos-color-muted);
  --expense-border: var(--driveos-color-border);
  --expense-soft: var(--driveos-color-surface);
}
html[data-driveos-theme="dark"] #page-expenses .expense-v453-filters,
html[data-driveos-theme="dark"] #page-expenses .page-actions,
html[data-driveos-theme="dark"] #page-expenses > .card,
html[data-driveos-theme="dark"] #page-expenses #expenseKpis .kpi {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
html[data-driveos-theme="dark"] #page-expenses .expense-v453-filters .field label {
  color: #c2cdc1 !important;
}
html[data-driveos-theme="dark"] #page-expenses .expense-v453-filters :is(input,select) {
  background: #0f1510 !important;
  border-color: var(--driveos-color-border-strong) !important;
  color: #f2f7ee !important;
  color-scheme: dark;
}
html[data-driveos-theme="dark"] #page-expenses .expense-v457-quick .tiny-btn {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: #dce5db !important;
}
html[data-driveos-theme="dark"] #page-expenses .expense-v457-quick .tiny-btn.active {
  background: var(--driveos-color-accent) !important;
  border-color: var(--driveos-color-accent) !important;
  color: var(--driveos-color-accent-ink) !important;
}
html[data-driveos-theme="dark"] #page-expenses #expensesTable .data-table :is(th,td) {
  background: var(--surface) !important;
  border-color: var(--line) !important;
}
html[data-driveos-theme="dark"] #page-expenses #expensesTable .data-table td:not(.positive):not(.negative):not(.good):not(.bad):not(.warn):not(.driveos-value-positive):not(.driveos-value-negative) {
  color: var(--text) !important;
}
html[data-driveos-theme="dark"] #page-expenses #expensesTable .data-table th {
  background: var(--driveos-color-surface-inset) !important;
  color: var(--driveos-color-muted-strong) !important;
}
html[data-driveos-theme="dark"] #page-expenses #expensesTable .data-table tbody tr:hover td {
  background: #202820 !important;
}

/* Keep form fields in the existing edit modal light for familiar data entry. */
html[data-driveos-theme="dark"] #modal .field :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),select,textarea) {
  background: #fff !important;
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  color-scheme: light;
}
@media (max-width: 767px) {
  html[data-driveos-theme="dark"] .driveos-filter-views {
    width: 100%;
  }
  html[data-driveos-theme="dark"] #page-expenses .expense-v453-filters :is(input,select) {
    width: 100%;
    min-width: 0;
  }
}


/* DRIVEOS_MOBILE_RECORD_CARD_LISTS_V1
 * On narrow screens, operational/financial record rows become readable cards.
 * The canonical row/cells and action controls remain in the DOM unchanged.
 */
@media (max-width: 760px) {
  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list,
  html.driveos-mobile-card-lists #page-accounts table.driveos-mobile-record-list {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: auto !important;
    border: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: transparent !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > caption {
    display: block !important;
    width: 100% !important;
    padding: 10px 2px !important;
    color: #aeb8ae !important;
    text-align: left !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > thead {
    display: none !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 10px 14px !important;
    margin: 0 !important;
    overflow: hidden !important;
    border: 1px solid #303c32 !important;
    border-radius: 18px !important;
    background: #111812 !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.16) !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td {
    display: grid !important;
    grid-template-columns: minmax(86px, 34%) minmax(0, 1fr) !important;
    gap: 8px !important;
    align-items: start !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 8px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid #283229 !important;
    background: transparent !important;
    color: #e4ebe3 !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    line-height: 1.45 !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td::before {
    content: attr(data-driveos-mobile-card-label) !important;
    display: block !important;
    color: #98a598 !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    letter-spacing: .035em !important;
    line-height: 1.4 !important;
    text-transform: uppercase !important;
    white-space: normal !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td.driveos-mobile-card-primary {
    order: -1 !important;
    display: block !important;
    padding: 4px 0 10px !important;
    color: #c5fa54 !important;
    font-size: 17px !important;
    font-weight: 850 !important;
    line-height: 1.3 !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td.driveos-mobile-card-primary::before {
    content: none !important;
    display: none !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td.driveos-mobile-card-actions {
    order: 100 !important;
    display: block !important;
    padding: 12px 0 2px !important;
    border: 0 !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td.driveos-mobile-card-actions::before,
  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td:empty:not(.driveos-mobile-card-actions)::before {
    content: none !important;
    display: none !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list .actions,
  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list .table-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list .actions > button,
  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list .table-actions > button,
  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td.driveos-mobile-card-actions button {
    flex: 1 1 130px !important;
    min-width: 0 !important;
    min-height: 44px !important;
    white-space: normal !important;
  }

  html.driveos-mobile-card-lists .page table.driveos-mobile-record-list > tbody > tr[data-driveos-mobile-card-row="true"] > td.driveos-mobile-card-actions button.primary {
    background: #24361d !important;
    border-color: #405b30 !important;
    color: #c5fa54 !important;
  }
}

@media (max-width: 760px) {
  html.driveos-mobile-card-lists .page .driveos-mobile-card-sort {
    display: flex !important;
    align-items: end !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 10px 0 !important;
  }

  html.driveos-mobile-card-lists .page .driveos-mobile-card-sort label {
    display: grid !important;
    gap: 5px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    color: #aeb8ae !important;
    font-size: 11px !important;
    font-weight: 700 !important;
  }

  html.driveos-mobile-card-lists .page .driveos-mobile-card-sort select,
  html.driveos-mobile-card-lists .page .driveos-mobile-card-sort button {
    min-height: 42px !important;
    border: 1px solid #344435 !important;
    border-radius: 12px !important;
    background: #111812 !important;
    color: #edf4e9 !important;
    padding: 8px 12px !important;
    font: inherit !important;
  }

  html.driveos-mobile-card-lists .page .driveos-mobile-card-sort button:disabled {
    opacity: .45 !important;
  }
}