/*
  Stage 105.3D CLEAN — Table Row / Page Content Readability Recovery
  Built from confirmed Stage 105.3C.

  Scope:
  - Main page content tables/lists only.
  - Recover washed-out row text and dense table contrast on older/partially UI-v2 pages.
  - Keep dropdown/menu/sidebar work from 105.3B/105.3C untouched.
  - Keep Customer 360 tabbed profile behaviour untouched.

  No route, API, popup behaviour, app.js, backend, database, or business logic changes.
*/

:root {
  --ui1053d-table-text: #172033;
  --ui1053d-table-muted: #475569;
  --ui1053d-table-head: #263247;
  --ui1053d-table-head-bg: rgba(241, 245, 249, 0.98);
  --ui1053d-table-border: rgba(148, 163, 184, 0.28);
  --ui1053d-row-odd: rgba(255, 255, 255, 0.98);
  --ui1053d-row-even: rgba(241, 245, 249, 0.78);
  --ui1053d-row-hover: rgba(219, 234, 254, 0.72);
  --ui1053d-link: #1d4ed8;
}

html[data-theme="dark"],
body.dark,
body.theme-dark {
  --ui1053d-table-text: #e5edf8;
  --ui1053d-table-muted: #b6c2d2;
  --ui1053d-table-head: #f1f5f9;
  --ui1053d-table-head-bg: rgba(30, 41, 59, 0.96);
  --ui1053d-table-border: rgba(148, 163, 184, 0.24);
  --ui1053d-row-odd: rgba(15, 23, 42, 0.94);
  --ui1053d-row-even: rgba(30, 41, 59, 0.78);
  --ui1053d-row-hover: rgba(37, 99, 235, 0.20);
  --ui1053d-link: #93c5fd;
}

/* Main content only. Do not touch flyout menus, maps, or modal internals here. */
#page :where(table):not(.gm-style table),
.page :where(table):not(.gm-style table) {
  color: var(--ui1053d-table-text) !important;
  border-color: var(--ui1053d-table-border) !important;
  opacity: 1 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
}

#page :where(table):not(.gm-style table) thead th,
.page :where(table):not(.gm-style table) thead th,
#page :where(table):not(.gm-style table) th,
.page :where(table):not(.gm-style table) th {
  color: var(--ui1053d-table-head) !important;
  background: var(--ui1053d-table-head-bg) !important;
  border-color: var(--ui1053d-table-border) !important;
  opacity: 1 !important;
  text-shadow: none !important;
}

#page :where(table):not(.gm-style table) tbody tr,
.page :where(table):not(.gm-style table) tbody tr {
  opacity: 1 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
}

#page :where(table):not(.gm-style table) tbody tr:nth-child(odd) td,
.page :where(table):not(.gm-style table) tbody tr:nth-child(odd) td {
  background-color: var(--ui1053d-row-odd) !important;
}

#page :where(table):not(.gm-style table) tbody tr:nth-child(even) td,
.page :where(table):not(.gm-style table) tbody tr:nth-child(even) td {
  background-color: var(--ui1053d-row-even) !important;
}

#page :where(table):not(.gm-style table) tbody tr:hover td,
.page :where(table):not(.gm-style table) tbody tr:hover td {
  background-color: var(--ui1053d-row-hover) !important;
}

#page :where(table):not(.gm-style table) td,
.page :where(table):not(.gm-style table) td,
#page :where(table):not(.gm-style table) td span:not([class*="badge"]):not([class*="pill"]):not([class*="chip"]),
.page :where(table):not(.gm-style table) td span:not([class*="badge"]):not([class*="pill"]):not([class*="chip"]) {
  color: var(--ui1053d-table-text) !important;
  border-color: var(--ui1053d-table-border) !important;
  opacity: 1 !important;
  text-shadow: none !important;
}

#page :where(table):not(.gm-style table) td small,
.page :where(table):not(.gm-style table) td small,
#page :where(table):not(.gm-style table) td .muted,
.page :where(table):not(.gm-style table) td .muted,
#page :where(table):not(.gm-style table) td .text-muted,
.page :where(table):not(.gm-style table) td .text-muted {
  color: var(--ui1053d-table-muted) !important;
  opacity: 1 !important;
}

#page :where(table):not(.gm-style table) a,
.page :where(table):not(.gm-style table) a {
  color: var(--ui1053d-link) !important;
  opacity: 1 !important;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Badges/chips should stay readable without flattening their intent colours. */
#page :where(table):not(.gm-style table) :is(.badge, .pill, .chip, [class*="badge"], [class*="pill"], [class*="chip"]),
.page :where(table):not(.gm-style table) :is(.badge, .pill, .chip, [class*="badge"], [class*="pill"], [class*="chip"]) {
  opacity: 1 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Older list/card shells often put text directly in rows rather than semantic tables. */
#page :where(.list-row, .table-row, .data-row, .stage-card-row, .rows .row, .result-row),
.page :where(.list-row, .table-row, .data-row, .stage-card-row, .rows .row, .result-row) {
  color: var(--ui1053d-table-text) !important;
  opacity: 1 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
}

#page :where(.list-row, .table-row, .data-row, .stage-card-row, .rows .row, .result-row) :where(span, strong, small, div, p),
.page :where(.list-row, .table-row, .data-row, .stage-card-row, .rows .row, .result-row) :where(span, strong, small, div, p) {
  opacity: 1 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Keep table containers from spilling under the sidebar/footer while preserving horizontal scroll where needed. */
#page :where(.table-wrap, .table-wrapper, .data-table-wrap, .stage-table-wrap, .overflow-x-auto),
.page :where(.table-wrap, .table-wrapper, .data-table-wrap, .stage-table-wrap, .overflow-x-auto) {
  max-width: 100% !important;
  overflow-x: auto !important;
  scrollbar-color: rgba(100, 116, 139, 0.55) rgba(226, 232, 240, 0.55);
}
