/* 保留业务状态颜色；主题只控制页面层级与可读性。 */
html { color-scheme: light; }
.theme-toggle { white-space: nowrap; }
.topbar .user-actions > button {
  box-sizing: border-box;
  min-height: 44px;
  height: 44px;
  padding: 0 12px;
  font-size: 14px;
  line-height: 1;
}
.login-theme { display: flex; justify-content: flex-end; margin-top: 10px; }
.login-theme .theme-toggle { min-height: 40px; }

/* 白天：让导航、内容区和卡片有清楚的层次。 */
html[data-theme="light"] body { background: #e6edf5; color: #1d334b; }
html[data-theme="light"] .topbar { background: #f8fbff; border-bottom: 1px solid #b3c4d9; }
html[data-theme="light"] .navigation { background: #cbd9e9; }
html[data-theme="light"] .account-console { background: #e6edf5; }
html[data-theme="light"] .chrome-title { background: #d5e3f2; color: #183d60; }
html[data-theme="light"] .account-activity > section { background: #fff; border-color: #aebfd3; }
html[data-theme="light"] #external-account-body tr.binding-selected td { background: #e6f1ff; }
html[data-theme="light"] .login-page { background: #d9e5f2; }

html[data-theme="dark"] { color-scheme: dark; --line: #465a70; --muted: #afc0d2; }
html[data-theme="dark"] body { background: #101b29; color: #e0eaf5; }
html[data-theme="dark"] :is(.topbar, .admin-header, body.login-page, body > header) {
  background: #172638; color: #e0eaf5; border-color: #40546a;
}
html[data-theme="dark"] :is(.navigation, .subnav, .account-console, .account-table,
  .history-page, .game-help-page, .schedule-page, .planner-grid, .workspace) {
  background: #101b29; color: #e0eaf5; border-color: #40546a;
}
html[data-theme="dark"] :is(.panel, .login-card, dialog, .account-activity > section,
  .mobile-getting-started, #external-account-body tr, #transactions-body tr,
  .history-frame, .history-toolbar, .maintenance-panel, .game-rules-panel,
  .planner-column, .binding-management, #binding-challenge, .reference-tile,
  .site-account-panel, .time-window, .schedule-options, .effect, .auth-tabs,
  .login-note, .draft-feedback, .plan-steps, .mode-bar, .predict-sync-row,
  .strategy-backtest, .season-windows > div) {
  background: #1d3044; color: #e0eaf5; border-color: #4a6078;
}
html[data-theme="dark"] :is(.chrome-title, .page-heading, .account-totals,
  #transactions-body td:first-child, .history-page .history-collapse) {
  background: #2a4058; color: #f1f6fc; border-color: #526981;
}
html[data-theme="dark"] :is(h1, h2, h3, h4, .small-label, .clock, .game-rule-list dt,
  #binding-totals, #binding-count, .account-site summary, #external-account-body td::before,
  #transactions-body td::before, .site-account-summary dt) { color: #d9eaff; }
html[data-theme="dark"] #external-account-body td::before,
html[data-theme="dark"] #transactions-body td::before { color: #d9eaff; }
html[data-theme="dark"] :is(.muted, .hint, .auth-hint, .history-source, .history-date,
  .binding-control-reason, .binding-snapshot-time, .account-site, .game-rule-list dd,
  .schedule-page, .schedule-description, .schedule-rules, .schedule-clock,
  .schedule-status-strip, .window-note, .site-footer, .login-card footer,
  .chrome-title small, .reference-tile small, #hub-recipe-form small,
  #hub-save-status, .lead) { color: #b9cadd; }
html[data-theme="dark"] a { color: #9bcaff; }
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  background: #122235; color: #f1f6fc; border-color: #698198;
}
html[data-theme="dark"] #external-account-body .binding-limit {
  background: #122235; color: #f1f6fc; border-color: #698198;
}
html[data-theme="dark"] #account-toolbar-controls .binding-auto { color: #d9eaff; }
html[data-theme="dark"] .cycle-preference { color: #e0eaf5; }
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #adbed1; opacity: 1; }
html[data-theme="dark"] :is(button:not(.binding-switch), .more-navigation summary) {
  background: #304a65; color: #f1f6fc; border-color: #7188a1;
}
html[data-theme="dark"] #main-nav :is(button, a) { background: #304a65; color: #f1f6fc; border-color: #7188a1; }
html[data-theme="dark"] #main-nav .active { background: #2b6499; color: #fff; border-color: #8cbce8; }
html[data-theme="dark"] :is(button:not(.binding-switch)):hover { background: #42617f; }
html[data-theme="dark"] :is(button.active, #main-nav .active, .subnav .active,
  .auth-tabs button.active) { background: #2b6499; color: #fff; border-color: #8cbce8; box-shadow: none; }
html[data-theme="dark"] button:disabled { opacity: .6; }
html[data-theme="dark"] :is(table, tbody, tr, td) { border-color: #465b70; }
html[data-theme="dark"] :is(th, .account-console th, .history-table th, .draw-panel th,
  .planner-grid th) { background: #2b4056; color: #e0edfa; border-color: #50657c; }
html[data-theme="dark"] .history-page .history-table { background: #1d3044; }
html[data-theme="dark"] :is(td, .account-console td, .history-table td, .draw-panel td,
  .planner-grid td) { background: transparent; color: #dce9f6; border-color: #465b70; }
html[data-theme="dark"] #external-account-body tr.binding-selected td { background: #284962; }
html[data-theme="dark"] #external-account-body .binding-positive { color: #ff9eae; }
html[data-theme="dark"] #external-account-body .binding-negative { color: #8de0b0; }
html[data-theme="dark"] :is(.binding-status.verified, .binding-running-count) { color: #8fe2b3; }
html[data-theme="dark"] .binding-status.needs-attention { color: #ffadba; }
html[data-theme="dark"] .binding-status { color: #f3d191; }
html[data-theme="dark"] .binding-status.verified { color: #8fe2b3; }
html[data-theme="dark"] :is(.history-toolbar strong, .history-toolbar [role="status"],
  .history-collapse small, .history-collapse .right, .history-pager > span,
  .history-table td:last-child, .strategy-backtest-metrics dt,
  .maintenance-content p, .maintenance-panel small, .usage-notes,
  .usage-notes summary, .time-switch, .schedule-preview small,
  .schedule-rules summary, #schedule-feedback, #schedule-empty) { color: #b9cadd; }
html[data-theme="dark"] #history-sync.stale,
html[data-theme="dark"] #schedule-preview[data-allowed="false"] { color: #ffe1a2; }
html[data-theme="dark"] #schedule-preview[data-allowed="true"] { color: #a4edc6; }
html[data-theme="dark"] .schedule-page #schedule-save { color: #f1f6fc; border-color: #8cbce8; }
html[data-theme="dark"] :is(.notice, .warning, .binding-form-feedback[data-level="pending"]) {
  background: #493c23; color: #ffe1a2; border-color: #9b7d41;
}
html[data-theme="dark"] :is(.error, .binding-form-feedback[data-level="error"],
  #account-feedback[data-level="error"]) { color: #ffb5bd; }
html[data-theme="dark"] .binding-form-feedback[data-level="error"],
html[data-theme="dark"] #account-feedback[data-level="error"] { background: #4a2934; border-color: #a4606c; }
html[data-theme="dark"] .binding-form-feedback[data-level="success"] { background: #20453d; color: #a4edc6; }
html[data-theme="dark"] :is(.status-badge, .tag, .badge) { background: #345164; color: #e1f4ff; }
html[data-theme="dark"] :is(.status-badge.stale, .schedule-draft-label) { background: #524023; color: #ffe1a2; }
html[data-theme="dark"] .player-saved-plan.selected { background: #284962; border-color: #79a9d0; }
html[data-theme="dark"] .field-help-popup { background: #1d3044; color: #eef5ff; border-color: #7f9ebd; }
html[data-theme="dark"] .s038-page :is(main > section, main > details, .metric, .signal) {
  background: #1d3044; color: #e0eaf5; border-color: #4a6078;
}
html[data-theme="dark"] :is(button, a, input, select, summary):focus-visible { outline: 3px solid #a5d4ff; outline-offset: 2px; }

/* 预测屏和日志本来就是深色，自身的图表及标记继续使用原有颜色。 */
html[data-theme="dark"] .prediction-stage h3,
html[data-theme="dark"] .screen-view h2 { color: inherit; }

@media (max-width: 800px) {
  .user-actions .theme-toggle { min-height: 44px; }
  .admin-header nav { flex-wrap: wrap; }
}

/* 功能配色：账号蓝、方案紫、交易青、开奖赭、帮助灰。
   状态开关及错误、等待提示继续使用各自原有颜色。 */
#main-nav > button[data-page="accounts"] {
  --feature: #245f98; --feature-wash: #e5f1fd; --feature-text: #174572;
}
#main-nav > button[data-page="strategies"] {
  --feature: #684397; --feature-wash: #f0eafb; --feature-text: #50327b;
}
#main-nav > button[data-page="transactions"] {
  --feature: #126a60; --feature-wash: #e3f5f1; --feature-text: #11554e;
}
#main-nav > button[data-page="history"] {
  --feature: #805313; --feature-wash: #fbf0dc; --feature-text: #68420e;
}
#main-nav > button[data-page="help"] {
  --feature: #4d5d74; --feature-wash: #edf0f5; --feature-text: #37475e;
}
html[data-theme] #main-nav > button[data-page] {
  background: var(--feature-wash);
  color: var(--feature-text);
  border: 1px solid var(--feature);
  border-bottom: 3px solid var(--feature);
  box-shadow: none;
}
html[data-theme] #main-nav > button[data-page].active {
  background: var(--feature);
  color: #fff;
  border-color: var(--feature);
  box-shadow: inset 0 0 0 2px #ffffffa6;
  font-weight: 700;
}
html[data-theme="dark"] #main-nav > button[data-page="accounts"] {
  --feature-wash: #203c59; --feature-text: #dcecff;
}
html[data-theme="dark"] #main-nav > button[data-page="strategies"] {
  --feature-wash: #3a2d4e; --feature-text: #f1e5ff;
}
html[data-theme="dark"] #main-nav > button[data-page="transactions"] {
  --feature-wash: #193e3d; --feature-text: #d2f6ed;
}
html[data-theme="dark"] #main-nav > button[data-page="history"] {
  --feature-wash: #443723; --feature-text: #ffebcc;
}
html[data-theme="dark"] #main-nav > button[data-page="help"] {
  --feature-wash: #303d50; --feature-text: #e3ebf8;
}

/* 同类入口与对应的内容卡片共用色条，卡片正文保持易读的中性色。 */
html[data-theme] .account-console .account-left { border-top: 4px solid #397bb7; }
html[data-theme] .account-activity .recent-transactions { border-top: 4px solid #168779; }
html[data-theme] .account-activity .player-logs { border-top: 4px solid #718297; }
html[data-theme] .strategy-hub-grid > .hub-catalog { border-top: 4px solid #855dc0; }
html[data-theme] .strategy-hub-grid > .hub-play { border-top: 4px solid #6c84c6; }
html[data-theme] .strategy-hub-grid > .hub-parameters { border-top: 4px solid #aa71b6; }
html[data-theme] .hub-backtest { border-top: 4px solid #855dc0; }
html[data-theme] [data-view="transactions"] > .table-scroll { border-top: 4px solid #168779; }
html[data-theme] .history-frame { border-top: 4px solid #a8772b; }
html[data-theme] .player-help { border-top: 4px solid #718297; }
/* 深色主题对旧组件有较强的边框选择器，只覆盖各卡片的顶部识别色。 */
html[data-theme] .account-activity .recent-transactions { border-top-color: #168779 !important; }
html[data-theme] .account-activity .player-logs { border-top-color: #718297 !important; }
html[data-theme] .strategy-hub-grid > .hub-catalog { border-top-color: #855dc0 !important; }
html[data-theme] .strategy-hub-grid > .hub-play { border-top-color: #6c84c6 !important; }
html[data-theme] .strategy-hub-grid > .hub-parameters { border-top-color: #aa71b6 !important; }
html[data-theme] .history-frame { border-top-color: #a8772b !important; }
html[data-theme] .player-help { border-top-color: #718297 !important; }

html[data-theme] :is(#player-add-account, #binding-submit) {
  background: #245f98; border-color: #245f98; color: #fff;
}
html[data-theme] :is(#hub-new, #hub-save, #fixed-save, #s038-plan-save,
  #luna-plan-form button[type="submit"], #multi-plan-add) {
  background: #684397; border-color: #684397; color: #fff;
}
html[data-theme] :is(#recent-refresh, .recent-transactions button[data-page="transactions"],
  #transactions-filter button[type="submit"], #transactions-site-open) {
  background: #126a60; border-color: #126a60; color: #fff;
}
html[data-theme] #history-refresh { background: #805313; border-color: #805313; color: #fff; }
html[data-theme] :is(#player-add-account, #binding-submit, #hub-new, #hub-save, #fixed-save,
  #s038-plan-save, #luna-plan-form button[type="submit"], #multi-plan-add, #recent-refresh,
  #transactions-filter button[type="submit"], #transactions-site-open, #history-refresh):hover:enabled {
  filter: brightness(1.12);
}
