/* ==========================================================================
   DealBroker theme layer — Light / Dark (2026-08)
   --------------------------------------------------------------------------
   Loaded LAST on every page (i_Header.php, logon.php). Every rule in this
   file is scoped to html[data-theme="light"] or html[data-theme="dark"]
   (or html[data-theme] for both). The default "Original" theme sets no
   attribute, so this entire file is inert and legacy pages render untouched.

   Specificity contract: page <style> blocks load after this file, so every
   selector here carries the html[data-theme] prefix (out-specifies bare
   class rules regardless of order) and !important wherever the legacy code
   itself uses !important (RE.css w3-* color classes, p_OverviewGrid button
   repaints) or inline style="" attributes (modals, JS-built spans).
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
html[data-theme] {
  --db-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --db-radius: 8px;
  --db-radius-lg: 12px;
}

html[data-theme="light"] {
  color-scheme: light;
  --db-bg: #f4f4f2;            /* page background */
  --db-surface: #ffffff;       /* cards, panels, modals */
  --db-surface-2: #f8f8f7;     /* subtle panels, table headers */
  --db-surface-3: #ececea;     /* hovers, wells, tracks */
  --db-text: #1f1f1d;
  --db-text-2: #5f5f5b;
  --db-text-3: #8f8f8a;
  --db-border: #e0e0dd;
  --db-border-2: #cfcfcb;
  --db-accent: #1a73e8;        /* links, icons, active states */
  --db-accent-bg: #1a73e8;     /* filled buttons / header bars */
  --db-accent-bg-text: #ffffff;
  --db-accent-soft: #e4ebf9;   /* selected fills, chips */
  --db-accent-soft-text: #174ea6;
  --db-danger: #b3261e;
  --db-danger-bg: #c5382f;
  --db-danger-soft: #fdecea;
  --db-danger-soft-text: #a50e0e;
  --db-success: #1e7e34;
  --db-success-bg: #2e8540;
  --db-success-soft: #e3f4e6;
  --db-success-soft-text: #137333;
  --db-warn: #8a5b00;
  --db-warn-bg: #e8a100;
  --db-warn-soft: #fef7e0;
  --db-warn-soft-text: #6d5400;
  --db-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --db-shadow-lg: 0 12px 32px rgba(0, 0, 0, .18);
  --db-topbar: #1b1b1a;        /* top bar stays dark: white logo needs it */
  --db-topbar-text: #e8e8e6;
  --db-overlay: rgba(32, 33, 36, .5);
  /* pages (Deals, CloseDeal, Myaccount) define these on :root — the
     html[data-theme] selector out-specifies :root, so themes retarget them */
  --primary-color: #1a73e8;
  --accent-color: #e4ebf9;
}

html[data-theme="dark"] {
  color-scheme: dark;          /* dark scrollbars + native form controls */
  --db-bg: #1a1a19;
  --db-surface: #232322;
  --db-surface-2: #292928;
  --db-surface-3: #333331;
  --db-text: #ececea;
  --db-text-2: #b4b4af;
  --db-text-3: #8f8f8a;
  --db-border: #3a3a37;
  --db-border-2: #4a4a46;
  --db-accent: #8ab4f8;
  --db-accent-bg: #2f6fdc;
  --db-accent-bg-text: #ffffff;
  --db-accent-soft: #24314d;
  --db-accent-soft-text: #a8c7fa;
  --db-danger: #f28b82;
  --db-danger-bg: #a33a32;
  --db-danger-soft: #3a2422;
  --db-danger-soft-text: #f2a29b;
  --db-success: #81c995;
  --db-success-bg: #2c6e3d;
  --db-success-soft: #1e3226;
  --db-success-soft-text: #92d1a4;
  --db-warn: #fdd663;
  --db-warn-bg: #8a6d1a;
  --db-warn-soft: #38300f;
  --db-warn-soft-text: #ecd07a;
  --db-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  --db-shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
  --db-topbar: #111110;
  --db-topbar-text: #d6d6d2;
  --db-overlay: rgba(0, 0, 0, .78); /* dark-on-dark needs a heavier scrim */
  --primary-color: #2f6fdc;
  --accent-color: #24314d;
}

/* ------------------------------------------------------------ base/page */
html[data-theme] body {
  background-color: var(--db-bg) !important;
  color: var(--db-text);
  font-family: var(--db-font);
}
html[data-theme] h1, html[data-theme] h2, html[data-theme] h3,
html[data-theme] h4, html[data-theme] h5, html[data-theme] h6 {
  font-family: var(--db-font);
  color: var(--db-text);
}
html[data-theme] table, html[data-theme] input, html[data-theme] select,
html[data-theme] textarea, html[data-theme] button {
  font-family: var(--db-font);
}
html[data-theme] a { color: var(--db-accent); }
html[data-theme] hr { border-color: var(--db-border); }
html[data-theme] label { color: var(--db-text-2); }

/* ------------------------------------------- w3 color classes (RE.css) */
/* RE.css marks every w3 color class !important, so these must be too.    */
/* Solid fills → semantic tokens (blue+teal+indigo normalize to accent).  */
html[data-theme] .w3-blue, html[data-theme] .w3-hover-blue:hover,
html[data-theme] .w3-teal, html[data-theme] .w3-indigo,
html[data-theme] .w3-light-blue {
  background-color: var(--db-accent-bg) !important;
  color: var(--db-accent-bg-text) !important;
}
html[data-theme] .w3-red, html[data-theme] .w3-hover-red:hover {
  background-color: var(--db-danger-bg) !important; color: #fff !important;
}
html[data-theme] .w3-green, html[data-theme] .w3-hover-green:hover {
  background-color: var(--db-success-bg) !important; color: #fff !important;
}
html[data-theme] .w3-yellow, html[data-theme] .w3-orange {
  background-color: var(--db-warn-bg) !important; color: #fff !important;
}
html[data-theme] .w3-white, html[data-theme] .w3-hover-white:hover {
  background-color: var(--db-surface) !important;
  color: var(--db-text) !important;
}
html[data-theme] .w3-light-grey, html[data-theme] .w3-light-gray {
  background-color: var(--db-bg) !important;
  color: var(--db-text) !important;
}
html[data-theme] .w3-grey, html[data-theme] .w3-gray {
  background-color: var(--db-surface-3) !important;
  color: var(--db-text) !important;
}
html[data-theme] .w3-dark-grey, html[data-theme] .w3-dark-gray {
  background-color: var(--db-border-2) !important;
  color: var(--db-text) !important;
}
/* w3-black: used for the fixed top bar */
html[data-theme] .w3-black {
  background-color: var(--db-topbar) !important;
  color: var(--db-topbar-text) !important;
}
/* Pale status fills (validation, alert panels, showMsg headers) — keep
   the semantic hue, adapt lightness so text stays readable per theme. */
html[data-theme] .w3-pale-red, html[data-theme] .w3-khaki {
  background-color: var(--db-danger-soft) !important;
  color: var(--db-danger-soft-text) !important;
}
html[data-theme] .w3-pale-green {
  background-color: var(--db-success-soft) !important;
  color: var(--db-success-soft-text) !important;
}
html[data-theme] .w3-pale-yellow {
  background-color: var(--db-warn-soft) !important;
  color: var(--db-warn-soft-text) !important;
}
html[data-theme] .w3-pale-blue {
  background-color: var(--db-accent-soft) !important;
  color: var(--db-accent-soft-text) !important;
}
/* Pale fills applied to inputs by JS validation keep readable text */
html[data-theme] input.w3-pale-red, html[data-theme] input.w3-pale-green,
html[data-theme] input.w3-red, html[data-theme] input.w3-green,
html[data-theme] input.w3-yellow {
  color: var(--db-text) !important;
}
html[data-theme] input.w3-red { background-color: var(--db-danger-soft) !important; }
html[data-theme] input.w3-green { background-color: var(--db-success-soft) !important; }
html[data-theme] input.w3-yellow { background-color: var(--db-warn-soft) !important; }
/* Text color utilities */
html[data-theme] .w3-text-grey, html[data-theme] .w3-text-gray,
html[data-theme] .w3-text-dark-grey, html[data-theme] .w3-text-dark-gray {
  color: var(--db-text-2) !important;
}
html[data-theme] .w3-text-blue, html[data-theme] .w3-text-teal,
html[data-theme] .w3-text-indigo, html[data-theme] .w3-text-light-blue {
  color: var(--db-accent) !important;
}
html[data-theme] .w3-text-red { color: var(--db-danger) !important; }
html[data-theme] .w3-text-green { color: var(--db-success) !important; }
html[data-theme] .w3-text-yellow, html[data-theme] .w3-text-orange { color: var(--db-warn) !important; }
html[data-theme] .w3-text-black { color: var(--db-text) !important; }
/* Borders */
html[data-theme] .w3-border { border-color: var(--db-border) !important; }
html[data-theme] .w3-border-white { border-color: var(--db-border) !important; }
html[data-theme] .w3-border-black { border-color: var(--db-border-2) !important; }
html[data-theme] .w3-border-light-blue, html[data-theme] .w3-border-blue { border-color: var(--db-accent) !important; }
html[data-theme] .w3-border-red { border-color: var(--db-danger) !important; }
html[data-theme] .w3-border-orange, html[data-theme] .w3-border-yellow { border-color: var(--db-warn) !important; }
html[data-theme] .w3-border-green { border-color: var(--db-success) !important; }

/* -------------------------------------------------- normalized elements */
/* Buttons: consistent radius, calm hover. RE.css forces #ccc/#000 hover
   with !important — replace with token hover; colored buttons keep their
   fill and just brighten. */
html[data-theme] .w3-button, html[data-theme] .w3-btn { border-radius: var(--db-radius); }
html[data-theme] .w3-button:hover {
  background-color: var(--db-surface-3) !important;
  color: var(--db-text) !important;
}
/* RE.css gives .w3-btn:hover a heavy black drop shadow
   (0 8px 16px rgba(0,0,0,.2), 0 6px 20px rgba(0,0,0,.19)). On dark surfaces
   that reads as dark blocky halos trailing the pointer across grid rows
   (the icon buttons in the payment-schedule rows carry .w3-btn). */
html[data-theme] .w3-btn:hover, html[data-theme] .w3-button:hover {
  box-shadow: var(--db-shadow) !important;
}
html[data-theme] .w3-button.w3-blue:hover, html[data-theme] .w3-button.w3-teal:hover,
html[data-theme] .w3-button.w3-indigo:hover {
  background-color: var(--db-accent-bg) !important;
  color: var(--db-accent-bg-text) !important;
  filter: brightness(1.1);
}
html[data-theme] .w3-button.w3-red:hover {
  background-color: var(--db-danger-bg) !important; color: #fff !important; filter: brightness(1.1);
}
html[data-theme] .w3-button.w3-green:hover {
  background-color: var(--db-success-bg) !important; color: #fff !important; filter: brightness(1.1);
}
html[data-theme] .w3-button.w3-yellow:hover, html[data-theme] .w3-button.w3-orange:hover {
  background-color: var(--db-warn-bg) !important; color: #fff !important; filter: brightness(1.1);
}
/* Inputs */
html[data-theme] .w3-input, html[data-theme] .w3-select,
html[data-theme] .w3-inputThin, html[data-theme] .w3-inputThinB,
html[data-theme] .inpLikeTxt, html[data-theme] .input-like-box,
html[data-theme] .w3-pill-input {
  background-color: var(--db-surface) !important;
  color: var(--db-text) !important;
  border-color: var(--db-border-2) !important;
  border-radius: var(--db-radius);
}
html[data-theme] .w3-input:focus, html[data-theme] .w3-select:focus {
  border-color: var(--db-accent) !important;
  box-shadow: 0 0 0 3px var(--db-accent-soft) !important;
}
html[data-theme] ::placeholder { color: var(--db-text-3); opacity: 1; }
/* Cards: themed shadow + a real border so separation survives dark bg */
html[data-theme] .w3-card, html[data-theme] .w3-card-2,
html[data-theme] .w3-card-4 {
  box-shadow: var(--db-shadow) !important;
  border: 1px solid var(--db-border);
  border-radius: var(--db-radius);
  background-color: var(--db-surface);
}
/* Tables */
html[data-theme] .w3-table, html[data-theme] .w3-table-all {
  background-color: var(--db-surface);
  color: var(--db-text);
  border-color: var(--db-border) !important;
}
html[data-theme] .w3-table-all tr { border-color: var(--db-border); }
html[data-theme] .w3-table-all tr:nth-child(odd) { background-color: var(--db-surface) !important; }
html[data-theme] .w3-table-all tr:nth-child(even) { background-color: var(--db-surface-2) !important; }
html[data-theme] .w3-hoverable tbody tr:hover, html[data-theme] .w3-ul.w3-hoverable li:hover {
  background-color: var(--db-surface-3) !important;
}
html[data-theme] .w3-striped tbody tr:nth-child(even) { background-color: var(--db-surface-2) !important; }
/* Modals + dropdowns */
html[data-theme] .w3-modal { background-color: var(--db-overlay) !important; }
html[data-theme] .w3-modal-content {
  background-color: var(--db-surface) !important;
  color: var(--db-text);
  border-radius: var(--db-radius-lg);
  box-shadow: var(--db-shadow-lg);
}
html[data-theme] .w3-dropdown-content {
  background-color: var(--db-surface) !important;
  color: var(--db-text) !important;
  box-shadow: var(--db-shadow-lg);
}
html[data-theme] .w3-bar-item.w3-button:hover { background-color: var(--db-surface-3) !important; }
/* Toggle switches (.switch/.slider, duplicated across pages) */
html[data-theme] .slider { background-color: var(--db-border-2) !important; }
html[data-theme] .slider:before { background-color: var(--db-surface) !important; }
html[data-theme] input:checked + .slider { background-color: var(--db-accent-bg) !important; }
/* i_Footer tool pills (light gradient in Original) */
html[data-theme] .tool-pill {
  background: var(--db-surface-2) !important;
  box-shadow: var(--db-shadow) !important;
  border: 1px solid var(--db-border);
}
/* Inline-styled legacy modals (style="background:white" in markup) */
html[data-theme] #dateModal, html[data-theme] #myModal > div {
  background-color: var(--db-surface) !important;
  border-color: var(--db-border) !important;
  color: var(--db-text) !important;
}
html[data-theme] #dateModal { max-width: 94vw; }
/* Inline JS-built status colors (style="color: red" spans, PAID/PAST DUE).
   NOTE: substring match — any future inline "background-color: red" would
   also trip these; prefer semantic classes for new code. */
html[data-theme="dark"] [style*="color: red"], html[data-theme="dark"] [style*="color:red"] { color: var(--db-danger) !important; }
html[data-theme="dark"] [style*="color:green"], html[data-theme="dark"] [style*="color: green"] { color: var(--db-success) !important; }
/* logon.php */
html[data-theme] .errMsg {
  background-color: var(--db-warn-soft) !important;
  color: var(--db-warn-soft-text) !important;
  border-radius: var(--db-radius);
}
/* Avatar upload drop zone (inline #f9f9f9 via markup + jQuery) */
html[data-theme="dark"] #avatarUploadArea {
  background-color: var(--db-surface-2) !important;
  border-color: var(--db-border-2) !important;
}
/* $-prefixed money inputs use a black-fill SVG background */
html[data-theme="dark"] .monyInput, html[data-theme="dark"] .monyInput2 { background-image: none !important; }

/* --------------------------------------------------- top bar + sidebar */
html[data-theme] .w3-bar.w3-top.w3-black {
  background-color: var(--db-topbar) !important;
  color: var(--db-topbar-text) !important;
}
html[data-theme] .db-topbar-company { color: var(--db-topbar-text); }
html[data-theme] .w3-overlay { background-color: var(--db-overlay); }

html[data-theme="dark"] #mySidebar { background: #1f1f1e; border-right-color: #333331; }
@media (max-width: 992px) {
  /* dark-on-dark: the open sidebar needs a stronger edge than the light shadow */
  html[data-theme="dark"] #mySidebar { box-shadow: 4px 0 32px rgba(0, 0, 0, .85); }
}
html[data-theme="dark"] .db-nav-item { color: #c9c9c4; }
html[data-theme="dark"] .db-nav-item i { color: #8f8f8a; }
html[data-theme="dark"] .db-nav-item:hover { background: #2c2c2a; color: #ececea; }
html[data-theme="dark"] .db-nav-item.db-active { background: #24314d; color: #a8c7fa; }
html[data-theme="dark"] .db-nav-item.db-active i { color: #a8c7fa; }
html[data-theme="dark"] .db-nav-label { color: #7c7c76; }
html[data-theme="dark"] .db-profile { background: #1f1f1e; border-top-color: #333331; }
html[data-theme="dark"] .db-profile:hover { background: #2c2c2a; }
html[data-theme="dark"] .db-profile-name { color: #ececea; }
html[data-theme="dark"] #myAccountBar {
  background: #262625; border-color: #3a3a37; box-shadow: var(--db-shadow-lg);
}
html[data-theme="dark"] .db-pop-head, html[data-theme="dark"] .db-pop-sec { border-bottom-color: #333331; }
html[data-theme="dark"] .db-pop-name { color: #ececea; }
html[data-theme="dark"] .db-pop-item { color: #d6d6d2; }
html[data-theme="dark"] .db-pop-item:hover { background: #303030; }
html[data-theme="dark"] .db-feat-row { color: #c9c9c4; }
html[data-theme="dark"] .db-feat-toggle:hover { color: #c9c9c4; }
html[data-theme="dark"] a.db-feat-link:hover { background: #303030; }
html[data-theme="dark"] a.db-feat-link:hover .db-feat-name,
html[data-theme="dark"] a.db-feat-link:hover i { color: #a8c7fa; }
html[data-theme="dark"] .db-chip-free { background: #333331; color: #a3a39e; }
html[data-theme="dark"] .db-chip-standard { background: #24314d; color: #a8c7fa; }
html[data-theme="dark"] .db-chip-pro { background: #322947; color: #cbb8f5; }
html[data-theme="dark"] .db-chip-on { background: #1e3226; color: #81c995; }
html[data-theme="dark"] .db-chip-off { background: #2c2c2a; color: #7c7c76; }
html[data-theme="dark"] .db-ai-tag { background: #322947; color: #cbb8f5; }
html[data-theme="dark"] .db-theme-seg button { background: #2c2c2a; border-color: #4a4a46; color: #c9c9c4; }
html[data-theme="dark"] .db-theme-seg button:hover { background: #333331; }
html[data-theme="dark"] .db-theme-seg button.db-theme-active {
  background: #24314d; border-color: #2f6fdc; color: #a8c7fa;
}

/* ----------------------------------------------------- My Tasks modal */
html[data-theme="dark"] #dbTasksModal { background: rgba(0, 0, 0, .6); }
html[data-theme="dark"] #dbTasksModal .db-modal-card { background: #262625; }
html[data-theme="dark"] .db-modal-head { border-bottom-color: #333331; color: #ececea; }
html[data-theme="dark"] .db-modal-close:hover { background: #333331; }
html[data-theme="dark"] .db-task-row { border-bottom-color: #2f2f2d; }
html[data-theme="dark"] .db-task-title { color: #ececea; }
html[data-theme="dark"] .db-task-done .db-task-title { color: #7c7c76; }
html[data-theme="dark"] .db-overdue { color: #f28b82; }
html[data-theme="dark"] .db-task-add input[type=text],
html[data-theme="dark"] .db-task-add input[type=date] {
  background: #2c2c2a; border-color: #4a4a46; color: #ececea;
}

/* ------------------------------------- global AskAI floating assistant */
html[data-theme="dark"] #askaiWin {
  background: var(--db-surface); color: var(--db-text);
  border-color: var(--db-border); box-shadow: var(--db-shadow-lg);
}
html[data-theme="dark"] .askai-w-head,
html[data-theme="dark"] .askai-w-tray {
  background: var(--db-surface-2); border-bottom-color: var(--db-border);
}
html[data-theme="dark"] .askai-w-title { color: var(--db-text); }
html[data-theme="dark"] .askai-w-logo { color: var(--db-accent); }
html[data-theme="dark"] .askai-w-tools button { color: var(--db-text-2); }
html[data-theme="dark"] .askai-w-tools button:hover { background: var(--db-surface-3); color: var(--db-text); }
html[data-theme="dark"] .askai-w-tools button.askai-act { background: var(--db-accent-soft); color: var(--db-accent-soft-text); }
html[data-theme="dark"] .askai-w-sep { background: var(--db-border-2); }
html[data-theme="dark"] .askai-w-tray b { color: var(--db-text); }
html[data-theme="dark"] .askai-w-msgs { background: var(--db-surface); }
html[data-theme="dark"] .askai-w-msgs .askai-assistant { background: var(--db-surface-3); color: var(--db-text); }
html[data-theme="dark"] .askai-w-msgs .askai-user { background: var(--db-accent-bg); color: var(--db-accent-bg-text); }
html[data-theme="dark"] .askai-w-msgs .askai-blocked {
  background: var(--db-warn-soft); color: var(--db-warn-soft-text); border-color: var(--db-warn-bg);
}
html[data-theme="dark"] .askai-w-foot { background: var(--db-surface); border-top-color: var(--db-border); }
html[data-theme="dark"] .askai-w-modes button {
  background: var(--db-surface-2); border-color: var(--db-border-2); color: var(--db-text-2);
}
html[data-theme="dark"] .askai-w-modes button.askai-act {
  background: var(--db-accent-soft); border-color: var(--db-accent-bg); color: var(--db-accent-soft-text);
}
html[data-theme="dark"] .askai-w-input {
  background: var(--db-surface-2); color: var(--db-text); border-color: var(--db-border-2);
}
html[data-theme="dark"] .askai-w-send { background: var(--db-accent-bg); color: var(--db-accent-bg-text); }
html[data-theme="dark"] .askai-w-quota.askai-quota-low,
html[data-theme="dark"] .askai-w-count.askai-count-warn { color: var(--db-danger); }
html[data-theme="dark"] #askaiFab { background: var(--db-accent-bg); color: var(--db-accent-bg-text); }

/* FuturePast: the assistant becomes a console window */
html[data-theme="dark"][data-flavor="futurepast"] #askaiWin {
  background:
    radial-gradient(circle at 20% 0%, rgba(0, 194, 255, .12), transparent 34%),
    linear-gradient(180deg, #08131f, #0a1725 58%, #08131f);
  border-color: rgba(62, 208, 255, .34);
}
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-head,
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-tray,
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-msgs,
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-foot {
  background: transparent; border-color: rgba(125, 226, 255, .22);
}
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-title { color: #7de2ff; letter-spacing: .5px; }
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-msgs .askai-assistant {
  background: rgba(4, 18, 30, .66); border: 1px solid rgba(125, 226, 255, .22); color: #d7f6ff;
}
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-modes button,
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-input {
  background: rgba(0, 151, 199, .13); border-color: rgba(125, 226, 255, .40); border-radius: 999px;
}
html[data-theme="dark"][data-flavor="futurepast"] .askai-w-send,
html[data-theme="dark"][data-flavor="futurepast"] #askaiFab {
  background: rgba(0, 151, 199, .30); border: 1px solid rgba(125, 226, 255, .55); color: #e7f8ff;
  box-shadow: 0 0 18px rgba(125, 226, 255, .28);
}

/* ------------------------------------------------------ jQuery UI skin */
html[data-theme="dark"] .ui-widget-content {
  background: var(--db-surface); color: var(--db-text); border-color: var(--db-border);
}
html[data-theme="dark"] .ui-widget { color: var(--db-text); }
html[data-theme="dark"] .ui-widget-header {
  background: var(--db-surface-2); color: var(--db-text); border-color: var(--db-border);
}
html[data-theme="dark"] .ui-dialog {
  background: var(--db-surface); border-color: var(--db-border); box-shadow: var(--db-shadow-lg);
}
html[data-theme="dark"] .ui-state-default,
html[data-theme="dark"] .ui-widget-content .ui-state-default {
  background: var(--db-surface-2); color: var(--db-text); border-color: var(--db-border-2);
}
html[data-theme="dark"] .ui-state-hover, html[data-theme="dark"] .ui-state-focus,
html[data-theme="dark"] .ui-widget-content .ui-state-hover {
  background: var(--db-surface-3); color: var(--db-text); border-color: var(--db-border-2);
}
html[data-theme="dark"] .ui-state-active,
html[data-theme="dark"] .ui-widget-content .ui-state-active,
html[data-theme="dark"] .ui-menu .ui-menu-item-wrapper.ui-state-active {
  background: var(--db-accent-soft); color: var(--db-accent-soft-text); border-color: var(--db-accent-bg);
}
html[data-theme="dark"] .ui-widget-overlay { background: #000; opacity: .55; }
html[data-theme="dark"] .ui-autocomplete { background: var(--db-surface); border-color: var(--db-border); }
/* Base-theme sprite icons are dark gray — invert so datepicker arrows show */
html[data-theme="dark"] .ui-icon { filter: invert(.8); }
html[data-theme="dark"] .ui-state-highlight,
html[data-theme="dark"] .ui-widget-content .ui-state-highlight {
  background: var(--db-warn-soft); color: var(--db-warn-soft-text); border-color: var(--db-warn-bg);
}
/* autocomplete secondary text / edit icons (CloseDeal + CRM custom menus) */
html[data-theme="dark"] .ui-autocomplete-name, html[data-theme="dark"] .ui-autocomplete-lease {
  color: var(--db-text-2);
}
html[data-theme="dark"] .ui-autocomplete-editicon:hover { color: var(--db-text); }
html[data-theme] .ui-dialog { max-width: 96vw; }
html[data-theme] .ui-corner-all { border-radius: var(--db-radius); }
/* sticky autocomplete headers (CloseDeal/CRM custom menus) */
html[data-theme="dark"] .ui-autocomplete-header {
  background: var(--db-surface-2) !important; border-color: var(--db-border) !important; color: var(--db-text) !important;
}

/* ------------------------------------------------------ DataTables skin */
html[data-theme="dark"] table.dataTable,
html[data-theme="dark"] table.dataTable tbody td {
  background-color: var(--db-surface); color: var(--db-text); border-color: var(--db-border);
}
html[data-theme="dark"] table.dataTable thead th, html[data-theme="dark"] table.dataTable thead td {
  background-color: var(--db-surface-2) !important;
  color: var(--db-text-2) !important;
  border-color: var(--db-border) !important;
}
html[data-theme="dark"] table.dataTable tbody tr { background-color: var(--db-surface); }
html[data-theme="dark"] table.dataTable.stripe tbody tr:nth-child(odd) td,
html[data-theme="dark"] table.dataTable.display tbody tr:nth-child(odd) td,
html[data-theme="dark"] table.dataTable tbody tr:nth-child(odd) td {
  background-color: var(--db-surface-2);
}
html[data-theme="dark"] table.dataTable.hover tbody tr:hover td,
html[data-theme="dark"] table.dataTable tbody tr:hover td {
  background-color: var(--db-surface-3);
}
html[data-theme="dark"] table.dataTable tbody tr.selected td,
html[data-theme="dark"] table.dataTable tbody tr.selected {
  background-color: var(--db-accent-soft) !important; color: var(--db-accent-soft-text) !important;
}
html[data-theme="dark"] .dataTables_wrapper,
html[data-theme="dark"] .dataTables_info, html[data-theme="dark"] .dataTables_filter,
html[data-theme="dark"] .dataTables_length, html[data-theme="dark"] .dt-info,
html[data-theme="dark"] .dt-search, html[data-theme="dark"] .dt-length {
  color: var(--db-text-2) !important;
}
html[data-theme="dark"] .dataTables_wrapper input, html[data-theme="dark"] .dataTables_wrapper select,
html[data-theme="dark"] div.dt-container input, html[data-theme="dark"] div.dt-container select {
  background-color: var(--db-surface) !important; color: var(--db-text) !important;
  border: 1px solid var(--db-border-2) !important; border-radius: var(--db-radius);
}
html[data-theme="dark"] .dt-scroll-head, html[data-theme="dark"] .dt-scroll-body,
html[data-theme="dark"] div.dtfh-floatingparent {
  border-color: var(--db-border) !important;
  background: var(--db-surface-2) !important;
}
html[data-theme="dark"] div.dt-button-collection {
  background-color: var(--db-surface) !important; border-color: var(--db-border) !important;
  box-shadow: var(--db-shadow-lg) !important;
}
html[data-theme="dark"] div.dt-button-collection .dt-button,
html[data-theme="dark"] div.dt-button-collection .dt-button span {
  background: var(--db-surface) !important; color: var(--db-text) !important;
}
html[data-theme="dark"] div.dt-button-collection .dt-button:hover,
html[data-theme="dark"] div.dt-button-collection .dt-button.dt-button-active {
  background: var(--db-surface-3) !important;
}

/* --------------------------------------------------- jquery-confirm skin */
html[data-theme="dark"] .jconfirm .jconfirm-box {
  background: var(--db-surface); color: var(--db-text); box-shadow: var(--db-shadow-lg);
}
html[data-theme="dark"] .jconfirm .jconfirm-box .jconfirm-title-c { color: var(--db-text); }
html[data-theme="dark"] .jconfirm .jconfirm-box .jconfirm-content { color: var(--db-text-2); }
html[data-theme="dark"] .jconfirm .jconfirm-box .jconfirm-buttons button.btn-default {
  background: var(--db-surface-2); color: var(--db-text);
}
html[data-theme] .jconfirm .jconfirm-box { max-width: 94vw !important; border-radius: var(--db-radius-lg); }

/* --------------------------- page: Deals / CloseDeal (Material skins) */
/* Their body/input rules are page-level; the prefixed selectors below
   out-specify them. Pale focus ring + white inputs covered above. */
html[data-theme="dark"] .select-caret, html[data-theme="dark"] .select-edit,
html[data-theme="dark"] .select-clear { color: var(--db-text-3); }
html[data-theme="dark"] .select-caret:hover, html[data-theme="dark"] .select-edit:hover,
html[data-theme="dark"] .select-clear:hover { color: var(--db-text); }
html[data-theme="dark"] .property-autocomplete, html[data-theme="dark"] .company-autocomplete {
  background: var(--db-surface); border-color: var(--db-border);
}
html[data-theme="dark"] .deal-green { color: var(--db-success) !important; }
html[data-theme="dark"] .deal-orange { color: var(--db-warn) !important; }
html[data-theme="dark"] .deal-red { color: var(--db-danger) !important; }

/* ---------------------------------------- page: Myaccount (dashboard) */
html[data-theme="dark"] .dashboard-nav, html[data-theme="dark"] .dashboard-section {
  background: var(--db-surface) !important; border-color: var(--db-border) !important;
  box-shadow: var(--db-shadow) !important;
}
html[data-theme="dark"] .dashboard-nav-item { color: var(--db-text-2) !important; }
html[data-theme="dark"] .dashboard-nav-item:hover { background: var(--db-surface-3) !important; }
html[data-theme="dark"] .dashboard-nav-item.active {
  background: var(--db-accent-soft) !important; color: var(--db-accent-soft-text) !important;
}
html[data-theme="dark"] .dashboard-section-header { border-color: var(--db-border) !important; color: var(--db-text) !important; }
html[data-theme="dark"] .dashboard-section label, html[data-theme="dark"] .dashboard-section p { color: var(--db-text-2) !important; }

/* -------------------------------------- page: Deals grid (p_OverviewGrid) */
html[data-theme="dark"] #dealsGridBar {
  background: var(--db-surface) !important; border-color: var(--db-border) !important;
}
html[data-theme="dark"] .dg-bar-btn,
html[data-theme="dark"] #dealsGridBarBtns > .dt-button,
html[data-theme="dark"] #dealsGridBarBtns > .w3-button,
html[data-theme="dark"] #dealsGridBarBtns > .dt-buttons > .dt-button,
html[data-theme="dark"] #dealsGridBarBtns > .dt-buttons > .w3-button {
  background: var(--db-surface) !important; color: var(--db-text-2) !important;
  border-color: var(--db-border-2) !important;
}
html[data-theme="dark"] .dg-bar-btn:hover,
html[data-theme="dark"] #dealsGridBarBtns > .dt-button:hover,
html[data-theme="dark"] #dealsGridBarBtns > .w3-button:hover,
html[data-theme="dark"] #dealsGridBarBtns > .dt-buttons > .dt-button:hover,
html[data-theme="dark"] #dealsGridBarBtns > .dt-buttons > .w3-button:hover {
  background: var(--db-surface-3) !important;
}
html[data-theme="dark"] #dealsOmni {
  background: var(--db-surface) !important; border-color: var(--db-border-2) !important;
}
html[data-theme="dark"] #dealsOmni input { background: transparent !important; color: var(--db-text) !important; }
html[data-theme="dark"] .dg-omni-token { background: var(--db-accent-soft) !important; color: var(--db-accent-soft-text) !important; }
html[data-theme="dark"] #dealsOmniSug, html[data-theme="dark"] #dealsOmniPanel {
  background: var(--db-surface) !important; border-color: var(--db-border) !important;
  box-shadow: var(--db-shadow-lg) !important; color: var(--db-text);
}
html[data-theme="dark"] #dealsOmniSug a, html[data-theme="dark"] #dealsOmniPanel a { color: var(--db-text-2); }
html[data-theme="dark"] #dealsOmniSug a:hover { background: var(--db-surface-3); }
html[data-theme="dark"] #dealsOmniPanel input, html[data-theme="dark"] #dealsOmniPanel select {
  background: var(--db-surface-2) !important; color: var(--db-text) !important; border-color: var(--db-border-2) !important;
}
html[data-theme="dark"] .dg-ex { background: var(--db-surface-3) !important; color: var(--db-text-2) !important; }
html[data-theme="dark"] .dg-omni-help { color: var(--db-text-2) !important; border-top-color: var(--db-border) !important; }
html[data-theme="dark"] .dg-pill-paid { background: var(--db-success-soft) !important; color: var(--db-success-soft-text) !important; }
html[data-theme="dark"] .dg-pill-imp { background: var(--db-surface-3) !important; color: var(--db-text-2) !important; }
html[data-theme="dark"] mark.dg-hl { background: var(--db-warn-soft) !important; color: var(--db-warn-soft-text) !important; }
html[data-theme="dark"] #dealsHiddenHint, html[data-theme="dark"] .match-hint {
  background: var(--db-warn-soft) !important; border-color: var(--db-warn-bg) !important; color: var(--db-warn-soft-text) !important;
}
html[data-theme="dark"] #tblDeals_wrapper table.dataTable thead th {
  background: var(--db-surface-2) !important; color: var(--db-text-2) !important; border-color: var(--db-border) !important;
}
html[data-theme="dark"] .today-change-scrollbox { background: var(--db-surface-2) !important; border-color: var(--db-border) !important; }

/* ---------------------------------------- page: changelog (p_changelog) */
html[data-theme="dark"] #clTable tr.cl-child > td {
  background: var(--db-surface-2) !important; border-left-color: var(--db-accent-bg) !important;
}
html[data-theme="dark"] .cl-badge, html[data-theme="dark"] .cl-tag, html[data-theme="dark"] .cl-status {
  background: var(--db-surface-3) !important; color: var(--db-text-2) !important;
}
html[data-theme="dark"] .cl-badge.feature { background: var(--db-accent-soft) !important; color: var(--db-accent-soft-text) !important; }
html[data-theme="dark"] .cl-badge.bugfix, html[data-theme="dark"] .cl-badge.security { background: var(--db-danger-soft) !important; color: var(--db-danger-soft-text) !important; }
html[data-theme="dark"] .cl-badge.change { background: #322947 !important; color: #cbb8f5 !important; }
html[data-theme="dark"] .cl-empty { background: var(--db-surface-2) !important; border-color: var(--db-border-2) !important; color: var(--db-text-2) !important; }
html[data-theme="dark"] .cl-filters input, html[data-theme="dark"] .cl-filters select,
html[data-theme="dark"] .cl-comment-add textarea, html[data-theme="dark"] .cl-tag-add input,
html[data-theme="dark"] .cl-status-select {
  background: var(--db-surface) !important; color: var(--db-text) !important; border-color: var(--db-border-2) !important;
}
/* tag/status variants keep their semantic hue (wip/deployed/etc.) */
html[data-theme="dark"] .cl-tag.wip, html[data-theme="dark"] .cl-status.admin { background: var(--db-warn-soft) !important; color: var(--db-warn-soft-text) !important; }
html[data-theme="dark"] .cl-tag.deployed, html[data-theme="dark"] .cl-tag.ready-for-prod { background: var(--db-success-soft) !important; color: var(--db-success-soft-text) !important; }
html[data-theme="dark"] .cl-tag.stage-only, html[data-theme="dark"] .cl-status.manager { background: var(--db-accent-soft) !important; color: var(--db-accent-soft-text) !important; }
html[data-theme="dark"] .cl-tag.admin-only, html[data-theme="dark"] .cl-status.global { background: var(--db-danger-soft) !important; color: var(--db-danger-soft-text) !important; }

/* ----------------------------------------------------- page: CRM Hub */
/* Consistent Material palette → grouped token remaps. */
html[data-theme="dark"] #crmWrap { color: var(--db-text-2); }
html[data-theme="dark"] #crmWrap .crm-toolbar, html[data-theme="dark"] #crmWrap .crm-sec,
html[data-theme="dark"] #crmWrap .crm-card, html[data-theme="dark"] #crmWrap .crm-modal,
html[data-theme="dark"] #crmWrap .crm-panel, html[data-theme="dark"] #crmWrap .crm-upsell {
  background: var(--db-surface); border-color: var(--db-border); color: var(--db-text-2);
}
html[data-theme="dark"] #crmWrap .crm-col, html[data-theme="dark"] #crmWrap .crm-stage-row {
  background: var(--db-surface-2); border-color: var(--db-border);
}
html[data-theme="dark"] #crmWrap .crm-card-title, html[data-theme="dark"] #crmWrap h3,
html[data-theme="dark"] #crmWrap h4, html[data-theme="dark"] #crmWrap .crm-panel-head b,
html[data-theme="dark"] #crmWrap .crm-title, html[data-theme="dark"] #crmWrap .crm-task-title,
html[data-theme="dark"] #crmWrap .crm-act-title, html[data-theme="dark"] #crmWrap .crm-dash-detail-item {
  color: var(--db-text);
}
html[data-theme="dark"] #crmWrap .crm-dash-detail-head, html[data-theme="dark"] #crmWrap .crm-card-company,
html[data-theme="dark"] #crmWrap .crm-col-total, html[data-theme="dark"] #crmWrap .crm-tl-legend {
  color: var(--db-text-2);
}
html[data-theme="dark"] #crmWrap .crm-dash-row:hover { background: var(--db-surface-3); }
html[data-theme="dark"] #crmWrap .askai-quota-low, html[data-theme="dark"] #crmWrap .askai-count-warn {
  color: var(--db-danger) !important;
}
html[data-theme="dark"] #crmWrap .crm-btn, html[data-theme="dark"] #crmWrap .crm-tab,
html[data-theme="dark"] #crmWrap .crm-pill {
  background: var(--db-surface-2); color: var(--db-text-2); border-color: var(--db-border-2);
}
html[data-theme="dark"] #crmWrap .crm-btn:hover, html[data-theme="dark"] #crmWrap .crm-tab:hover {
  background: var(--db-surface-3);
}
html[data-theme="dark"] #crmWrap .crm-btn-primary {
  background: var(--db-accent-bg); color: var(--db-accent-bg-text); border-color: var(--db-accent-bg);
}
html[data-theme="dark"] #crmWrap .crm-tab.crm-active, html[data-theme="dark"] #crmWrap .crm-pill.crm-active {
  background: var(--db-accent-soft); color: var(--db-accent-soft-text); border-color: var(--db-accent-bg);
}
html[data-theme="dark"] #crmWrap .crm-banner {
  background: var(--db-accent-soft); border-color: var(--db-accent-bg); color: var(--db-accent-soft-text);
}
/* the 'acting as' banner is JS-built with inline colors — needs !important */
html[data-theme="dark"] #crmWrap .crm-banner[style] {
  background: var(--db-danger-soft) !important; border-color: var(--db-danger-bg) !important;
  color: var(--db-danger-soft-text) !important;
}
/* JS-built digest config box + dashboard bar tracks carry inline light fills */
html[data-theme="dark"] #crmDigestConfig {
  background: var(--db-surface-2) !important; border-color: var(--db-border) !important;
}
html[data-theme="dark"] #crmWrap div[style*="#f1f3f4"], html[data-theme="dark"] #crmWrap span[style*="#f1f3f4"] {
  background-color: var(--db-surface-3) !important;
}
html[data-theme="dark"] #crmWrap .crm-chip, html[data-theme="dark"] #crmWrap .crm-badge,
html[data-theme="dark"] #crmWrap .crm-info, html[data-theme="dark"] #crmWrap .crm-act-icon {
  background: var(--db-accent-soft); color: var(--db-accent-soft-text);
}
html[data-theme="dark"] #crmWrap .crm-field input, html[data-theme="dark"] #crmWrap .crm-field select,
html[data-theme="dark"] #crmWrap .crm-field textarea, html[data-theme="dark"] #crmWrap input[style],
html[data-theme="dark"] #crmWrap select[style], html[data-theme="dark"] #crmWrap .askai-input {
  background: var(--db-surface-2) !important; color: var(--db-text) !important; border-color: var(--db-border-2) !important;
}
html[data-theme="dark"] #crmWrap .crm-task-row, html[data-theme="dark"] #crmWrap .crm-feed-item,
html[data-theme="dark"] #crmWrap .crm-act-row, html[data-theme="dark"] #crmWrap .crm-dash-detail-item {
  border-color: var(--db-border);
}
html[data-theme="dark"] #crmWrap .crm-act-row:hover { background: var(--db-surface-2); }
html[data-theme="dark"] #crmWrap table.crm-tbl th { color: var(--db-text-3); border-color: var(--db-border) !important; }
html[data-theme="dark"] #crmWrap table.crm-tbl td { border-color: var(--db-border); }
html[data-theme="dark"] #crmWrap .crm-tbl tr:hover td { background: var(--db-surface-2); }
html[data-theme="dark"] #crmWrap .crm-lock-pill, html[data-theme="dark"] #crmWrap .crm-readonly-note,
html[data-theme="dark"] #crmWrap .askai-blocked {
  background: var(--db-warn-soft); color: var(--db-warn-soft-text); border-color: var(--db-warn-bg);
}
html[data-theme="dark"] #crmWrap .crm-msg .ok { background: var(--db-success-soft); color: var(--db-success-soft-text); }
html[data-theme="dark"] #crmWrap .crm-msg .fail { background: var(--db-danger-soft); color: var(--db-danger-soft-text); }
html[data-theme="dark"] #crmWrap .askai-assistant { background: var(--db-surface-3); color: var(--db-text); }
html[data-theme="dark"] #crmWrap .askai-user { background: var(--db-accent-bg); }
html[data-theme="dark"] #crmWrap .askai-foot, html[data-theme="dark"] #crmWrap .crm-panel-head,
html[data-theme="dark"] #crmWrap .crm-digest-head { border-color: var(--db-border); }
html[data-theme="dark"] #crmWrap .crm-tl-wrap::before { background: var(--db-border); }
html[data-theme="dark"] #crmWrap .crm-tl-card { background: var(--db-surface); }
html[data-theme="dark"] #crmWrap .crm-card-locked { background: var(--db-surface-2); }
html[data-theme="dark"] #crmWrap .crm-ac-type-owner { background: var(--db-success-soft); color: var(--db-success-soft-text); }
html[data-theme="dark"] #crmWrap .crm-ac-type-tenant, html[data-theme="dark"] .crm-comp-ac .crm-ac-type-tenant { background: var(--db-accent-soft); color: var(--db-accent-soft-text); }
html[data-theme="dark"] #crmWrap .crm-ac-type-cobroker, html[data-theme="dark"] .crm-comp-ac .crm-ac-type-cobroker { background: var(--db-warn-soft); color: var(--db-warn-soft-text); }
html[data-theme="dark"] .crm-prop-ac .crm-ac-type-owner { background: var(--db-success-soft); color: var(--db-success-soft-text); }
html[data-theme="dark"] #crmFooterBar .crm-fb-inner, html[data-theme="dark"] #crmFooterBar .crm-fb-panel {
  background: var(--db-surface) !important; border-color: var(--db-border) !important; color: var(--db-text-2);
}
html[data-theme="dark"] #crmFooterBar .crm-fb-plan {
  background: var(--db-surface-2); border-color: var(--db-border-2); color: var(--db-text-2);
}
html[data-theme="dark"] #crmFooterBar .crm-fb-viewas select {
  background: var(--db-surface-2); color: var(--db-text); border-color: var(--db-border-2);
}
html[data-theme="dark"] #crmFooterBar .crm-fb-tier { background: var(--db-surface); border-color: var(--db-border); color: var(--db-text-2); }
html[data-theme="dark"] #crmFooterBar .crm-fb-tier.crm-fb-current { background: var(--db-accent-soft); border-color: var(--db-accent-bg); }
html[data-theme="dark"] #crmFooterBar.crm-fb-preview .crm-fb-inner { background: var(--db-danger-soft) !important; }
html[data-theme="dark"] #crmFooterBar .crm-fb-previewing {
  background: var(--db-danger-soft); color: var(--db-danger-soft-text); border-color: var(--db-danger-bg);
}
html[data-theme="dark"] #crmFooterBar .crm-fb-current-flag {
  background: var(--db-accent-soft); color: var(--db-accent-soft-text);
}

/* ==========================================================================
   My Account embeds, popups and report pages (dark) — from the code sweep
   of dware/user.php, p_edit_salesagent.php, visibility panels, schedules,
   notifications, disbursement health, usage analytics, FVC, CoStar report.
   ========================================================================== */

/* ---- resources/project/user_feature_visibility.php + report visibility panel (dware/report_visi ---- */
/* --- Features tab: Feature Visibility panel (user_feature_visibility.php) --- */
html[data-theme="dark"] #userFeatureVisibility .feature-toggle-row {
  background: var(--db-surface-2);
  border-color: var(--db-border);
}
html[data-theme="dark"] #userFeatureVisibility .feature-toggle-title { color: var(--db-text); }
html[data-theme="dark"] #userFeatureVisibility .feature-toggle-meta,
html[data-theme="dark"] #userFeatureVisibility .user-tier-override-label { color: var(--db-text-2); }
html[data-theme="dark"] #userFeatureVisibility .user-tier-override {
  background: var(--db-surface);
  color: var(--db-text);
  border-color: var(--db-border-2);
}
html[data-theme="dark"] #userFeatureVisibility .feature-msg.ok { background: var(--db-success-soft); color: var(--db-success-soft-text); }
html[data-theme="dark"] #userFeatureVisibility .feature-msg.warn { background: var(--db-warn-soft); color: var(--db-warn-soft-text); }
html[data-theme="dark"] #userFeatureVisibility .feature-msg.fail { background: var(--db-danger-soft); color: var(--db-danger-soft-text); }
/* --- Report Visibility tab: grid body (report_visibility.php) --- */
html[data-theme="dark"] .report-visibility-grid {
  background: var(--db-surface);
  color: var(--db-text);
}
html[data-theme="dark"] .report-visibility-grid td { border-color: var(--db-border); }
html[data-theme="dark"] .report-visibility-grid td.salesperson-name {
  background: var(--db-surface);
  color: var(--db-text);
}
html[data-theme="dark"] .grid-container { border-color: var(--db-border); }
html[data-theme="dark"] .report-visibility-grid th {
  background: var(--db-surface-2);
  color: var(--db-text);
  border-color: var(--db-border);
}
html[data-theme="dark"] .report-visibility-grid th.report-col { background: var(--db-surface-3); }
html[data-theme="dark"] .report-visibility-grid th.report-subcol { background: var(--db-surface-2); }
html[data-theme="dark"] .report-visibility-grid tbody tr:hover { background: var(--db-surface-3); }
html[data-theme="dark"] .report-column-action,
html[data-theme="dark"] .report-bulk-button {
  background: var(--db-surface-2);
  border-color: var(--db-border-2);
  color: var(--db-text-2);
}
html[data-theme="dark"] .report-column-action:hover,
html[data-theme="dark"] .report-bulk-button:hover {
  background: var(--db-surface-3);
  border-color: var(--db-border-2);
  color: var(--db-text);
}
html[data-theme="dark"] .report-bulk-label { color: var(--db-text-2); }
html[data-theme="dark"] .report-type-badge.badge-static {
  background: var(--db-accent-soft);
  border-color: var(--db-accent);
  color: var(--db-accent-soft-text);
}
html[data-theme="dark"] .report-type-badge.badge-dynamic {
  background: var(--db-warn-soft);
  border-color: var(--db-warn-bg);
  color: var(--db-warn-soft-text);
}
html[data-theme="dark"] pre[style*="#f5f5f5"] {
  background: var(--db-surface-2) !important;
  color: var(--db-text) !important;
}

/* ---- resources/project/event_notifications_embed.php + public/p_payment_duplicate_monitor.php ( ---- */
/* Events/Schedules embed panel headers: replace light gradient band */
html[data-theme="dark"] .section-gradient {
  background: var(--db-surface-2);
  border: 1px solid var(--db-border);
}
/* Event Notifications grid: borders + header row */
html[data-theme="dark"] #eventNotifications .grid th,
html[data-theme="dark"] #eventNotifications .grid td {
  border-color: var(--db-border);
}
html[data-theme="dark"] #eventNotifications .grid th {
  background: var(--db-surface-2);
  color: var(--db-text-2);
}
/* Delivery Log / Manage Types dialog tables (JS-built inside jconfirm) */
html[data-theme="dark"] .jconfirm .grid th,
html[data-theme="dark"] .jconfirm .grid td {
  border: 1px solid var(--db-border);
  padding: 8px;
}
html[data-theme="dark"] .jconfirm .grid th {
  background: var(--db-surface-2);
  color: var(--db-text-2);
}
html[data-theme="dark"] #evLogTbl tbody tr.selected td {
  background: var(--db-accent-soft);
  color: var(--db-accent-soft-text);
}
/* bare JS-built buttons (Edit/Delete/Log in grid, Details in log dialog) */
html[data-theme="dark"] #eventNotifications .grid td button,
html[data-theme="dark"] .jconfirm .grid td button {
  background: var(--db-surface-2);
  color: var(--db-text);
  border: 1px solid var(--db-border-2);
  border-radius: var(--db-radius);
  cursor: pointer;
}
html[data-theme="dark"] #eventNotifications .grid td button:hover,
html[data-theme="dark"] .jconfirm .grid td button:hover {
  background: var(--db-surface-3);
}
/* Summary Detail box in Delivery Log dialog (inline style="background:#f9f9f9") */
html[data-theme="dark"] #evLogDetail {
  background: var(--db-surface-2) !important;
  border-color: var(--db-border) !important;
  color: var(--db-text);
}
/* New/Edit Notification dialog form controls */
html[data-theme="dark"] #dlgEvBody input,
html[data-theme="dark"] #dlgEvBody select {
  background: var(--db-surface-2);
  color: var(--db-text);
  border: 1px solid var(--db-border-2);
  border-radius: var(--db-radius);
  padding: 6px;
}
/* #ev_user_id border is set inline via jQuery .css() — must beat the style attribute */
html[data-theme="dark"] #ev_user_id {
  border-color: var(--db-border-2) !important;
}
/* Payment duplicate monitor: status badges */
html[data-theme="dark"] .pdm-badge.processing { background: var(--db-warn-soft); color: var(--db-warn-soft-text); }
html[data-theme="dark"] .pdm-badge.duplicate,
html[data-theme="dark"] .pdm-badge.error { background: var(--db-danger-soft); color: var(--db-danger-soft-text); }
html[data-theme="dark"] .pdm-badge.completed { background: var(--db-accent-soft); color: var(--db-accent-soft-text); }
html[data-theme="dark"] .pdm-badge.cleaned { background: var(--db-success-soft); color: var(--db-success-soft-text); }
/* Payment duplicate monitor: bundle details panel, KV tiles, empty states */
html[data-theme="dark"] .pdm-details {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] .pdm-kv {
  background: var(--db-surface-2);
  border-color: var(--db-border);
}
html[data-theme="dark"] .pdm-kv label {
  color: var(--db-text-3);
}
html[data-theme="dark"] .pdm-empty {
  background: var(--db-surface-2);
  border-color: var(--db-border-2);
  color: var(--db-text-2);
}

/* ---- public/p_disbursement_health.php + public/p_usage_analytics.php ---- */
/* --- Disbursement Health: filters + comment box --- */
html[data-theme="dark"] .dh-filters input[type=text],
html[data-theme="dark"] .dh-filters select,
html[data-theme="dark"] .dh-comment-add textarea {
  background-color: var(--db-surface);
  color: var(--db-text);
  border-color: var(--db-border-2);
}
html[data-theme="dark"] .dh-filters label { color: var(--db-text-2); }
html[data-theme="dark"] #dhTable tr.dh-child > td {
  background: var(--db-surface-2);
  border-left-color: var(--db-accent-bg);
}
/* --- badges + timeline tags --- */
html[data-theme="dark"] .dh-badge.safe { background: var(--db-success-soft); color: var(--db-success-soft-text); }
html[data-theme="dark"] .dh-badge.review,
html[data-theme="dark"] .dh-tl-tag.error { background: var(--db-danger-soft); color: var(--db-danger-soft-text); }
html[data-theme="dark"] .dh-badge.missing,
html[data-theme="dark"] .dh-tl-tag.warning { background: var(--db-warn-soft); color: var(--db-warn-soft-text); }
html[data-theme="dark"] .dh-badge.hiddenTag,
html[data-theme="dark"] .dh-tl-tag { background: var(--db-surface-3); color: var(--db-text-2); }
html[data-theme="dark"] .dh-tl-tag.payment { background: var(--db-accent-soft); color: var(--db-accent-soft-text); }
html[data-theme="dark"] .dh-tl-tag.salesperson { background: #322947; color: #cbb8f5; }
/* --- empty state + key/value cards --- */
html[data-theme="dark"] .dh-empty {
  background: var(--db-surface-2);
  border-color: var(--db-border-2);
  color: var(--db-text-2);
}
html[data-theme="dark"] .dh-kv {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] .dh-kv label,
html[data-theme="dark"] .dh-comment .dh-comment-meta,
html[data-theme="dark"] .dh-timeline .dh-tl-ts { color: var(--db-text-3); }
/* --- comments thread, icon button, timeline rail --- */
html[data-theme="dark"] .dh-comment { border-bottom-color: var(--db-border); }
html[data-theme="dark"] .dh-icon-btn { color: var(--db-accent); }
html[data-theme="dark"] .dh-icon-btn.has-comments { color: var(--db-warn); }
html[data-theme="dark"] .dh-close { color: var(--db-text-3); }
html[data-theme="dark"] .dh-timeline li { border-left-color: var(--db-border-2); }
html[data-theme="dark"] .dh-timeline li.cause {
  border-left-color: var(--db-warn);
  background: var(--db-warn-soft);
}
/* --- Usage Analytics: base text --- */
html[data-theme="dark"] #uaWrap { color: var(--db-text-2); }
html[data-theme="dark"] #uaWrap .ua-ticker span { color: var(--db-text-2); }
html[data-theme="dark"] #uaWrap .ua-sec h4 { color: var(--db-text); }
html[data-theme="dark"] #uaWrap .ua-live,
html[data-theme="dark"] #uaWrap .ua-note,
html[data-theme="dark"] #uaWrap .ua-card .ua-lbl,
html[data-theme="dark"] #uaWrap .ua-ticker .ua-dotsep { color: var(--db-text-3); }
html[data-theme="dark"] #uaWrap .ua-live .ua-dot { background: var(--db-success); }
/* --- tabs + sub-tab pills --- */
html[data-theme="dark"] #uaWrap .ua-tab,
html[data-theme="dark"] #uaWrap .ua-subtab {
  background: var(--db-surface-2);
  color: var(--db-text-2);
  border-color: var(--db-border-2);
}
html[data-theme="dark"] #uaWrap .ua-tab:hover { background: var(--db-surface-3); }
html[data-theme="dark"] #uaWrap .ua-tab.ua-active {
  background: var(--db-accent-bg);
  color: var(--db-accent-bg-text);
  border-color: var(--db-accent-bg);
}
html[data-theme="dark"] #uaWrap .ua-subtab.ua-active {
  background: var(--db-accent-soft);
  color: var(--db-accent-soft-text);
  border-color: var(--db-accent-bg);
}
/* --- stat cards + sections --- */
html[data-theme="dark"] #uaWrap .ua-card,
html[data-theme="dark"] #uaWrap .ua-sec {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] #uaWrap .ua-card .ua-num { color: var(--db-accent); }
html[data-theme="dark"] #uaWrap .ua-ticker { border-top-color: var(--db-border); }
html[data-theme="dark"] #uaWrap .ua-drill { border-top-color: var(--db-border); }
/* --- charts: tooltip, bar rows, tracks --- */
html[data-theme="dark"] #uaWrap .ua-chart .ua-col .ua-tip {
  background: var(--db-surface-3);
  color: var(--db-text);
  border: 1px solid var(--db-border-2);
}
html[data-theme="dark"] #uaWrap .ua-bar-row.ua-click:hover { background: var(--db-surface-3); }
html[data-theme="dark"] #uaWrap .ua-bar-row .ua-bar-track { background: var(--db-surface-3); }
html[data-theme="dark"] #uaWrap .ua-bar-row .ua-bar-fill { background: var(--db-accent-bg); }
/* --- tables + links --- */
html[data-theme="dark"] #uaWrap table.ua-tbl th {
  color: var(--db-text-3);
  border-bottom-color: var(--db-border-2);
}
html[data-theme="dark"] #uaWrap table.ua-tbl td { border-bottom-color: var(--db-border); }
html[data-theme="dark"] #uaWrap table.ua-tbl tr:hover td { background: var(--db-surface-3); }
html[data-theme="dark"] #uaWrap a.ua-link { color: var(--db-accent); }
/* --- pills, chips, raw button, select --- */
html[data-theme="dark"] #uaWrap .ua-pill-new,
html[data-theme="dark"] #uaWrap .ua-chip {
  background: var(--db-accent-soft);
  color: var(--db-accent-soft-text);
}
html[data-theme="dark"] #uaWrap .ua-pill-legacy {
  background: var(--db-surface-3);
  color: var(--db-text-2);
}
html[data-theme="dark"] #uaWrap .ua-raw-btn {
  background: var(--db-surface-2);
  color: var(--db-text-2);
  border-color: var(--db-border-2);
}
html[data-theme="dark"] #uaWrap .ua-raw-btn:hover { background: var(--db-surface-3); }
html[data-theme="dark"] #uaWrap select.ua-select {
  background: var(--db-surface);
  color: var(--db-text);
  border-color: var(--db-border-2);
}
/* --- jconfirm popups built by usage analytics (inline styles → !important) --- */
html[data-theme="dark"] .jconfirm .jconfirm-content pre {
  background: var(--db-surface-2) !important;
  border-color: var(--db-border) !important;
  color: var(--db-text-2) !important;
}
html[data-theme="dark"] .jconfirm .jconfirm-content [style*="#80868b"] { color: var(--db-text-3) !important; }

/* ---- Feature Version Control tab (dware/version_preferences_ui.php, dware/admin_version_managem ---- */
html[data-theme="dark"] .version-preferences-section {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] .version-preferences-header {
  background: var(--db-surface-2); /* kills the light gradient */
  border-bottom-color: var(--db-border);
}
html[data-theme="dark"] .version-preferences-title,
html[data-theme="dark"] .version-preference-name {
  color: var(--db-text);
}
html[data-theme="dark"] .version-preference-item {
  border-bottom-color: var(--db-border);
}
html[data-theme="dark"] .version-preference-description,
html[data-theme="dark"] .version-loading {
  color: var(--db-text-2);
}
html[data-theme="dark"] .version-toggle-label { color: var(--db-text-2); }
html[data-theme="dark"] .version-toggle-label.active { color: var(--db-accent); }
html[data-theme="dark"] .version-slider { background-color: var(--db-border-2); }
html[data-theme="dark"] .version-slider:before { background-color: var(--db-surface); }
html[data-theme="dark"] .version-toggle input:checked + .version-slider { background-color: var(--db-accent-bg); }
html[data-theme="dark"] .version-reset-btn { background: var(--db-danger-bg); color: #fff; }
html[data-theme="dark"] .version-reset-btn:hover { background: var(--db-danger-bg); filter: brightness(1.15); }
html[data-theme="dark"] .version-error {
  background: var(--db-danger-soft);
  color: var(--db-danger-soft-text);
}
html[data-theme="dark"] .version-preference-info div[style*="#c62828"] {
  color: var(--db-danger) !important;
}
html[data-theme="dark"] .admin-version-section {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] .admin-version-header {
  background: var(--db-danger-bg); /* flat token red replaces the light gradient; white title stays readable */
  border-bottom-color: var(--db-border);
}
html[data-theme="dark"] .admin-page-item { border-bottom-color: var(--db-border); }
html[data-theme="dark"] .admin-page-name { color: var(--db-text); }
html[data-theme="dark"] .admin-page-description,
html[data-theme="dark"] .admin-override-reason { color: var(--db-text-2); }
html[data-theme="dark"] .admin-override-by { color: var(--db-text-3); }
html[data-theme="dark"] .admin-page-status.override {
  background: var(--db-danger-soft);
  color: var(--db-danger-soft-text);
  border-color: var(--db-danger-bg);
}
html[data-theme="dark"] .admin-page-status.normal {
  background: var(--db-success-soft);
  color: var(--db-success-soft-text);
  border-color: var(--db-success-bg);
}
html[data-theme="dark"] .admin-btn.force-new { background: var(--db-accent-bg); color: var(--db-accent-bg-text); }
html[data-theme="dark"] .admin-btn.force-legacy { background: var(--db-warn-bg); color: #fff; }
html[data-theme="dark"] .admin-btn.remove-override { background: var(--db-danger-bg); color: #fff; }
html[data-theme="dark"] #costarFeatureControl .fvc-tab {
  background: var(--db-surface-2);
  color: var(--db-text-2);
  border-color: var(--db-border-2);
}
html[data-theme="dark"] #costarFeatureControl .fvc-tab:hover { background: var(--db-surface-3); }
html[data-theme="dark"] #costarFeatureControl .fvc-tab.fvc-active {
  background: var(--db-accent-bg);
  color: var(--db-accent-bg-text);
  border-color: var(--db-accent-bg);
}
html[data-theme="dark"] #costarFeatureControl .fvc-filters {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] #costarFeatureControl .fvc-filters label,
html[data-theme="dark"] #costarFeatureControl .fvc-note,
html[data-theme="dark"] #costarFeatureControl .fvc-notier { color: var(--db-text-3); }
html[data-theme="dark"] #costarFeatureControl .fvc-filters select,
html[data-theme="dark"] #costarFeatureControl .fvc-filters input {
  background: var(--db-surface-2);
  color: var(--db-text);
  border-color: var(--db-border-2);
}
html[data-theme="dark"] #costarFeatureControl .costar-feature-enabled,
html[data-theme="dark"] #costarFeatureControl .costar-setup-ok { color: var(--db-success); }
html[data-theme="dark"] #costarFeatureControl .costar-feature-disabled { color: var(--db-text-3); }
html[data-theme="dark"] #costarFeatureControl .costar-setup-warn { color: var(--db-warn); }
html[data-theme="dark"] #costarFeatureControl .costar-feature-msg.ok {
  background: var(--db-success-soft);
  color: var(--db-success-soft-text);
}
html[data-theme="dark"] #costarFeatureControl .costar-feature-msg.warn {
  background: var(--db-warn-soft);
  color: var(--db-warn-soft-text);
}
html[data-theme="dark"] #costarFeatureControl .costar-feature-msg.fail {
  background: var(--db-danger-soft);
  color: var(--db-danger-soft-text);
}
html[data-theme="dark"] #costarFeatureControl .costar-tier-free {
  background: var(--db-surface-3);
  color: var(--db-text-2);
}
html[data-theme="dark"] #costarFeatureControl .costar-tier-standard {
  background: var(--db-accent-soft);
  color: var(--db-accent-soft-text);
}
html[data-theme="dark"] #costarFeatureControl .costar-tier-pro {
  background: var(--db-warn-soft);
  color: var(--db-warn-soft-text);
}
html[data-theme="dark"] #costarFeatureControl .costar-ai-badge {
  background: var(--db-success-soft);
  color: var(--db-success-soft-text);
}
html[data-theme="dark"] #aiBudgetSection .aib-card {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] #aiBudgetSection .aib-card h5 { color: var(--db-text-3); }
html[data-theme="dark"] #aiBudgetSection .aib-num { color: var(--db-accent); }
html[data-theme="dark"] #aiBudgetSection .aib-row label { color: var(--db-text-2); }
html[data-theme="dark"] #aiBudgetSection input[type=number],
html[data-theme="dark"] #aiBudgetSection input[type=text],
html[data-theme="dark"] #aiBudgetSection input[type=email] {
  background: var(--db-surface-2);
  color: var(--db-text);
  border-color: var(--db-border-2);
}
html[data-theme="dark"] #aiBudgetSection table { background: var(--db-surface); }
html[data-theme="dark"] #aiBudgetSection table th {
  color: var(--db-text-3);
  border-bottom-color: var(--db-border-2);
}
html[data-theme="dark"] #aiBudgetSection table td { border-bottom-color: var(--db-border); }
html[data-theme="dark"] #aiBudgetSection .aib-test-out {
  background: var(--db-surface-2);
  border-color: var(--db-border);
}
html[data-theme="dark"] #aiBudgetSection .aib-kill {
  background: var(--db-danger-soft);
  border-color: var(--db-danger-bg);
  color: var(--db-danger-soft-text);
}
html[data-theme="dark"] #aiBudgetSection .aib-kill.aib-ok {
  background: var(--db-success-soft);
  border-color: var(--db-success-bg);
  color: var(--db-success-soft-text);
}
html[data-theme="dark"] #costarFeatureControl [style*="#137333"] { color: var(--db-success) !important; }
html[data-theme="dark"] #costarFeatureControl [style*="#a50e0e"] { color: var(--db-danger) !important; }
html[data-theme="dark"] #costarFeatureControl [style*="#e8710a"] { color: var(--db-warn) !important; }
html[data-theme="dark"] #costarFeatureControl [style*="#80868b"] { color: var(--db-text-3) !important; }
html[data-theme="dark"] #costarTierSection tbody tr[style*="background"] {
  background: var(--db-warn-soft) !important;
}

/* ---- dware/user.php (Account Overview embed, User Management grids, User Logs dialog) + public/ ---- */
/* User info band (version-preferences shell reused by user.php) */
html[data-theme="dark"] .version-preferences-section {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] .version-preferences-header {
  background: var(--db-surface-2);
  border-bottom-color: var(--db-border);
}
html[data-theme="dark"] .version-preferences-title { color: var(--db-text); }
html[data-theme="dark"] .version-preference-item { border-bottom-color: var(--db-border); }
/* Section header gradient band (User Management) */
html[data-theme="dark"] .section-gradient {
  background: linear-gradient(var(--db-surface-2), var(--db-surface-3));
}
/* User Logs dialog: deal links + origin row highlight */
html[data-theme="dark"] a.deal-link { color: var(--db-accent); }
html[data-theme="dark"] .deal-origin {
  background: var(--db-warn-soft) !important;
  color: var(--db-warn-soft-text) !important;
}
/* w3-blue-grey caption bars (User Logs dialog headers) — RE.css uses !important */
html[data-theme="dark"] .w3-blue-grey, html[data-theme="dark"] .w3-blue-gray {
  background-color: var(--db-surface-3) !important;
  color: var(--db-text) !important;
}
/* User Logs dialog: inline gray divider */
html[data-theme="dark"] .w3-border-top[style*="#9e9e9e"] {
  border-top-color: var(--db-border-2) !important;
}
/* Avatar images: inline #ddd borders */
html[data-theme="dark"] #myAccountAvatar,
html[data-theme="dark"] #avatar1 {
  border-color: var(--db-border-2) !important;
}
/* jconfirm delete warning: inline #d32f2f text */
html[data-theme="dark"] .jconfirm-content [style*="#d32f2f"] {
  color: var(--db-danger) !important;
}
/* Modify Sales Agent dialog title bar (jQuery .css inline #1a73e8) */
html[data-theme="dark"] .ui-dialog[aria-describedby="modEditSalesagent"] .ui-dialog-titlebar {
  background: var(--db-accent-bg) !important;
  color: var(--db-accent-bg-text) !important;
}
/* Modify Sales Agent: Deal Visibility permission matrix */
html[data-theme="dark"] .permission-panel,
html[data-theme="dark"] .permission-matrix-wrap {
  background: var(--db-surface);
  border-color: var(--db-border);
}
html[data-theme="dark"] .permission-matrix th,
html[data-theme="dark"] .permission-matrix td {
  border-bottom-color: var(--db-border);
}
html[data-theme="dark"] .permission-matrix th {
  background: var(--db-surface-2);
  color: var(--db-text-2);
}
html[data-theme="dark"] .permission-mini-button {
  background: var(--db-surface-2);
  border-color: var(--db-border-2);
  color: var(--db-text);
}
html[data-theme="dark"] .permission-mini-button:hover {
  background: var(--db-surface-3);
  border-color: var(--db-border-2);
}
/* Modify Sales Agent: visibility list scrollbar */
html[data-theme="dark"] #visibilityList {
  scrollbar-color: var(--db-border-2) var(--db-surface-2);
}
html[data-theme="dark"] #visibilityList::-webkit-scrollbar-track { background: var(--db-surface-2); }
html[data-theme="dark"] #visibilityList::-webkit-scrollbar-thumb { background: var(--db-border-2); }
html[data-theme="dark"] #visibilityList::-webkit-scrollbar-thumb:hover { background: var(--db-text-3); }
/* Modify Sales Agent: tab keyboard-focus state (theme covers hover/active only) */
html[data-theme="dark"] .dashboard-nav-item:focus {
  background: var(--db-surface-3) !important;
  color: var(--db-text) !important;
}
/* nav overflow scrollbar thumb: rgba(60,64,67,.2) is invisible on dark */
html[data-theme="dark"] .dashboard-nav::-webkit-scrollbar-thumb {
  background-color: var(--db-border-2);
}
/* Modify Sales Agent: .w3-slider toggles (Features / Report Visibility tabs) */
html[data-theme="dark"] .w3-slider { background-color: var(--db-border-2); }
html[data-theme="dark"] .w3-slider:before { background-color: var(--db-surface); }
html[data-theme="dark"] input:checked + .w3-slider { background-color: var(--db-success-bg); }
html[data-theme="dark"] input:focus + .w3-slider { box-shadow: 0 0 0 3px var(--db-accent-soft); }

/* ---- resources/project/costar_powerbroker_submissions.php (CoStar Power Broker Submissions, AJA ---- */
/* CoStar Power Broker Submissions — yellow notice box */
html[data-theme="dark"] .report-wrap .notice {
  background: var(--db-warn-soft);
  border-color: var(--db-warn-bg);
  color: var(--db-warn-soft-text);
}
html[data-theme="dark"] .report-wrap .notice strong { color: inherit; }
/* CoStar report meta line */
html[data-theme="dark"] .report-wrap .meta { color: var(--db-text-2); }
html[data-theme="dark"] .report-wrap .period-static { color: var(--db-text); }
/* CoStar quarter/year pickers */
html[data-theme="dark"] .report-wrap .period-picker select {
  background: var(--db-surface);
  color: var(--db-text);
  border-color: var(--db-border-2);
}
/* CoStar summary table: borders, clickable-row hover, row action icon */
html[data-theme="dark"] .report-wrap th,
html[data-theme="dark"] .report-wrap td { border-color: var(--db-border-2); }
html[data-theme="dark"] .report-wrap .costar-summary-row.is-clickable:hover td {
  background: var(--db-surface-3);
}
html[data-theme="dark"] .report-wrap .costar-row-action { color: var(--db-accent); }
/* CoStar 'View records' dialog (jquery-confirm content, outside .report-wrap) */
html[data-theme="dark"] .costar-detail-wrap { border-color: var(--db-border); }
html[data-theme="dark"] .costar-detail-grid th,
html[data-theme="dark"] .costar-detail-grid td { border-color: var(--db-border); }
html[data-theme="dark"] .costar-detail-grid td:first-child {
  background: var(--db-surface-2);
  color: var(--db-text);
}
html[data-theme="dark"] .costar-detail-grid .review-cell {
  background: var(--db-danger-soft);
  color: var(--db-danger-soft-text);
}
html[data-theme="dark"] .costar-empty-detail {
  background: var(--db-surface-2);
  border-color: var(--db-border);
  color: var(--db-text-2);
}

/* ---- resources/project/admin_schedules_embed.php + dware/scheduled_report_events.php (Schedules ---- */
html[data-theme="dark"] #schedulesAdminSection .section-gradient {
  background: var(--db-surface-2);
}
html[data-theme="dark"] #schedulesAdminSection .grid th,
html[data-theme="dark"] #schedulesAdminSection .grid td {
  border-color: var(--db-border);
}
html[data-theme="dark"] #schedulesAdminSection .grid th {
  background: var(--db-surface-2);
  color: var(--db-text);
}
html[data-theme="dark"] .scheduled-event-log-filters {
  background: var(--db-surface-2);
  border-color: var(--db-border);
}
html[data-theme="dark"] .scheduled-event-log-filters label {
  color: var(--db-text-2);
}
html[data-theme="dark"] .scheduled-event-log-filters input,
html[data-theme="dark"] .scheduled-event-log-filters select {
  background-color: var(--db-surface);
  color: var(--db-text);
  border-color: var(--db-border-2);
}
html[data-theme="dark"] .scheduled-event-detail-btn {
  background: var(--db-surface-3);
  border-color: var(--db-border-2);
  color: var(--db-text);
}
html[data-theme="dark"] table.scheduled-event-log-grid th,
html[data-theme="dark"] table.scheduled-event-log-grid td {
  border-color: var(--db-border);
}
html[data-theme="dark"] table.scheduled-event-log-grid th {
  background: var(--db-surface-2);
  color: var(--db-text);
}
html[data-theme="dark"] table.scheduled-event-log-grid td[style*="#1e7e34"] { color: var(--db-success) !important; }
html[data-theme="dark"] table.scheduled-event-log-grid td[style*="#b00020"] { color: var(--db-danger) !important; }
html[data-theme="dark"] table.scheduled-event-log-grid td[style*="#555"] { color: var(--db-text-2) !important; }
html[data-theme="dark"] .reports-header {
  background: var(--db-surface-2) !important;
  border-color: var(--db-border) !important;
}
html[data-theme="dark"] .reports-header h4,
html[data-theme="dark"] .reports-header h4 i {
  color: var(--db-text) !important;
}
html[data-theme="dark"] .reports-header p {
  color: var(--db-text-2) !important;
}
html[data-theme="dark"] .reports-table-container {
  background: var(--db-surface) !important;
  border-color: var(--db-border) !important;
  box-shadow: var(--db-shadow) !important;
}
html[data-theme="dark"] #tblReports thead tr,
html[data-theme="dark"] #tblReports thead th {
  background: var(--db-surface-2) !important;
  color: var(--db-text) !important;
}
html[data-theme="dark"] #tblReports td {
  border-bottom: 1px solid var(--db-border);
}
html[data-theme="dark"] #dlgBody input:not([type="checkbox"]),
html[data-theme="dark"] #dlgBody select,
html[data-theme="dark"] #dlgBody textarea,
html[data-theme="dark"] #wizardBody input:not([type="checkbox"]),
html[data-theme="dark"] #wizardBody select,
html[data-theme="dark"] #wizardBody textarea,
html[data-theme="dark"] #copyBody select,
html[data-theme="dark"] #rp_project_id,
html[data-theme="dark"] #rp_report_file,
html[data-theme="dark"] #rp_rargs_template,
html[data-theme="dark"] #rp_type {
  background-color: var(--db-surface-2) !important;
  color: var(--db-text) !important;
  border-color: var(--db-border-2) !important;
}
html[data-theme="dark"] .edit-radio-option,
html[data-theme="dark"] .wiz-radio-option {
  background: var(--db-surface-2) !important;
  border-color: var(--db-border-2) !important;
}
html[data-theme="dark"] .edit-radio-option.selected,
html[data-theme="dark"] .wiz-radio-option.selected {
  background: var(--db-accent-soft) !important;
  border-color: var(--db-accent) !important;
}
html[data-theme="dark"] .edit-option-desc,
html[data-theme="dark"] .wiz-option-desc,
html[data-theme="dark"] .edit-option-help,
html[data-theme="dark"] .wiz-option-help,
html[data-theme="dark"] #dlgBody [style*="rgb(102, 102, 102)"],
html[data-theme="dark"] #wizardBody [style*="rgb(102, 102, 102)"] {
  color: var(--db-text-2) !important;
}
html[data-theme="dark"] .edit-option-help[style*="rgb(40, 167, 69)"],
html[data-theme="dark"] .wiz-option-help[style*="rgb(40, 167, 69)"] {
  color: var(--db-success) !important;
}
html[data-theme="dark"] #edit_date_config,
html[data-theme="dark"] #wiz_date_config,
html[data-theme="dark"] #wiz_invoice_days_container,
html[data-theme="dark"] .jconfirm-content [style*="#f8f9fa"] {
  background: var(--db-surface-2) !important;
  border-color: var(--db-border) !important;
}
html[data-theme="dark"] #edit_preview,
html[data-theme="dark"] #wiz_preview,
html[data-theme="dark"] .jconfirm-content [style*="#e3f2fd"] {
  background: var(--db-accent-soft) !important;
  border-left-color: var(--db-accent) !important;
  color: var(--db-accent-soft-text) !important;
}
html[data-theme="dark"] .jconfirm-content [style*="#1976d2"] {
  color: var(--db-accent-soft-text) !important;
}
html[data-theme="dark"] #copyBody [style*="#666"] {
  color: var(--db-text-2) !important;
}
html[data-theme="dark"] #copyBody [style*="#eee"] {
  border-top-color: var(--db-border) !important;
}
html[data-theme="dark"] .jconfirm-content div[style*="#f7f7f7"] {
  background: var(--db-surface-2) !important;
  border-color: var(--db-border) !important;
  color: var(--db-text) !important;
}
html[data-theme="dark"] .jconfirm-content label[style*="#495057"],
html[data-theme="dark"] .jconfirm-content h4[style*="#495057"] {
  color: var(--db-text) !important;
}
html[data-theme="dark"] .jconfirm-content [style*="#6c757d"] {
  color: var(--db-text-2) !important;
}
html[data-theme="dark"] .jconfirm-content i[style*="#28a745"] {
  color: var(--db-success) !important;
}

/* ==========================================================================
   FuturePast — sci-fi console flavor of Dark (modeled on the Email Provider
   Control Center skin in css/control-center.css). Activated as
   data-theme="dark" + data-flavor="futurepast", so every dark rule above
   applies first; this section retargets the tokens and adds the flavor's
   signature moves: ocean-navy gradient + scanlines, cyan glow borders,
   pill buttons that lift on hover, letterspaced cyan headings.
   ========================================================================== */
html[data-theme="dark"][data-flavor="futurepast"] {
  --db-bg: #08131f;
  --db-surface: #0d2032;
  --db-surface-2: #0f2438;
  --db-surface-3: #143049;
  --db-text: #e7f8ff;
  --db-text-2: #a9dbeb;
  --db-text-3: #6f9fb4;
  --db-border: rgba(125, 226, 255, .22);
  --db-border-2: rgba(125, 226, 255, .40);
  --db-accent: #7de2ff;
  --db-accent-bg: rgba(0, 151, 199, .30);
  --db-accent-bg-text: #e7f8ff;
  --db-accent-soft: rgba(0, 151, 199, .18);
  --db-accent-soft-text: #8edcff;
  --db-danger: #ff7b8a;
  --db-danger-bg: rgba(184, 62, 62, .40);
  --db-danger-soft: rgba(184, 62, 62, .22);
  --db-danger-soft-text: #ffd6db;
  --db-success: #6dff9f;
  --db-success-bg: rgba(49, 164, 98, .45);
  --db-success-soft: rgba(49, 164, 98, .20);
  --db-success-soft-text: #d8ffe5;
  --db-warn: #ffd36c;
  --db-warn-bg: rgba(255, 149, 0, .38);
  --db-warn-soft: rgba(255, 211, 108, .14);
  --db-warn-soft-text: #fff0ca;
  --db-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 6px 16px rgba(0, 46, 69, .18);
  --db-shadow-lg: 0 20px 48px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .04);
  --db-topbar: #050e17;
  --db-topbar-text: #9edff4;
  --db-overlay: rgba(3, 12, 22, .8);
  --db-radius: 10px;
  --db-radius-lg: 14px;
}
/* signature backdrop: radial cyan glow + 135° navy gradient */
html[data-theme="dark"][data-flavor="futurepast"] body {
  background:
    radial-gradient(circle at 18% 0%, rgba(0, 194, 255, .13), transparent 40%),
    linear-gradient(135deg, #08131f, #0f2438 62%, #122b3d) fixed !important;
}
/* CRT scanlines drifting over everything (the Control Center's ::before) */
html[data-theme="dark"][data-flavor="futurepast"] body::before {
  content: "";
  position: fixed;
  inset: -12px 0;
  background: repeating-linear-gradient(0deg,
    rgba(255, 255, 255, .022) 0, rgba(255, 255, 255, .022) 1px,
    transparent 1px, transparent 8px);
  pointer-events: none;
  z-index: 2147480000;
  animation: dbfpScanline 4s linear infinite;
}
@keyframes dbfpScanline {
  from { transform: translateY(-10px); }
  to { transform: translateY(10px); }
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme="dark"][data-flavor="futurepast"] body::before { animation: none; }
}
/* headings glow cyan with the Control Center's letterspacing */
html[data-theme="dark"][data-flavor="futurepast"] h1,
html[data-theme="dark"][data-flavor="futurepast"] h2,
html[data-theme="dark"][data-flavor="futurepast"] h3,
html[data-theme="dark"][data-flavor="futurepast"] h4,
html[data-theme="dark"][data-flavor="futurepast"] h5 {
  color: #7de2ff;
  letter-spacing: .5px;
}
/* pill buttons: translucent cyan fill, bright border, lift + glow on hover */
html[data-theme="dark"][data-flavor="futurepast"] .w3-button,
html[data-theme="dark"][data-flavor="futurepast"] .w3-btn {
  border: 1px solid rgba(125, 226, 255, .55) !important;
  border-radius: 999px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 6px 16px rgba(0, 46, 69, .16);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
html[data-theme="dark"][data-flavor="futurepast"] .w3-button:hover,
html[data-theme="dark"][data-flavor="futurepast"] .w3-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 226, 255, .78) !important;
  /* !important so it beats the base .w3-btn:hover shadow reset above */
  box-shadow: 0 0 0 3px rgba(125, 226, 255, .12), inset 0 1px 0 rgba(255, 255, 255, .07), 0 8px 20px rgba(0, 46, 69, .22) !important;
}
html[data-theme="dark"][data-flavor="futurepast"] .w3-button.w3-green,
html[data-theme="dark"][data-flavor="futurepast"] .w3-button.w3-green:hover { border-color: rgba(126, 255, 183, .55) !important; }
html[data-theme="dark"][data-flavor="futurepast"] .w3-button.w3-red,
html[data-theme="dark"][data-flavor="futurepast"] .w3-button.w3-red:hover { border-color: rgba(255, 136, 136, .55) !important; }
/* inputs: pill, translucent cyan wells, glow focus ring */
html[data-theme="dark"][data-flavor="futurepast"] .w3-input,
html[data-theme="dark"][data-flavor="futurepast"] .w3-select,
html[data-theme="dark"][data-flavor="futurepast"] .w3-pill-input {
  background-color: rgba(0, 151, 199, .13) !important;
  border-color: rgba(125, 226, 255, .40) !important;
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
html[data-theme="dark"][data-flavor="futurepast"] .w3-input:focus,
html[data-theme="dark"][data-flavor="futurepast"] .w3-select:focus {
  background-color: rgba(0, 151, 199, .22) !important;
  border-color: rgba(125, 226, 255, .80) !important;
  box-shadow: 0 0 0 3px rgba(125, 226, 255, .12), inset 0 1px 0 rgba(255, 255, 255, .06) !important;
}
/* cards + modals: translucent navy panels with the inset top light */
html[data-theme="dark"][data-flavor="futurepast"] .w3-card,
html[data-theme="dark"][data-flavor="futurepast"] .w3-card-2,
html[data-theme="dark"][data-flavor="futurepast"] .w3-card-4 {
  background-color: rgba(4, 18, 30, .54);
  border-color: rgba(125, 226, 255, .22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03) !important;
  border-radius: 12px;
}
html[data-theme="dark"][data-flavor="futurepast"] .w3-modal-content {
  background:
    radial-gradient(circle at 20% 0%, rgba(0, 194, 255, .12), transparent 34%),
    linear-gradient(180deg, #08131f, #0a1725 58%, #08131f) !important;
  border: 1px solid rgba(62, 208, 255, .34);
}
/* sidebar + profile menu go full console */
html[data-theme="dark"][data-flavor="futurepast"] #mySidebar {
  background: linear-gradient(180deg, #0a1725, #0a1a2a);
  border-right-color: rgba(125, 226, 255, .28);
}
html[data-theme="dark"][data-flavor="futurepast"] .db-nav-item { color: #a9dbeb; border-radius: 999px; }
html[data-theme="dark"][data-flavor="futurepast"] .db-nav-item i { color: #6f9fb4; }
html[data-theme="dark"][data-flavor="futurepast"] .db-nav-item:hover { background: rgba(0, 151, 199, .16); color: #effdff; }
html[data-theme="dark"][data-flavor="futurepast"] .db-nav-item.db-active {
  background: linear-gradient(135deg, rgba(0, 183, 255, .22), rgba(50, 255, 217, .14));
  color: #effdff; border: 1px solid rgba(125, 226, 255, .7);
}
html[data-theme="dark"][data-flavor="futurepast"] .db-nav-item.db-active i { color: #7de2ff; }
html[data-theme="dark"][data-flavor="futurepast"] .db-nav-label { color: #7de2ff; letter-spacing: 1px; }
html[data-theme="dark"][data-flavor="futurepast"] .db-profile {
  background: #0a1725; border-top-color: rgba(125, 226, 255, .28);
}
html[data-theme="dark"][data-flavor="futurepast"] .db-profile:hover { background: rgba(0, 151, 199, .14); }
html[data-theme="dark"][data-flavor="futurepast"] .db-profile-name { color: #e7f8ff; }
html[data-theme="dark"][data-flavor="futurepast"] #myAccountBar {
  background: linear-gradient(180deg, #0a1725, #0a1a2a);
  border-color: rgba(62, 208, 255, .40);
  box-shadow: 0 20px 48px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .04);
}
html[data-theme="dark"][data-flavor="futurepast"] .db-pop-head,
html[data-theme="dark"][data-flavor="futurepast"] .db-pop-sec { border-bottom-color: rgba(125, 226, 255, .18); }
html[data-theme="dark"][data-flavor="futurepast"] .db-pop-name { color: #e7f8ff; }
html[data-theme="dark"][data-flavor="futurepast"] .db-pop-label { color: #8edcff; letter-spacing: 1px; }
html[data-theme="dark"][data-flavor="futurepast"] .db-pop-item { color: #d7f6ff; }
html[data-theme="dark"][data-flavor="futurepast"] .db-pop-item:hover { background: rgba(0, 151, 199, .16); }
html[data-theme="dark"][data-flavor="futurepast"] .db-feat-row { color: #a9dbeb; }
html[data-theme="dark"][data-flavor="futurepast"] a.db-feat-link:hover { background: rgba(0, 151, 199, .16); }
html[data-theme="dark"][data-flavor="futurepast"] a.db-feat-link:hover .db-feat-name,
html[data-theme="dark"][data-flavor="futurepast"] a.db-feat-link:hover i { color: #7de2ff; }
html[data-theme="dark"][data-flavor="futurepast"] .db-feat-toggle > i { color: #7de2ff; }
html[data-theme="dark"][data-flavor="futurepast"] .db-chip,
html[data-theme="dark"][data-flavor="futurepast"] .db-count {
  border: 1px solid rgba(125, 226, 255, .40);
}
html[data-theme="dark"][data-flavor="futurepast"] .db-theme-seg button {
  background: rgba(6, 24, 38, .72); border-color: rgba(125, 226, 255, .26);
  color: #a9dbeb; border-radius: 999px;
}
html[data-theme="dark"][data-flavor="futurepast"] .db-theme-seg button.db-theme-active {
  background: linear-gradient(135deg, rgba(0, 183, 255, .22), rgba(50, 255, 217, .14));
  border-color: rgba(125, 226, 255, .7); color: #effdff;
}
/* tables: cyan console headers */
html[data-theme="dark"][data-flavor="futurepast"] th,
html[data-theme="dark"][data-flavor="futurepast"] table.dataTable thead th {
  color: #8edcff !important;
  letter-spacing: .45px;
}
/* thin cyan scrollbars, site-wide (the .cc-scroll treatment) */
html[data-theme="dark"][data-flavor="futurepast"] * {
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 226, 255, .45) rgba(8, 24, 38, .72);
}
html[data-theme="dark"][data-flavor="futurepast"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"][data-flavor="futurepast"] ::-webkit-scrollbar-track { background: rgba(8, 24, 38, .72); }
html[data-theme="dark"][data-flavor="futurepast"] ::-webkit-scrollbar-thumb {
  border: 2px solid transparent; border-radius: 999px;
  background: rgba(125, 226, 255, .45); background-clip: padding-box;
}
/* top bar: deep navy with a faint cyan seam */
html[data-theme="dark"][data-flavor="futurepast"] .w3-bar.w3-top.w3-black {
  border-bottom: 1px solid rgba(125, 226, 255, .25);
}
/* My Tasks modal joins the console */
html[data-theme="dark"][data-flavor="futurepast"] #dbTasksModal .db-modal-card {
  background:
    radial-gradient(circle at 20% 0%, rgba(0, 194, 255, .12), transparent 34%),
    linear-gradient(180deg, #08131f, #0a1725 58%, #08131f);
  border: 1px solid rgba(62, 208, 255, .34);
}
html[data-theme="dark"][data-flavor="futurepast"] .db-task-add input[type=text],
html[data-theme="dark"][data-flavor="futurepast"] .db-task-add input[type=date] {
  background: rgba(0, 151, 199, .13); border-color: rgba(125, 226, 255, .40); border-radius: 999px;
}

/* --------------------------------------------------------- print guard */
/* Never print dark backgrounds, whatever the theme. The selector list must
   repeat (at equal-or-greater specificity) every dark rule that paints a
   surface, because both sides use !important and this block loads last. */
@media print {
  html[data-theme] body, html[data-theme] .w3-white, html[data-theme] .w3-light-grey,
  html[data-theme] .w3-grey, html[data-theme] .w3-gray, html[data-theme] .w3-dark-grey,
  html[data-theme] .w3-black,
  html[data-theme] .w3-card, html[data-theme] .w3-card-2, html[data-theme] .w3-card-4,
  html[data-theme] table, html[data-theme] tr, html[data-theme] td, html[data-theme] th,
  html[data-theme] table.dataTable thead th, html[data-theme] table.dataTable tbody td,
  html[data-theme] input, html[data-theme] select, html[data-theme] textarea,
  html[data-theme] .w3-input, html[data-theme] .w3-select,
  html[data-theme] input.w3-red, html[data-theme] input.w3-green, html[data-theme] input.w3-yellow,
  html[data-theme] .w3-table-all tr:nth-child(odd), html[data-theme] .w3-table-all tr:nth-child(even),
  html[data-theme] .w3-striped tbody tr:nth-child(even),
  html[data-theme] #mySidebar, html[data-theme] .dashboard-nav, html[data-theme] .dashboard-section,
  html[data-theme] #dealsGridBar {
    background: #fff !important;
    color: #000 !important;
    border-color: #ccc !important;
    box-shadow: none !important;
  }
  /* FuturePast rules carry two attributes (higher specificity), so its
     surfaces need their own equal-specificity reset here */
  html[data-theme="dark"][data-flavor="futurepast"] body,
  html[data-theme="dark"][data-flavor="futurepast"] .w3-input,
  html[data-theme="dark"][data-flavor="futurepast"] .w3-select,
  html[data-theme="dark"][data-flavor="futurepast"] .w3-card,
  html[data-theme="dark"][data-flavor="futurepast"] .w3-card-2,
  html[data-theme="dark"][data-flavor="futurepast"] .w3-card-4,
  html[data-theme="dark"][data-flavor="futurepast"] .w3-modal-content {
    background: #fff !important;
    color: #000 !important;
    border-color: #ccc !important;
    box-shadow: none !important;
  }
  html[data-theme="dark"][data-flavor="futurepast"] body::before { content: none; }
  html[data-theme="dark"][data-flavor="futurepast"] th,
  html[data-theme="dark"][data-flavor="futurepast"] table.dataTable thead th { color: #000 !important; }
}
