/* Neutral dark theme v6 — deliberately loaded LAST. */
html[data-theme="dark"]{
  color-scheme:dark;
  --canvas:#212121;
  --surface:#2f2f2f;
  --soft:#383838;
  --line:#4a4a4a;
  --ink:#ececec;
  --muted:#b4b4b4;
  --brand:#ececec;
  --brand-2:#d7d7d7;
  --accent:#a8a8a8;
  --accent-dark:#f4f4f4;
  --rail:#171717;
  --danger:#ff8585;
  --warning:#e7c66b;
  --shadow:0 16px 45px rgba(0,0,0,.35);
  --shadow-sm:0 8px 24px rgba(0,0,0,.25);
}
html[data-theme="dark"],html[data-theme="dark"] body{
  background:#212121!important;
  background-image:none!important;
  color:#ececec!important;
}
html[data-theme="dark"] main,
html[data-theme="dark"] .page-shell,
html[data-theme="dark"] .content-shell{background:transparent!important;color:var(--ink)!important}
html[data-theme="dark"] :where(h1,h2,h3,h4,h5,h6,strong,b,.value,.metric-value,.listing-title,.price,.results-count,.home-manager-name){color:var(--ink)!important}
html[data-theme="dark"] :where(p,small,.muted,.hint,.sub,.listing-meta,.home-manager-save,.home-manager-note){color:var(--muted)!important}
html[data-theme="dark"] a{color:var(--ink)}
html[data-theme="dark"] :where(
 .panel,.card,.ph-widget,.ph-command,.listing-card,.ph-shop-product,.ph-local-content-card,
 .ph-local-content-copy,.user-popover,.nav-dropdown-menu,.mobile-drawer,.filter-drawer,
 .table-wrap,.auth-shell .panel,.quick-dialog,.location-dialog,.ph-popup-card,.account-popover-foot,
 .upload-tile,.category-chip,.quick-option,.ph-command-action,.ph-content-card,.ph-deal-card,
 .ph-emergency-list a,.admin-content .card,.home-manager-row,.home-manager-gear
){
  background:var(--surface)!important;
  color:var(--ink)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .home-manager-row.is-off{background:#292929!important}
html[data-theme="dark"] .home-manager-handle,
html[data-theme="dark"] .home-manager-name .ico,
html[data-theme="dark"] .home-manager-note{background:var(--soft)!important;color:var(--ink)!important}
html[data-theme="dark"] .home-manager-switch span{background:#5a5a5a!important}
html[data-theme="dark"] .home-manager-switch input:checked+span{background:#8f8f8f!important}
html[data-theme="dark"] .home-manager-switch span:after{background:#ececec!important}
html[data-theme="dark"] .site-header{
  background:rgba(33,33,33,.96)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] .service-rail{background:#171717!important;border-color:#333!important}
html[data-theme="dark"] :where(.rail-item,.rail-name,.rail-group-title){color:#d8d8d8!important}
html[data-theme="dark"] .rail-item:hover,
html[data-theme="dark"] .rail-item.active{background:#2f2f2f!important;color:#fff!important}
html[data-theme="dark"] :where(.input,input,select,textarea,.btn-outline,.header-icon-button,.dialog-close){
  background:#2f2f2f!important;
  color:#ececec!important;
  border-color:#4a4a4a!important;
}
html[data-theme="dark"] :where(input,select,textarea)::placeholder{color:#999!important}
html[data-theme="dark"] :where(.table th,.filter-body,.account-popover-foot,.account-grid,.quick-dialog-head,.mobile-drawer-head,.location-dialog-body){
  background:#292929!important;color:var(--ink)!important;border-color:var(--line)!important
}
html[data-theme="dark"] .table td{border-color:var(--line)!important;color:var(--ink)!important}
html[data-theme="dark"] .table tbody tr:hover{background:#383838!important}
html[data-theme="dark"] :where(
 .ph-widget[data-widget-key],.ph-widget[data-widget-key="tools.weather"],
 .ph-widget[data-widget-key="tools.prayer-times"],.ph-widget[data-widget-key="tools.tomorrow-bag"],
 .ph-widget[data-widget-key="tools.tasks"],.ph-widget[data-widget-key="tools.household"],
 .ph-widget[data-widget-key="tools.budget"],.ph-widget[data-widget-key="tools.location"],
 .ph-widget[data-widget-key="tools.scanner"],.ph-widget[data-widget-key="tools.ocr"],
 .ph-widget[data-widget-key="classifieds.feed"],.ph-widget[data-widget-key="emergency.feed"],
 .ph-widget[data-widget-key="content.local-feed"],.ph-widget[data-widget-key="zagmart.products"],
 .ph-widget[data-widget-key="deals.marketplace"]
){background:#2f2f2f!important;background-image:none!important;color:var(--ink)!important}
html[data-theme="dark"] .ph-command{background:#2f2f2f!important;background-image:none!important}
html[data-theme="dark"] :where(.ph-quick-actions a,.ph-card-media,.ph-deal-icon,.ph-cart-icon,.ph-shop-empty){background:#383838!important;color:var(--ink)!important}
html[data-theme="dark"] .mobile-bottom-nav{background:rgba(33,33,33,.98)!important;border-color:var(--line)!important}
html[data-theme="dark"] :where(.mobile-bottom-link,.nav-link,.mobile-drawer-link,.account-item){color:#c7c7c7!important}
html[data-theme="dark"] :where(.mobile-bottom-link.active,.nav-link.active,.nav-link:hover,.mobile-drawer-link.active,.mobile-drawer-link:hover,.account-item:hover){color:#fff!important}
html[data-theme="dark"] :where(.nav-link.active,.nav-link:hover,.mobile-drawer-link.active,.mobile-drawer-link:hover,.account-item:hover){background:#383838!important}
html[data-theme="dark"] .site-footer{background:#171717!important;color:#cfcfcf!important}
html[data-theme="dark"] .footer-links a{color:#cfcfcf!important}

/* Section pages: neutral surfaces, no green dark-mode gradients. */
html[data-theme="dark"] :where(.browse-hero,.emergency-command,.zm-hero,.section-themed-hero){
  background:#2f2f2f!important;
  background-image:none!important;
  color:#fff!important;
  border-color:#4a4a4a!important;
}
html[data-theme="dark"] :where(.browse-hero h1,.browse-hero h2,.browse-hero .sub,.emergency-command h1,.emergency-command h2,.emergency-command p,.zm-hero h1,.zm-hero h2,.zm-hero p,.section-themed-hero h1,.section-themed-hero h2,.section-themed-hero p){color:#ececec!important}
html[data-theme="dark"] .browse-search{background:#383838!important}
html[data-theme="dark"] .category-chip.active,
html[data-theme="dark"] .category-chip:hover{background:#444!important;border-color:#666!important;color:#fff!important}
html[data-theme="dark"] .filter-pill{background:#444!important;color:#ececec!important}

html[data-theme="dark"] .zo-house-ad{background:#2f2f2f!important;background-image:none!important;color:#ececec!important;border-color:#555!important}
html[data-theme="dark"] .zo-house-brand{background:#292929!important;border-color:var(--line)!important}
html[data-theme="dark"] .listing-thumb{background:#383838!important;background-image:none!important}
html[data-theme="dark"] .status-draft,html[data-theme="dark"] .badge-off{background:#444!important;color:#ddd!important}
html[data-theme="dark"] .success{background:#24352a!important;color:#cde8d4!important;border-color:#3f5d49!important}
html[data-theme="dark"] .warning{background:#3a321f!important;color:#f0d995!important;border-color:#665a35!important}
html[data-theme="dark"] .danger{background:#3a2424!important;color:#ffb1b1!important;border-color:#684040!important}
html[data-theme="dark"] :where(.adblock-policy-card,.htab-welcome-card){background:var(--surface)!important;color:var(--ink)!important}
html[data-theme="dark"] .theme-toggle-fab{background:#2f2f2f!important;color:#ececec!important;border-color:#4a4a4a!important}
html[data-theme="dark"] img{filter:none}

/* Last-resort normalization for legacy inline white/light backgrounds that otherwise create white islands. */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background:#f8"],
html[data-theme="dark"] [style*="background:#f9"],
html[data-theme="dark"] [style*="background:#fb"],
html[data-theme="dark"] [style*="background:#fc"]{
  background:var(--surface)!important;
  color:var(--ink)!important;
}


/* FIX07 — strict neutral visual normalization for dark mode. */
html[data-theme="dark"]{
  --widget-background:#2f2f2f!important;
  --widget-foreground:#ececec!important;
}

/* Buttons: never light text on a light button or dark text on a dark button. */
html[data-theme="dark"] :where(
  .btn,button.btn,.btn-outline,.ph-command-actions .btn,.browse-search .btn,
  .location-dialog-actions .btn,.mobile-drawer-add,.logout-link
){
  background:#3a3a3a!important;
  background-image:none!important;
  color:#f2f2f2!important;
  border-color:#555!important;
  box-shadow:none!important;
}
html[data-theme="dark"] :where(.btn:hover,button.btn:hover,.btn-outline:hover){
  background:#474747!important;color:#fff!important;border-color:#686868!important;
}
html[data-theme="dark"] :where(.btn-accent,.btn.primary,.btn[type="submit"]:not(.btn-outline)){
  background:#e8e8e8!important;color:#202020!important;border-color:#e8e8e8!important;
}

/* Personal Home: all widget surfaces and their nested controls are neutral. */
html[data-theme="dark"] :where(.ph-grid,.ph-widget,.ph-custom-card,.ph-command,.ph-content-card,.ph-deal-card){
  color:#ececec!important;
}
html[data-theme="dark"] .ph-widget,
html[data-theme="dark"] .ph-custom-card{
  background:#2f2f2f!important;
  background-image:none!important;
  border-color:#4a4a4a!important;
}
html[data-theme="dark"] .ph-widget *:not(img):not(svg):not(path){
  border-color:inherit;
}
html[data-theme="dark"] :where(.ph-widget h1,.ph-widget h2,.ph-widget h3,.ph-widget strong,.ph-widget b,.ph-widget a){
  color:#ececec!important;
}
html[data-theme="dark"] :where(.ph-widget small,.ph-widget p,.ph-widget .hint,.ph-widget .muted,.ph-widget .ph-widget-handle span){
  color:#b4b4b4!important;
}

/* News ticker must not retain the old green identity in dark mode. */
html[data-theme="dark"] .ph-ticker{
  background:#383838!important;
  background-image:none!important;
  color:#ececec!important;
  border:1px solid #4a4a4a!important;
}
html[data-theme="dark"] .ph-ticker-label{
  background:#505050!important;
  color:#f0f0f0!important;
}
html[data-theme="dark"] .ph-ticker-track a,
html[data-theme="dark"] .ph-ticker-track span{
  color:#ececec!important;
}
html[data-theme="dark"] .ph-ticker-track a:after{color:#8e8e8e!important}
html[data-theme="dark"] .ph-ticker button{
  background:#4a4a4a!important;color:#fff!important;border:1px solid #5b5b5b!important;
}

/* Quick access, settings controls and widget controls. */
html[data-theme="dark"] :where(
 .ph-quick-actions a,.ph-command-action,.home-manager-gear,.home-manager-handle,
 .ph-popup-close,.ph-mobile-ad-close
){
  background:#3a3a3a!important;color:#ececec!important;border-color:#555!important;
}
html[data-theme="dark"] :where(.ph-quick-actions a>span,.ph-widget-heading>a,.ph-widget-handle a){
  color:#ececec!important;
}

/* Forms/search fields. */
html[data-theme="dark"] :where(
 .input,input:not([type="checkbox"]):not([type="radio"]),select,textarea,.browse-search .input
){
  background:#303030!important;
  color:#ececec!important;
  border-color:#505050!important;
  caret-color:#fff!important;
}
html[data-theme="dark"] :where(.input,input,textarea)::placeholder{color:#9f9f9f!important}

/* Ads and placeholders: neutral only. */
html[data-theme="dark"] :where(.zo-house-ad,.zo-house-brand,.paid-ad,.ph-ad,.ph-inline-ad,.ph-bottom-ad,.ph-ticker-sponsor){
  background-color:#2f2f2f!important;
  color:#ececec!important;
  border-color:#555!important;
}
html[data-theme="dark"] .zo-house-mark{background:#a9a9a9!important;color:#fff!important}
html[data-theme="dark"] .zo-house-ad :where(span,small,strong,b,em,a){color:#ececec!important}

/* Kill remaining green decorative backgrounds inside homepage widgets in dark mode. */
html[data-theme="dark"] :where(
 .ph-widget [style*="background:"],.ph-command [style*="background:"]
){
  background-color:#383838!important;
  background-image:none!important;
}
html[data-theme="dark"] :where(
 .ph-widget [style*="color:"],.ph-command [style*="color:"]
){
  color:#ececec!important;
}

/* Rail: theme control is pinned immediately above the separator; messages remain below it. */
@media(min-width:981px){
  html[data-theme="dark"] .service-rail{background:#171717!important}
  .service-rail .rail-theme{margin-top:auto!important;padding-top:0!important;padding-bottom:8px!important}
  .service-rail .rail-utility{margin-top:0!important;border-top:1px solid rgba(255,255,255,.12)!important}
  html[data-theme="dark"] .rail-item:hover,
  html[data-theme="dark"] .rail-item.active{background:#303030!important;color:#fff!important}
}

/* No green accents in dark mode navigation/active states. */
html[data-theme="dark"] .rail-item.active:after{background:#9b9b9b!important}
html[data-theme="dark"] :where(.badge,.notification-count){background:#555!important;color:#fff!important}


/* FIX08 — mobile dark-mode + header/login guarantees. */
html[data-theme="dark"] .theme-toggle-fab{
  background:#2f2f2f!important;
  color:#f2f2f2!important;
  border-color:#555!important;
}
html[data-theme="dark"] .guest-account-link{
  background:#2f2f2f!important;
  color:#ececec!important;
  border-color:#505050!important;
}
@media(max-width:980px){
  html[data-theme="dark"] .site-header,
  html[data-theme="dark"] .mobile-header,
  html[data-theme="dark"] .header-inner,
  html[data-theme="dark"] .brand-area{
    background:#212121!important;
    background-image:none!important;
    color:#ececec!important;
  }
  html[data-theme="dark"] :where(.hero,.home-hero,.ph-command,.zo-house-ad,.paid-ad,.ph-widget,.ph-custom-card){
    background-color:#2f2f2f!important;
    background-image:none!important;
    color:#ececec!important;
    border-color:#4a4a4a!important;
  }
  html[data-theme="dark"] :where(.mobile-bottom-nav,.mobile-drawer){
    background:#212121!important;
    color:#ececec!important;
    border-color:#444!important;
  }
}

/* FIX09 mobile header controls */
html[data-theme="dark"] .mobile-theme-header-button,
html[data-theme="dark"] .guest-account-link,
html[data-theme="dark"] .header-actions summary.header-icon-button{
  background:#2f2f2f!important;
  color:#ececec!important;
  border-color:#505050!important;
}
