.theme-toggle { display:inline-flex; align-items:center; justify-content:center; gap:7px; border:1px solid #e1d8ec; border-radius:9px; padding:9px 12px; color:#49345f; background:#f7f3fc; cursor:pointer; font:600 12px "Segoe UI",sans-serif; white-space:nowrap; }
.theme-toggle:focus-visible { outline:2px solid #ff8d2f; outline-offset:3px; }
.theme-dark-label { display:none; }
:root[data-theme="dark"] .theme-light-label { display:none; }
:root[data-theme="dark"] .theme-dark-label { display:inline; }
.login-theme { position:fixed; top:18px; right:20px; z-index:10; }
@media(max-width:650px) { .theme-toggle { padding:7px 9px; font-size:11px; } .topbar-right { gap:10px; flex-shrink:0; } .breadcrumb .muted,.breadcrumb .crumb { display:none; } .login-theme { top:12px; right:12px; } }
@media screen {
  :root[data-theme="dark"] { --green:#ff9e51; --dark:#f0e8fb; --muted:#b7a9c7; --line:#44354f; background:#171122; color-scheme:dark; }
  :root[data-theme="dark"] body { background:#171122; color:#efe8f6; }
  :root[data-theme="dark"] :is(.workspace-main,main) { background:transparent; }
  :root[data-theme="dark"] :is(.topbar,.panel,.stat,.w-area-card,.login-card) { background:#241a30; color:#efe8f6; border-color:#44354f; }
  :root[data-theme="dark"] :is(h1,h2,h3,h4,.subtitle strong,.w-main-link,.w-stat strong,.payment-total strong,.stat strong,.stat em,.w-facts dd,.breadcrumb strong) { color:#f5edff; }
  :root[data-theme="dark"] :is(.subtitle,.muted,.eyebrow,.w-stat>span,.w-stat>small,.w-facts dt,.w-panel td small,.w-area-card p,.w-area-count,.w-editor-subtitle,.w-edit-hint,.w-section-description,.w-readonly span,.panel-heading p,.stat small,.stat>div,.legend-row,.period-label,.filter>span,footer,footer span,.panel-bottom) { color:#baaccb; }
  :root[data-theme="dark"] :is(.w-stat,.w-readonly,.w-area-intro,.subtle,.panel-bottom,.w-editor .w-dialog-body) { background:#2c2039; border-color:#44354f; }
  :root[data-theme="dark"] .w-area-intro { background:linear-gradient(110deg,#34233f,#29202c); }
  :root[data-theme="dark"] :is(table,th,td) { border-color:#44354f; color:#e9deef; }
  :root[data-theme="dark"] thead th { background:#30213e; color:#c8b6dc; }
  :root[data-theme="dark"] tbody tr { background:transparent; }
  :root[data-theme="dark"] tbody tr:hover { background:#352542; }
  :root[data-theme="dark"] :is(.secondary,.theme-toggle) { background:#342640; color:#eee0fc; border-color:#554064; }
  :root[data-theme="dark"] :is(.secondary,.theme-toggle):hover { background:#443151; border-color:#ad88cb; }
  :root[data-theme="dark"] .primary { background:#ff963e; color:#201029; border-color:#ff963e; }
  :root[data-theme="dark"] .primary:hover { background:#ffaf6b; }
  :root[data-theme="dark"] :is(.text-button,.w-back-link,.portfolio-link,.panel a) { color:#d3afea; }
  :root[data-theme="dark"] :is(input,select,textarea),
  :root[data-theme="dark"] #w-dialog :is(input,select,textarea) { background:#1d1527; color:#f1e8fa; border-color:#5a4668; }
  :root[data-theme="dark"] :is(input,textarea)::placeholder { color:#a897b9; }
  :root[data-theme="dark"] :is(input,select,textarea):focus { outline-color:#ff9e51; border-color:#ff9e51; }
  :root[data-theme="dark"] .search { background:#1d1527; border-color:#5a4668; }
  :root[data-theme="dark"] :is(.badge,.badge.neutral) { background:#42304f; color:#e5d2f4; border-color:#59436b; }
  :root[data-theme="dark"] :is(.badge.amber,.notice.warning) { background:#443021; color:#ffd09a; border-color:#765431; }
  :root[data-theme="dark"] .badge.green { background:#1d433a; color:#a5ead3; }
  :root[data-theme="dark"] :is(.notice,.snapshot-note) { background:#30243d; color:#d8c8e8; border-color:#574368; }
  :root[data-theme="dark"] .w-area-card:hover { background:#30213f; border-color:#9773b0; }
  :root[data-theme="dark"] :is(#w-dialog,#detail) { color:#efe8f6; background:#241a30; }
  :root[data-theme="dark"] :is(.w-dialog-head,.w-editor .w-dialog-head) { background:#241a30; border-color:#44354f; }
  :root[data-theme="dark"] .w-editor .w-form-section { background:#241a30; border-color:#493657; }
  :root[data-theme="dark"] .w-editor .w-form-section legend { color:#f0e5fc; }
  :root[data-theme="dark"] .w-editor .w-readonly { background:#30223b; border-color:#644775; }
  :root[data-theme="dark"] .w-section-number { background:#4b325f; color:#e0c0f6; }
  :root[data-theme="dark"] :is(#w-import,#w-billing) { background:#2e213a; border-color:#564264; }
  :root[data-theme="dark"] .metric-icon { background:#42304f; color:#e7c7ff; }
  :root[data-theme="dark"] .featured-stat { background:#342039; }
  :root[data-theme="dark"] .login-layout { background:#171122; }
  :root[data-theme="dark"] :is(.login-layout p,.login-layout label) { color:#c7b9d5; }
  :root[data-theme="dark"] .login-layout h2 { color:#f3eaff; }
  :root[data-theme="dark"] footer strong { color:#dac5eb; }
  :root[data-theme="dark"] button:disabled { opacity:.5; }
}
@media print { .theme-toggle { display:none!important; } :root { color-scheme:light!important; } }


.theme-toggle { width:auto; margin:0; }
@media screen {
  :root[data-theme="dark"] :is(.energy-total strong,.legend-row strong,.task-row>strong,.partner-card h3,.partner-stats strong) { color:#ead5fc; }
  :root[data-theme="dark"] :is(.task-row p,.task-row small,.energy-total span,.legend-row small,.portfolio>p,.payment-total small) { color:#bcaaca; }
  :root[data-theme="dark"] :is(.task-row,.panel-heading,.pagination,.table-tools,.filters,.partner-stats) { border-color:#493750; }
  :root[data-theme="dark"] .task-row:hover { background:#30213e; }
  :root[data-theme="dark"] :is(.icon-button,.pagination button,.tab) { background:#32243f; color:#e9d7f7; border-color:#58416b; }
  :root[data-theme="dark"] .partner-card { background:#241a30; border-color:#44354f; color:#efe8f6; }
}

/* Navigation follows the selected appearance on desktop and mobile. */
@media screen {
  :root { --nav-bg:#fff; --nav-text:#514060; --nav-muted:#7a688a; --nav-hover:#f1ebf7; --nav-border:#e8e1ee; --nav-icon-bg:#f4eef9; --nav-icon-text:#704791; --nav-active:#ff8d2f; }
  :root[data-theme="dark"] { --nav-bg:#1d1527; --nav-text:#ded0eb; --nav-muted:#b3a0c6; --nav-hover:#32243f; --nav-border:#44354f; --nav-icon-bg:#30213e; --nav-icon-text:#f4bb8b; --nav-active:#ff963e; }
  .sidebar { background:var(--nav-bg); color:var(--nav-text); border-right:1px solid var(--nav-border); scrollbar-color:var(--nav-muted) var(--nav-bg); }
  .sidebar .brand-block { background:var(--nav-bg); }
  .sidebar .product-label { color:var(--nav-muted); }
  .sidebar .workspace { color:var(--nav-text); }
  .sidebar :is(.workspace small,.nav-caption,.mobile-page-nav) { color:var(--nav-muted); }
  .sidebar .workspace-icon { background:var(--nav-icon-bg); color:var(--nav-icon-text); border-color:var(--nav-border); }
  .sidebar .nav-link { color:var(--nav-text); }
  .sidebar .nav-link:hover { background:var(--nav-hover); color:var(--nav-text); }
  .sidebar .nav-icon { color:inherit; }
  .sidebar .nav-count { background:var(--nav-icon-bg); color:var(--nav-text); border-color:var(--nav-border); }
  .sidebar .nav-link.active { background:var(--nav-active); color:#140043; }
  .sidebar .active .nav-count { background:#ffffff40; color:#140043; border-color:#14004325; }
  .sidebar .mobile-page-nav select { background:var(--nav-icon-bg); color:var(--nav-text); border:1px solid var(--nav-border); }
  :root[data-theme="dark"] .sidebar .brand { background:#fff; border-radius:8px; padding:12px; }
  :root[data-theme="dark"] .sidebar .brand img { width:100%; max-width:168px; }
}

/* Stable layout when switching appearance. */
@media screen {
  .sidebar .brand { background:#fff; border-radius:8px; padding:12px; }
  .sidebar .brand img { width:100%; max-width:168px; }
  :root:not([data-theme="dark"]) :is(.eyebrow,.crumb,footer,footer strong,footer span,.task-arrow) { color:#705c7e; }
  :root:not([data-theme="dark"]) :is(.badge,.badge.neutral,.badge.lavender) { color:#654778; }
  :root:not([data-theme="dark"]) .badge.amber { color:#854619; }
  :root:not([data-theme="dark"]) :is(input,select,textarea) { border-color:#887693; }
  :root:not([data-theme="dark"]) :is(input,textarea)::placeholder { color:#756180; opacity:1; }
  :root:not([data-theme="dark"]) :is(.metric-icon,.workspace-icon) { color:#704791; }
  :root:not([data-theme="dark"]) .metric-icon.amber-icon { color:#8b4b18; }
  :root:not([data-theme="dark"]) :is(button,a,input,select,textarea):focus-visible { outline-color:#704791; }
  :root[data-theme="dark"] :is(.record-link,.tab,.w-panel .record-link) { color:#d9b9ef; }
  :root[data-theme="dark"] :is(input,select,textarea),
  :root[data-theme="dark"] #w-dialog :is(input,select,textarea) { border-color:#9079a2; }
  :root[data-theme="dark"] :is(input,textarea)::placeholder { color:#b7a4c8; opacity:1; }
  .sidebar .mobile-page-nav select { border-color:var(--nav-muted); }
}
@media screen {
  :root:not([data-theme="dark"]) :is(.search>span,.result-label span,.empty p,.icon-button,.payment-total small) { color:#705c7e; }
  :root:not([data-theme="dark"]) .w-area-arrow { color:#934c17; }
  :root[data-theme="dark"] :is(.result-label,.result-label strong,.result-label span,.cell-sub,.pagination,.pagination span,.empty p) { color:#c6b3d6; }
}
@media screen {
  :root:not([data-theme="dark"]) .w-section-description { color:#705c7e; }
  :root[data-theme="dark"] .login-layout .error { background:#492332; color:#ffd3de; }
  :root[data-theme="dark"] :is(button,a,input,select,textarea):focus-visible { outline-color:#ffb477; }
}
