/* Shared CPM appearance controls. Layouts and media remain untouched. */
.theme-toggle{
  display:inline-flex;align-items:center;justify-content:center;gap:7px;
  min-height:44px;padding:9px 12px;border:1px solid #6a7c94;border-radius:8px;
  background:#213c59;color:#f3f0ea;font:inherit;font-size:.78rem;font-weight:600;
  cursor:pointer;white-space:nowrap;touch-action:manipulation;
}
.theme-toggle:hover{background:#2a4866}
.theme-toggle:focus-visible{outline:3px solid #c9a227;outline-offset:3px}
.theme-toggle svg{width:16px;height:16px;flex:0 0 auto}
.login-gate{align-items:safe center}
.login-card .theme-toggle{margin:0 0 16px;background:var(--surface-soft);color:var(--navy);border:1px solid var(--line)}
.top-ribbon > .theme-toggle{grid-column:1;grid-row:1;justify-self:start}
@media(max-width:1200px){
  body header .top-ribbon{grid-template-columns:minmax(0,1fr) auto}
  body #ribbonNav{grid-column:1 / -1;grid-row:1}
  body .top-ribbon #sessionChip{grid-column:2;grid-row:2}
  .top-ribbon > .theme-toggle{grid-column:1;grid-row:2}
}
@media screen {
  html[data-theme="dark"]{color-scheme:dark}
  html[data-theme="dark"] body.cpm-shell{
    --ink:#e1e9f1;--navy:#a8c8e7;--sky:#85bbd2;
    --good:#91d1ad;--goodbg:#1c392e;--mid:#dfc781;--midbg:#3b3422;
    --bad:#f0a4a8;--badbg:#40282e;--paper:#111e2c;--card:#1a2a3b;
    --line:#3b4d60;--muted:#adbdce;--surface-soft:#223548;
    --gold:#cfb775;--shadow:0 3px 14px rgba(4,12,23,.16);
  }
  html[data-theme="dark"] body.cpm-shell :is(.sheet,.msg-panel,.walkbooks-options,.table-wrap,.roster-wrap,table,.i360-btn,.builder-previews figure){
    background:var(--card);color:var(--ink);border-color:var(--line);
  }
  html[data-theme="dark"] body.cpm-shell :is(input,select,textarea){
    background:var(--card);color:var(--ink);border-color:var(--line);accent-color:#cfb775;
  }
  html[data-theme="dark"] body.cpm-shell :is(input,textarea)::placeholder{color:var(--muted)}
  html[data-theme="dark"] body.cpm-shell :is(.tabs button.on,.chip.on,th,.msg-fab,.rb-primary,.login-card > .btn-good){
    background:#254967;color:#f3f0ea;border-color:var(--line);
  }
  html[data-theme="dark"] body.cpm-shell :is(.btn-good,.rb-apply){background:#286749;color:#f3f0ea}
  html[data-theme="dark"] body.cpm-shell .btn-bad{background:#943f42;color:#f3f0ea}
  html[data-theme="dark"] body.cpm-shell :is(.btn-ghost,.team-pill,.pay-method,.select-assign,.p-done,.wb-req,.msg-item.unread,.audit-track,.rb-status:not(:empty),.action-menu > summary,.session-chip .action-menu-panel > button){
    background:var(--surface-soft);color:var(--ink);border-color:var(--line);
  }
  html[data-theme="dark"] body.cpm-shell :is(.btn-ghost:hover,.tabs button:not(.on):hover,.chip:not(.on):hover,.walkbooks-options button:hover,.walkbooks-options button.on,.action-menu-panel > button:hover,.roster-batch button:hover:not(:disabled)){
    background:#30475d;color:var(--ink);
  }
  html[data-theme="dark"] body.cpm-shell #ribbonNav .action-menu-panel > button.on{background:#30475d;color:var(--ink)}
  html[data-theme="dark"] body.cpm-shell tr:hover td{background:#263c51}
  html[data-theme="dark"] body.cpm-shell tbody tr:nth-child(even) td{background:#1e3042}
  html[data-theme="dark"] body.cpm-shell tbody tr:hover td{background:#263c51}
  html[data-theme="dark"] body.cpm-shell :is(th,td){border-bottom-color:var(--line)}
  html[data-theme="dark"] body.cpm-shell .pay-yes{background:var(--goodbg);color:var(--good)}
  html[data-theme="dark"] body.cpm-shell .pay-no{background:var(--badbg);color:var(--bad)}
  html[data-theme="dark"] body.cpm-shell :is(.area,.ios-install){color:var(--ink)}
  html[data-theme="dark"] body.cpm-shell .ios-install{background:var(--midbg)}
  html[data-theme="dark"] body.cpm-shell .area-tabs button:not(.on){background:var(--card)}
  html[data-theme="dark"] body.cpm-shell .area-tabs button[data-area="canvassers"].on{background:#254967;color:#f3f0ea}
  html[data-theme="dark"] body.cpm-shell .audit-bar{border-color:var(--line)}
  html[data-theme="dark"] body.cpm-shell .audit-track i{background:var(--ink)}
  html[data-theme="dark"] body.cpm-shell :is(.rb-status.rb-error){background:var(--badbg);color:var(--bad)}
  html[data-theme="dark"] body.cpm-shell :is(.rb-status.rb-success){background:var(--goodbg);color:var(--good)}
  html[data-theme="dark"] body.cpm-shell :is(#payDayStatus,#payoutDaily,select.daily-on,option.daily-pay,tr[style*="background:#ffe566"]){
    background:var(--midbg)!important;color:var(--mid);
  }
  html[data-theme="dark"] body.cpm-shell .kpi[style*="background:#fdecec"]{background:var(--badbg)!important}
  html[data-theme="dark"] body.cpm-shell .kpi b[style*="color:#a32020"]{color:var(--bad)!important}
  html[data-theme="dark"] body.cpm-shell button[style*="background:#eef4ea"]{background:var(--goodbg)!important}
  html[data-theme="dark"] body.cpm-shell .preview-new{color:var(--mid)}
  html[data-theme="dark"] body.cpm-shell .login-card .tag{color:var(--gold)}
  html[data-theme="dark"] body.cpm-shell .msg-receipt{color:var(--good)}
  html[data-theme="dark"] body.cpm-shell .audit-map-legend{
    background:var(--card)!important;color:var(--ink);border-color:var(--line)!important;
  }
  html[data-theme="dark"] body.cpm-shell .audit-map-legend span{color:var(--muted)!important}
}
/* Theme selection never changes printed paperwork or the actual exported data. */
@media print {
  html{color-scheme:light!important}
  .theme-toggle,[data-testid="button-toggle-dark-mode"]{display:none!important}
  body.cpm-shell{background:#fdfcf9;color:#233249}
}
