/* ============================================================
   TradeRail — My Day + Dashboard Dark Theme Override
   Matches Customer Hub gold standard palette.
   Overrides: pr419_myday_engine.css, pr366_owner_dashboard.css,
              rebuild_features.css myday-* classes,
              pr_ui_1d_home_redesign.js injected pui1d-* styles
   Dark palette:
     Page bg        #141310
     Card surface   #1e1c19
     Elevated       #252220
     Border         #2a2520
     Border-strong  #3a3530
     Text primary   #f1f5f9
     Text secondary #94a3b8
     Text muted     #64748b
     Orange accent  #FF6B00
     Orange hover   #e55f00
   ============================================================ */

/* ── 1. CSS variable override — remaps root vars used by My Day ── */
/* Scoped to home + myday + dashboard containers so we don't break
   every module on the page. These vars control the light-mint
   backgrounds (#f4f7f6), light borders (#d8e8e5/#eef4f3), and
   dark-teal text (#1a2e2b) used throughout. */

.home-wrap,
.pr419-wrap,
.pr366-dash-wrap,
[data-tr-page="home"],
[data-tr-page="myday"],
#myday-root,
#home-root,
.pui1d-home {
  --bg:    #141310;
  --white: #1e1c19;
  --tx:    #f1f5f9;
  --tx-md: #94a3b8;
  --tx-lt: #64748b;
  --bd:    #2a2520;
  --bd-lt: #3a3530;
  --card-bg: #1e1c19;
  --navy: #f1f5f9;
}

/* ── 2. PR419 My Day Engine ─────────────────────────────────────── */

.pr419-wrap {
  background: #141310;
  color: #f1f5f9;
}

.pr419-greeting {
  background: #1e1c19;
  border-bottom: 1px solid #2a2520;
}
.pr419-greeting-title { color: #f1f5f9; }
.pr419-greeting-role  { background: #FF6B00; color: #ffffff; }

.pr419-trai-strip {
  background: #252220;
  border-color: #FF6B00;
}
.pr419-trai-text { color: #94a3b8; }
.pr419-trai-skeleton {
  background: #252220;
  border-color: #3a3530;
}
.pr419-trai-skeleton::after {
  background: linear-gradient(90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.06) 50%,
    rgba(255,255,255,0) 100%);
}

.pr419-tabs {
  background: #1e1c19;
  border-bottom: 1px solid #2a2520;
}
.pr419-tab { color: #64748b; }
.pr419-tab.active { color: #FF6B00; border-bottom-color: #FF6B00; }
.pr419-tab-count { color: #64748b; }

.pr419-offline-banner {
  background: #2d1515;
  border-bottom-color: #dc2626;
  color: #fca5a5;
}

.pr419-section-hdr {
  color: #64748b;
  border-bottom: 1px solid #2a2520;
}
.pr419-section-count { color: #64748b; }
.pr419-section-empty { color: #64748b; }

.pr419-sort-bar {
  background: #252220;
  border-color: #2a2520;
  color: #94a3b8;
}

.pr419-card {
  background: #1e1c19;
  border: 1px solid #2a2520;
}
.pr419-card-title  { color: #f1f5f9; }
.pr419-card-meta   { color: #64748b; }
.pr419-card-amount { color: #f1f5f9; }

.pr419-state-overdue   { background: #2a1515; border-color: #7f1d1d; }
.pr419-state-overdue::before { background: #dc2626; }
.pr419-state-active    { background: #1e1c19; border-color: #2a2520; }
.pr419-state-active::before  { background: #FF6B00; }
.pr419-state-blocker   { background: #2a1515; border-color: #7f1d1d; }
.pr419-state-blocker::before { background: #dc2626; }
.pr419-state-attention { background: #251f10; border-color: #78350f; }
.pr419-state-attention::before { background: #f59e0b; }
.pr419-state-sent-back { background: #251f10; border-color: #78350f; }
.pr419-state-sent-back::before { background: #f59e0b; }
.pr419-state-delegated { background: #141d2a; border-color: #1e3a5f; }
.pr419-state-delegated::before { background: #3b82f6; }
.pr419-state-snoozed   { background: #1e1c19; border-color: #3a3530; }
.pr419-state-snoozed::before  { background: #64748b; }
.pr419-state-done      { background: #111e14; border-color: #14532d; }
.pr419-state-done::before     { background: #16a34a; }

.pr419-pill-overdue  { background: #7f1d1d; color: #fca5a5; }
.pr419-pill-active   { background: #431407; color: #fb923c; }
.pr419-pill-attention{ background: #451a03; color: #fbbf24; }

.pr419-btn-secondary {
  background: #252220;
  color: #f1f5f9;
  border: 1px solid #3a3530;
}
.pr419-btn-muted {
  background: #252220;
  color: #64748b;
  border: 1px solid #2a2520;
}

.pr419-done-row {
  background: #111e14;
  border-color: #14532d;
}
.pr419-done-row-title { color: #f1f5f9; }
.pr419-done-row-meta  { color: #4ade80; }

.pr419-expand-row {
  background: #1e1c19;
  border-color: #3a3530;
  color: #64748b;
}

.pr419-allclear {
  background: #111e14;
  border-color: #14532d;
}
.pr419-allclear-title { color: #4ade80; }
.pr419-allclear-text  { color: #64748b; }

.pr419-sendback-input {
  background: #252220;
  border-color: #3a3530;
  color: #f1f5f9;
}

.pr419-age          { color: #64748b; }
.pr419-snooze-count { color: #64748b; }

/* ── 3. rebuild_features.css — myday-* classes ──────────────────── */

.myday-group {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
}
.myday-group-hdr {
  background: #252220 !important;
  border-bottom-color: #2a2520 !important;
}
.myday-group-hdr h4 { color: #f1f5f9 !important; }

.myday-group.overdue .myday-group-hdr {
  background: #2a1515 !important;
  border-bottom-color: #7f1d1d !important;
}
.myday-group.overdue .myday-group-hdr .ct { background: #dc2626 !important; }
.myday-group.amber .myday-group-hdr {
  background: #251f10 !important;
  border-bottom-color: #78350f !important;
}
.myday-group.amber .myday-group-hdr .ct { background: #d97706 !important; }

.myday-group-empty { color: #64748b !important; }

.myday-stat {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
}
.myday-stat .v { color: #f1f5f9 !important; }
.myday-stat .l { color: #64748b !important; }
.myday-stat.over .v   { color: #f87171 !important; }
.myday-stat.amber .v  { color: #fbbf24 !important; }
.myday-stat.teal .v   { color: #FF6B00 !important; }

.myday-item {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
}
.myday-item.snoozed { background: #252220 !important; }
.myday-item-nm      { color: #f1f5f9 !important; }
.myday-item-meta    { color: #64748b !important; }

.myday-item-ic {
  background: #252220 !important;
  color: #FF6B00 !important;
}
.myday-item.overdue .myday-item-ic {
  background: #2a1515 !important;
  color: #f87171 !important;
}
.myday-item.amber .myday-item-ic {
  background: #251f10 !important;
  color: #fbbf24 !important;
}

.myday-item-meta .pill {
  background: #252220 !important;
  color: #FF6B00 !important;
}
.myday-item-meta .pill.over {
  background: #2a1515 !important;
  color: #fca5a5 !important;
}
.myday-item-meta .pill.due {
  background: #251f10 !important;
  color: #fbbf24 !important;
}

.myday-act {
  background: #252220 !important;
  border-color: #3a3530 !important;
  color: #f1f5f9 !important;
}
.myday-act:hover {
  border-color: #FF6B00 !important;
  color: #FF6B00 !important;
}
.myday-act.primary {
  background: #FF6B00 !important;
  border-color: #FF6B00 !important;
  color: #ffffff !important;
}
.myday-act.primary:hover {
  background: #e55f00 !important;
  border-color: #e55f00 !important;
}
.myday-act.warn {
  color: #f87171 !important;
  border-color: #7f1d1d !important;
}
.myday-act.warn:hover {
  background: #2a1515 !important;
  color: #fca5a5 !important;
  border-color: #dc2626 !important;
}

/* Approval card */
.myday-item.approval-card {
  background: #251f10 !important;
  border-color: #78350f !important;
}
.myday-appr-details {
  background: #1e1c19 !important;
  border-color: #3a3530 !important;
  color: #94a3b8 !important;
}
.myday-appr-row b { color: #f1f5f9 !important; }
.myday-appr-preview {
  background: #252220 !important;
  border-color: #3a3530 !important;
  color: #f1f5f9 !important;
}
.myday-appr-person {
  background: #252220 !important;
  border-color: #3a3530 !important;
  color: #94a3b8 !important;
}

/* ── 4. pui1d-* Home Redesign ────────────────────────────────────── */

/* pui1d cards use --card-bg CSS var (fallback #f6fafa) — override it */
.pui1d-home {
  --card-bg: #1e1c19;
}

.pui1d-stat {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
}
.pui1d-stat-val { color: #f1f5f9 !important; }
.pui1d-stat-lbl { color: #64748b !important; }
.pui1d-stat.red   .pui1d-stat-val { color: #f87171 !important; }
.pui1d-stat.amber .pui1d-stat-val { color: #fbbf24 !important; }
.pui1d-stat.green .pui1d-stat-val { color: #4ade80 !important; }
.pui1d-stat.teal  .pui1d-stat-val { color: #FF6B00 !important; }

.pui1d-sec {
  background: #1e1c19;
  border-bottom-color: #2a2520;
}
.pui1d-sec-hdr { color: #64748b; }

.pui1d-alert {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
  color: #94a3b8 !important;
}
.pui1d-alert-info {
  background: #141d2a !important;
  border-color: #1e3a5f !important;
  color: #94a3b8 !important;
}
.pui1d-alert-amber {
  background: #251f10 !important;
  border-color: #78350f !important;
  color: #fbbf24 !important;
}
.pui1d-alert-urgent {
  background: #2a1515 !important;
  border-color: #7f1d1d !important;
  color: #fca5a5 !important;
}
.pui1d-alert-title { color: #f1f5f9; }

.pui1d-job-card {
  background: #1e1c19 !important;
}
.pui1d-job-name { color: #f1f5f9 !important; }

.pui1d-empty-card {
  background: #252220 !important;
}

.pui1d-site-row {
  background: #1e1c19 !important;
}
.pui1d-site-row:hover { background: #252220 !important; }
.pui1d-site-name { color: #f1f5f9 !important; }

/* ── 5. PR366 Owner Dashboard ────────────────────────────────────── */

.pr366-dash-wrap {
  background: #141310;
}
.pr366-kpi-bar {
  background: #1e1c19;
  box-shadow: none;
  border: 1px solid #2a2520;
}
.pr366-kpi-tile   { border-right-color: #2a2520; }
.pr366-kpi-num    { color: #f1f5f9; }
.pr366-kpi-label  { color: #64748b; }

.pr366-panel {
  background: #1e1c19;
  border: 1px solid #2a2520;
  box-shadow: none;
}
.pr366-panel-title {
  color: #f1f5f9;
  border-bottom-color: #2a2520;
}

.pr366-project-table th      { color: #64748b; }
.pr366-project-table thead tr { border-bottom-color: #2a2520; }
.pr366-project-row td {
  border-bottom-color: #2a2520;
  color: #f1f5f9;
}
.pr366-project-row:hover td  { background: #252220; }

.pr366-chip-green  { background: #14532d; color: #4ade80; }
.pr366-chip-orange { background: #431407; color: #fb923c; }
.pr366-chip-red    { background: #7f1d1d; color: #fca5a5; }

.pr366-alert-item  { border-bottom-color: #2a2520; }
.pr366-alert-link  { color: #f1f5f9; }
.pr366-alert-link:hover { color: #FF6B00; }
.pr366-empty-state { color: #64748b; }

.pr366-trai-bar {
  background: #1e1a14;
  border-left-color: #FF6B00;
  color: #94a3b8;
}

.pr366-action-btn.pr366-action-btn-secondary {
  background: #1e1c19;
  color: #FF6B00;
  border-color: #FF6B00;
}
.pr366-action-btn.pr366-action-btn-secondary:hover {
  background: #252220;
}

@media (max-width: 900px) {
  .pr366-kpi-tile { border-bottom-color: #2a2520; }
  .pr366-kpi-tile:nth-child(odd) { border-right-color: #2a2520; }
}

/* ── 6. Home action tiles (rebuild_features.css .home-action) ─────── */

.home-action {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
}
.home-action:hover {
  border-color: #FF6B00 !important;
}
.home-action .ic {
  background: #252220 !important;
  color: #FF6B00 !important;
}
.home-action .nm { color: #f1f5f9 !important; }

/* ── 7. myday_source_intelligence.css overrides ───────────────────── */

.mgr-lily-context,
.msi-reminder-card,
.msi-source-fallback,
.vrfi-card {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
  color: #f1f5f9 !important;
}
.mgr-lily-context .lc-conf-high   { background: #14532d; color: #4ade80; }
.mgr-lily-context .lc-conf-medium { background: #451a03; color: #fbbf24; }

.msi-reminder-actions .btn-o,
.msi-source-fallback-actions .btn-o {
  background: #252220;
  border-color: #3a3530;
  color: #f1f5f9;
}
.msi-reminder-actions .btn-o:hover,
.msi-source-fallback-actions .btn-o:hover {
  background: #2a2520;
  border-color: #FF6B00;
}
.vrfi-status-open   { background: #14532d; color: #4ade80; }
.vrfi-status-closed { background: #252220; color: #64748b; }

/* ── 8. Search/autocomplete on home page ──────────────────────────── */

.home-search-row .srch,
.home-search-row .srch-results {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
}
.home-search-row .srch input {
  background: #252220 !important;
  border-color: #3a3530 !important;
  color: #f1f5f9 !important;
}
.home-search-body .nm { color: #f1f5f9 !important; }
.home-search-body .sub { color: #64748b !important; }
.home-search-empty { color: #64748b !important; }

/* ── 9. VillaShell vs-body + vs-panel when hosting My Day ──────────── */
/* :has() is supported in all modern browsers (Chrome 105+, Safari 15.4+, FF 121+) */
.vs-body:has(.myday-panel),
.vs-panel:has(.myday-panel) {
  background: #141310 !important;
}

/* Fallback for older browsers: set the background on the content wrapper div
   that VillaMyDay renders into — identified by its max-width:1180px style */
.vs-body > div[style*="max-width:1180px"] {
  background: #141310 !important;
}

/* The vs-pagebar (inline back-bar) also shows white inside My Day */
.vs-body:has(.myday-panel) .vs-pagebar,
.vs-body .myday-panel ~ .vs-pagebar {
  background: #1e1c19 !important;
  border-color: #2a2520 !important;
}

/* ── 10. VillaShell vs-body when hosting Customers (pr216) ──────── */

.vs-body:has(.pr216-landing),
.vs-body:has(.pr216-profile),
.vs-panel:has(.pr216-landing),
.vs-panel:has(.pr216-profile) {
  background: #141310 !important;
}

/* Override any ancestor wrapper that pr216 wraps its HTML in */
.vs-body .pr216-landing,
.vs-body .pr216-profile {
  background: #141310;
  color: #f1f5f9;
}

/* Search input on landing page */
.vs-body .pr216-search-input,
.pr216-search-input {
  background: #1e1c19 !important;
  border-color: #3a3530 !important;
  color: #f1f5f9 !important;
}
.vs-body .pr216-search-input:focus,
.pr216-search-input:focus {
  border-color: #FF6B00 !important;
}

/* Customer row hover */
.vs-body .pr216-customer-row:hover {
  background: #252220 !important;
}

/* Profile hero section */
.vs-body .pr216-hero {
  border-bottom-color: #2a2520 !important;
}
.vs-body .pr216-hero-name { color: #f1f5f9 !important; }
.vs-body .pr216-hero-type { color: #94a3b8 !important; }
.vs-body .pr216-hero-sub  { color: #94a3b8 !important; }

/* Profile tabs */
.vs-body .pr216-tab { color: #64748b !important; }
.vs-body .pr216-tab.pr216-tab-on {
  color: #FF6B00 !important;
  border-bottom-color: #FF6B00 !important;
}
.vs-body .pr216-tab:hover:not(.pr216-tab-on) { color: #f1f5f9 !important; }

/* Ghost buttons */
.vs-body .pr216-btn-ghost {
  background: transparent !important;
  border-color: #3a3530 !important;
  color: #94a3b8 !important;
}
.vs-body .pr216-btn-ghost:hover {
  border-color: #FF6B00 !important;
  color: #FF6B00 !important;
}
.vs-body .pr216-btn-ghost-xs {
  background: transparent !important;
  border-color: #3a3530 !important;
  color: #94a3b8 !important;
}

/* Data list (Overview tab) */
.vs-body .pr216-dl dt { color: #94a3b8 !important; }
.vs-body .pr216-dl dd { color: #f1f5f9 !important; }
.vs-body .pr216-muted { color: #64748b !important; }

/* Table rows */
.vs-body .pr216-table th {
  border-bottom-color: #2a2520 !important;
  color: #64748b !important;
}
.vs-body .pr216-table td {
  border-bottom-color: #2a2520 !important;
  color: #f1f5f9 !important;
}

/* Comp-extra / pill backgrounds */
.vs-body .pr216-comp-extra {
  background: #252220 !important;
  color: #94a3b8 !important;
}
.vs-body .pr216-pill {
  background: #252220 !important;
  color: #f1f5f9 !important;
}

/* Status badge / lead chip */
.vs-body .pr216-status-lead     { background: rgba(255,213,0,0.18);  color: #ffd54f !important; }
.vs-body .pr216-status-prospect { background: rgba(255,107,0,0.18);  color: #ffb74d !important; }
.vs-body .pr216-status-customer { background: rgba(43,178,154,0.18); color: #4dd0c4 !important; }
.vs-body .pr216-status-inactive { background: rgba(91,120,148,0.18); color: #94a3b8 !important; }

/* Modal overlays */
.pr216-modal-overlay {
  background: rgba(0,0,0,0.7) !important;
}

/* Section labels */
.vs-body .pr216-section-label { color: #64748b !important; }
.vs-body .pr216-landing-title { color: #f1f5f9 !important; }
.vs-body .pr216-landing-sub   { color: #94a3b8 !important; }

/* Empty states */
.vs-body .pr216-empty       { color: #94a3b8 !important; }
.vs-body .pr216-empty-title { color: #f1f5f9 !important; }
.vs-body .pr216-empty-sub   { color: #94a3b8 !important; }

/* Action buttons row */
.vs-body .pr216-action-btn {
  background: #1e1c19 !important;
  border-color: #3a3530 !important;
  color: #94a3b8 !important;
}
.vs-body .pr216-action-btn:hover {
  border-color: #FF6B00 !important;
  color: #FF6B00 !important;
}

/* Contact summary rows (Contacts tab) */
.vs-body .pr216-contact-summary {
  background: #1e1c19 !important;
  border-bottom-color: #2a2520 !important;
}
.vs-body .pr216-contact-summary:hover {
  background: #252220 !important;
}
