/* ============================================================
   ZXERP 全局夜间模式主题（theme.css）
   仅在 <html data-theme="dark"> 时生效；浅色模式零改动、保持默认。
   配色规范（黑白灰极简）：
     主背景 #171717 | 卡片/面板 #262626 | 弹窗/下拉 #333333
     主文字 #F5F5F5 | 次要文字 #A3A3A3 | 占位 #737373
     边框 #404040 | 高亮 #525252 | 危险 #fb7171 | 成功 #4ade80
   ============================================================ */

/* ---------- 基础 ---------- */
html[data-theme="dark"]{color-scheme:dark;background:#171717;}
html[data-theme="dark"] body{background:#171717 !important;color:#F5F5F5 !important;}
html[data-theme="dark"] a{color:#F5F5F5;}
html[data-theme="dark"] a:hover{color:#fff;}
html[data-theme="dark"] hr{border-color:#404040;background:#404040;}

/* ---------- 次要/说明文字归一（内联灰字 → 次要文字色） ---------- */
html[data-theme="dark"] [style*="color:#666"],html[data-theme="dark"] [style*="color:#888"],
html[data-theme="dark"] [style*="color:#999"],html[data-theme="dark"] [style*="color:#555"],
html[data-theme="dark"] [style*="color:#777"],html[data-theme="dark"] [style*="color:#aaa"],
html[data-theme="dark"] [style*="color:#bbb"],html[data-theme="dark"] [style*="color:#ccc"],
html[data-theme="dark"] [style*="color:#ddd"],html[data-theme="dark"] [style*="color:#86909c"],
html[data-theme="dark"] [style*="color:#4e5969"],html[data-theme="dark"] [style*="color:#6b7280"],
html[data-theme="dark"] [style*="color:#9ca3af"],html[data-theme="dark"] [style*="color:#4f4f4f"]{color:#A3A3A3 !important;}

/* 深色正文（内联深字在暗底看不清 → 主文字色） */
html[data-theme="dark"] [style*="color:#222"],html[data-theme="dark"] [style*="color:#333"],
html[data-theme="dark"] [style*="color:#111"],html[data-theme="dark"] [style*="color:#1a1a1a"],
html[data-theme="dark"] [style*="color:#1f2329"],html[data-theme="dark"] [style*="color:#374151"],
html[data-theme="dark"] [style*="color:#1f2937"],html[data-theme="dark"] [style*="color:#000"]{color:#F5F5F5 !important;}

/* 语义色归一：绿色系 → 成功色 #4ade80；红色系 → 危险色 #fb7171 */
html[data-theme="dark"] [style*="color:#00b42a"],html[data-theme="dark"] [style*="color:#2a7d2a"],
html[data-theme="dark"] [style*="color:#059669"],html[data-theme="dark"] [style*="color:#2e7d32"],
html[data-theme="dark"] [style*="color:#4caf50"],html[data-theme="dark"] [style*="color:#155724"],
html[data-theme="dark"] [style*="color:#065f46"]{color:#4ade80 !important;}
html[data-theme="dark"] [style*="color:#f53f3f"],html[data-theme="dark"] [style*="color:#c00"],
html[data-theme="dark"] [style*="color:#c0392b"],html[data-theme="dark"] [style*="color:#dc2626"],
html[data-theme="dark"] [style*="color:#e53935"],html[data-theme="dark"] [style*="color:#c62828"],
html[data-theme="dark"] [style*="color:#d32f2f"],html[data-theme="dark"] [style*="color:#d00"],
html[data-theme="dark"] [style*="color:#d33"],html[data-theme="dark"] [style*="color:#f44336"],
html[data-theme="dark"] [style*="color:#b91c1c"],html[data-theme="dark"] [style*="color:#e03333"]{color:#fb7171 !important;}

/* 蓝色/橙色/紫色/品红等彩色文字 → 中性（极简黑白灰，仅保留成功/危险色） */
html[data-theme="dark"] [style*="color:#4a90e2"],html[data-theme="dark"] [style*="color:#165dff"],
html[data-theme="dark"] [style*="color:#1976d2"],html[data-theme="dark"] [style*="color:#3a7bc8"],
html[data-theme="dark"] [style*="color:#1565c0"],html[data-theme="dark"] [style*="color:#4080ff"],
html[data-theme="dark"] [style*="color:#2563eb"],html[data-theme="dark"] [style*="color:#1d4ed8"],
html[data-theme="dark"] [style*="color:#4a90d9"],html[data-theme="dark"] [style*="color:#1677ff"],
html[data-theme="dark"] [style*="color:#ff7d00"],html[data-theme="dark"] [style*="color:#e67e22"],
html[data-theme="dark"] [style*="color:#d97706"],html[data-theme="dark"] [style*="color:#e6a23c"],
html[data-theme="dark"] [style*="color:#d46b08"],html[data-theme="dark"] [style*="color:#856404"],
html[data-theme="dark"] [style*="color:#8a6d3b"],html[data-theme="dark"] [style*="color:#92400e"],
html[data-theme="dark"] [style*="color:#722ed1"],html[data-theme="dark"] [style*="color:#eb2f96"],
html[data-theme="dark"] [style*="color:#7cb3ff"]{color:#F5F5F5 !important;}

/* ---------- 浅色内联背景 → 卡片面 #262626 ---------- */
html[data-theme="dark"] [style*="background:#fff"],html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background:white"],html[data-theme="dark"] [style*="background:#f5f5f5"],
html[data-theme="dark"] [style*="background:#fafafa"],html[data-theme="dark"] [style*="background:#f7f7f7"],
html[data-theme="dark"] [style*="background:#f0f0f0"],html[data-theme="dark"] [style*="background:#f7f8fa"],
html[data-theme="dark"] [style*="background:#efefef"],html[data-theme="dark"] [style*="background:#f5f7fa"],
html[data-theme="dark"] [style*="background:#eee"],html[data-theme="dark"] [style*="background:#f9f9f9"],
html[data-theme="dark"] [style*="background:#e8e8e8"],html[data-theme="dark"] [style*="background:#fafbfc"],
html[data-theme="dark"] [style*="background:#f2f2f2"],html[data-theme="dark"] [style*="background:#e0e0e0"],
html[data-theme="dark"] [style*="background:#e9e9e9"],html[data-theme="dark"] [style*="background:#f9fafb"],
html[data-theme="dark"] [style*="background:#f4f4f4"],html[data-theme="dark"] [style*="background:#f7f9fc"],
html[data-theme="dark"] [style*="background:#f3f4f6"],html[data-theme="dark"] [style*="background:#e8ecf0"],
html[data-theme="dark"] [style*="background:#fdfdfd"],html[data-theme="dark"] [style*="background:#f2f3f5"],
html[data-theme="dark"] [style*="background:#e5e6eb"],html[data-theme="dark"] [style*="background:#e6e6e6"],
html[data-theme="dark"] [style*="background:#e5e7eb"],html[data-theme="dark"] [style*="background:#f3f3f3"],
html[data-theme="dark"] [style*="background:#f8fafc"]{background-color:#262626 !important;}

/* 中灰内联背景 → 弹窗面 #333333 */
html[data-theme="dark"] [style*="background:#ddd"],html[data-theme="dark"] [style*="background:#ccc"],
html[data-theme="dark"] [style*="background:#c0c0c0"],html[data-theme="dark"] [style*="background:#bbb"]{background-color:#333333 !important;}

/* 彩色浅底（蓝/橙/紫/黄提示块）→ 中性面板 */
html[data-theme="dark"] [style*="background:#e3f2fd"],html[data-theme="dark"] [style*="background:#e0e8f5"],
html[data-theme="dark"] [style*="background:#e8f3ff"],html[data-theme="dark"] [style*="background:#e8f0fe"],
html[data-theme="dark"] [style*="background:#f0f6ff"],html[data-theme="dark"] [style*="background:#e8f0ff"],
html[data-theme="dark"] [style*="background:#f5f9ff"],html[data-theme="dark"] [style*="background:#f0f5ff"],
html[data-theme="dark"] [style*="background:#eef3fa"],html[data-theme="dark"] [style*="background:#dfe8f9"],
html[data-theme="dark"] [style*="background:#f0f7ff"],html[data-theme="dark"] [style*="background:#eef5ff"],
html[data-theme="dark"] [style*="background:#f7faff"],html[data-theme="dark"] [style*="background:#fff3cd"],
html[data-theme="dark"] [style*="background:#fff8e1"],html[data-theme="dark"] [style*="background:#fdf6ec"],
html[data-theme="dark"] [style*="background:#fef3c7"],html[data-theme="dark"] [style*="background:#fff3e8"],
html[data-theme="dark"] [style*="background:#fff3e0"],html[data-theme="dark"] [style*="background:#fff7e6"],
html[data-theme="dark"] [style*="background:#fff2f0"],html[data-theme="dark"] [style*="background:#fcfaf5"],
html[data-theme="dark"] [style*="background:#f3e8ff"]{background-color:#262626 !important;}

/* 成功浅底 → 暗色成功色调（保留语义） */
html[data-theme="dark"] [style*="background:#e8fff0"],html[data-theme="dark"] [style*="background:#d4edda"],
html[data-theme="dark"] [style*="background:#e6f7e6"],html[data-theme="dark"] [style*="background:#d1fae5"],
html[data-theme="dark"] [style*="background:#e8f5e9"]{background-color:rgba(74,222,128,.12) !important;}
/* 危险浅底 → 暗色危险色调（保留语义） */
html[data-theme="dark"] [style*="background:#fde8e8"],html[data-theme="dark"] [style*="background:#fff0f0"],
html[data-theme="dark"] [style*="background:#fff5f5"],html[data-theme="dark"] [style*="background:#f0d0d0"],
html[data-theme="dark"] [style*="background:#f5e5e5"],html[data-theme="dark"] [style*="background:#ffcdd2"],
html[data-theme="dark"] [style*="background:#fff0f6"],html[data-theme="dark"] [style*="background:#fbe9e7"]{background-color:rgba(251,113,133,.12) !important;}

/* 彩色实底按钮/标签归一（先灰化，成功/危险再单独提亮） */
html[data-theme="dark"] [style*="background:#4a90e2"],html[data-theme="dark"] [style*="background:#165dff"],
html[data-theme="dark"] [style*="background:#1976d2"],html[data-theme="dark"] [style*="background:#3a7bc8"],
html[data-theme="dark"] [style*="background:#1565c0"],html[data-theme="dark"] [style*="background:#4080ff"],
html[data-theme="dark"] [style*="background:#2563eb"],html[data-theme="dark"] [style*="background:#1d4ed8"],
html[data-theme="dark"] [style*="background:#4a90d9"],html[data-theme="dark"] [style*="background:#1677ff"],
html[data-theme="dark"] [style*="background:#ff7d00"],html[data-theme="dark"] [style*="background:#e67e22"],
html[data-theme="dark"] [style*="background:#722ed1"]{background-color:#333333 !important;border-color:#404040 !important;}
html[data-theme="dark"] [style*="background:#00b42a"],html[data-theme="dark"] [style*="background:#009025"],
html[data-theme="dark"] [style*="background:#2a7d2a"],html[data-theme="dark"] [style*="background:#009a24"],
html[data-theme="dark"] [style*="background:#4caf50"],html[data-theme="dark"] [style*="background:#3c9c3c"],
html[data-theme="dark"] [style*="background:#009424"],html[data-theme="dark"] [style*="background:#059669"]{
  background-color:#333333 !important;border-color:#4ade80 !important;color:#4ade80 !important;}
html[data-theme="dark"] [style*="background:#f53f3f"],html[data-theme="dark"] [style*="background:#d32f2f"],
html[data-theme="dark"] [style*="background:#dc3545"],html[data-theme="dark"] [style*="background:#dc2626"],
html[data-theme="dark"] [style*="background:#c00"],html[data-theme="dark"] [style*="background:#e03333"],
html[data-theme="dark"] [style*="background:#f44336"],html[data-theme="dark"] [style*="background:#c0392b"]{
  background-color:#333333 !important;border-color:#fb7171 !important;color:#fb7171 !important;}

/* ---------- 表单 ---------- */
html[data-theme="dark"] input[type="text"],html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="date"],html[data-theme="dark"] input[type="datetime-local"],
html[data-theme="dark"] input[type="month"],html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="email"],html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] input[type="search"],html[data-theme="dark"] input[type="url"],
html[data-theme="dark"] input:not([type]),html[data-theme="dark"] textarea{
  background:#333333 !important;color:#F5F5F5 !important;border:1px solid #404040 !important;
}
html[data-theme="dark"] select{background:#333333 !important;color:#F5F5F5 !important;border:1px solid #404040 !important;}
html[data-theme="dark"] select option,html[data-theme="dark"] select optgroup{background:#333333;color:#F5F5F5;}
html[data-theme="dark"] ::placeholder{color:#737373;opacity:1;}
html[data-theme="dark"] input:focus,html[data-theme="dark"] select:focus,html[data-theme="dark"] textarea:focus{
  border-color:#737373 !important;outline:none;
}

/* ---------- 按钮（默认灰面；语义色由上面的内联规则接管） ---------- */
html[data-theme="dark"] button,
html[data-theme="dark"] input[type="button"],html[data-theme="dark"] input[type="submit"],
html[data-theme="dark"] input[type="reset"],html[data-theme="dark"] .btn,html[data-theme="dark"] a.button{
  background:#333333 !important;color:#F5F5F5 !important;border:1px solid #404040 !important;
}
html[data-theme="dark"] button:hover,html[data-theme="dark"] .btn:hover,
html[data-theme="dark"] input[type="submit"]:hover,html[data-theme="dark"] input[type="button"]:hover{
  background:#525252 !important;border-color:#525252 !important;
}
/* 彩色实底按钮在 hover 时被上面内联规则压住，这里补语义 hover */
html[data-theme="dark"] [style*="background:#00b42a"]:hover,
html[data-theme="dark"] [style*="background:#2a7d2a"]:hover{background-color:#3d4d3d !important;border-color:#4ade80 !important;color:#4ade80 !important;}
html[data-theme="dark"] [style*="background:#f53f3f"]:hover,
html[data-theme="dark"] [style*="background:#c0392b"]:hover,
html[data-theme="dark"] [style*="background:#d32f2f"]:hover{background-color:#4d3333 !important;border-color:#fb7171 !important;color:#fb7171 !important;}

/* ---------- 表格 ---------- */
html[data-theme="dark"] table{background:#262626;color:#F5F5F5;border-color:#404040;}
html[data-theme="dark"] table th,html[data-theme="dark"] table thead td{
  background:#2e2e2e !important;color:#F5F5F5 !important;border-color:#404040 !important;
}
html[data-theme="dark"] table td{background-color:transparent;color:#F5F5F5;border-color:#404040;}
/* 彩色单元格背景保留语义（浅绿/浅红 → 暗色调），其余浅底由内联规则兜住 */
html[data-theme="dark"] table td[style*="background:#e8fff0"],html[data-theme="dark"] table td[style*="background:#d4edda"],
html[data-theme="dark"] table td[style*="background:#e6f7e6"]{background-color:rgba(74,222,128,.12) !important;}
html[data-theme="dark"] table td[style*="background:#fde8e8"],html[data-theme="dark"] table td[style*="background:#fff0f0"],
html[data-theme="dark"] table td[style*="background:#fff5f5"]{background-color:rgba(251,113,133,.12) !important;}
/* 行悬停高亮 #525252（[style] 提升优先级，压过内联浅底） */
html[data-theme="dark"] table tbody tr:hover td,
html[data-theme="dark"] table tr:hover td,
html[data-theme="dark"] table tr:hover td[style]{background-color:#525252 !important;}

/* ---------- 弹窗 / 下拉 / 抽屉 / jQuery UI ---------- */
html[data-theme="dark"] .modal,html[data-theme="dark"] [class*="modal"],html[data-theme="dark"] [id*="modal"],
html[data-theme="dark"] [class*="dialog"],html[data-theme="dark"] [id*="dialog"],
html[data-theme="dark"] [class*="popup"],html[data-theme="dark"] [id*="popup"],
html[data-theme="dark"] [class*="drawer"],html[data-theme="dark"] [class*="layer"]{
  background-color:#333333 !important;color:#F5F5F5 !important;
}
html[data-theme="dark"] .ui-widget,html[data-theme="dark"] .ui-widget-content,html[data-theme="dark"] .ui-widget-header{
  background:#333333 !important;color:#F5F5F5 !important;border-color:#404040 !important;
}
html[data-theme="dark"] .ui-datepicker{background:#262626 !important;}
html[data-theme="dark"] .ui-datepicker th,html[data-theme="dark"] .ui-datepicker td{border-color:#404040;color:#F5F5F5;}
html[data-theme="dark"] .ui-datepicker .ui-state-hover,html[data-theme="dark"] .ui-datepicker .ui-state-active{
  background:#525252 !important;color:#F5F5F5 !important;border-color:#525252 !important;
}
html[data-theme="dark"] .ui-datepicker .ui-icon{background-color:#A3A3A3;}

/* ---------- 标签页 / 分页 / 进度条 / 状态标签 / 菜单导航 / 面板 ---------- */
html[data-theme="dark"] .tab,html[data-theme="dark"] .tabs,html[data-theme="dark"] .tab-bar,
html[data-theme="dark"] .tab-btn,html[data-theme="dark"] .tab-item,html[data-theme="dark"] .nav-tabs{
  background:#262626 !important;color:#A3A3A3 !important;border-color:#404040 !important;
}
html[data-theme="dark"] .tab.active,html[data-theme="dark"] .tab-btn.active,html[data-theme="dark"] .tab-item.active,
html[data-theme="dark"] .active{color:#F5F5F5;}
html[data-theme="dark"] .tab.active,html[data-theme="dark"] .tab-btn.active,html[data-theme="dark"] .tab-item.active{
  background:#525252 !important;
}
html[data-theme="dark"] .pagination a,html[data-theme="dark"] .page-btn,html[data-theme="dark"] .pager a{
  background:#333333 !important;color:#F5F5F5 !important;border-color:#404040 !important;
}
html[data-theme="dark"] .pagination a:hover,html[data-theme="dark"] .page-btn:hover{background:#525252 !important;}
html[data-theme="dark"] [class*="progress"]{background:#404040 !important;color:#F5F5F5 !important;border-color:#404040;}
html[data-theme="dark"] .left-menu,html[data-theme="dark"] .sidebar,html[data-theme="dark"] .menu-list,
html[data-theme="dark"] .user-info,html[data-theme="dark"] .online-box,html[data-theme="dark"] .system-name,
html[data-theme="dark"] .mobile-header,html[data-theme="dark"] .card,html[data-theme="dark"] [class*="card"],
html[data-theme="dark"] [class*="panel"]{background-color:#262626 !important;color:#F5F5F5 !important;border-color:#404040 !important;}
html[data-theme="dark"] .menu-list a,html[data-theme="dark"] .menu-list summary{color:#F5F5F5 !important;}
html[data-theme="dark"] .menu-list a:hover,html[data-theme="dark"] .menu-list summary:hover{background:#525252 !important;}

/* ---------- 运行时兜底类（theme.js 扫描注入） ---------- */
html[data-theme="dark"] .zx-dark-surface{background-color:#262626 !important;}
html[data-theme="dark"] .zx-dark-text{color:#F5F5F5 !important;-webkit-text-fill-color:#F5F5F5 !important;}

/* ---------- 滚动条 ---------- */
html[data-theme="dark"] ::-webkit-scrollbar{width:10px;height:10px;}
html[data-theme="dark"] ::-webkit-scrollbar-thumb{background:#404040;border-radius:5px;}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover{background:#525252;}
html[data-theme="dark"] ::-webkit-scrollbar-track{background:#171717;}
html[data-theme="dark"] ::selection{background:#525252;color:#F5F5F5;}

/* ---------- 主题切换按钮（右上角悬浮，两态各自适配） ---------- */
.zxerp-theme-toggle{
  position:fixed;top:10px;right:10px;z-index:99999;
  padding:5px 14px;font-size:12px;line-height:1.5;border-radius:16px;cursor:pointer;
  background:rgba(255,255,255,.88);color:#333;border:1px solid #d9d9d9;
  box-shadow:0 1px 6px rgba(0,0,0,.15);font-family:inherit;
}
html[data-theme="dark"] .zxerp-theme-toggle{
  background:rgba(38,38,38,.92);color:#F5F5F5;border-color:#404040;box-shadow:0 1px 6px rgba(0,0,0,.5);
}
@media(max-width:768px){
  .zxerp-theme-toggle{top:46px;right:8px;padding:4px 10px;}
}

/* ---------- 打印：暗色模式下自动转白底黑字 ---------- */
@media print{
  .zxerp-theme-toggle{display:none !important;}
  html[data-theme="dark"],html[data-theme="dark"] body{background:#fff !important;color:#000 !important;}
  html[data-theme="dark"] *{
    background-color:transparent !important;background-image:none !important;
    color:#000 !important;border-color:#bbb !important;box-shadow:none !important;text-shadow:none !important;
  }
  html[data-theme="dark"] table th{background:#f0f0f0 !important;}
  html[data-theme="dark"] table tr{page-break-inside:avoid;}
}
