/* ============================================================
 * 系统整套主题 · 仅作用于 #app / #modal-root / #toast-root
 * 登录页 #login 完全不受影响（无变量引用、无选择器命中）
 * 主题切换：body[data-theme="green|blue|violet|orange|teal|rose"]
 * ============================================================ */

/* ---------- 清新绿（默认） ---------- */
body, body[data-theme="green"]{
  --primary:#2e9e63; --primary-2:#3da872; --primary-dark:#1c5136;
  --bg:#f2faf5; --card:#fff; --line:#cbe8d3; --line-2:#e4f2e8; --head:#d8efe0;
  --text:#203a2c; --muted:#6f8a79; --shadow:0 2px 12px rgba(40,120,75,.10);
  --th-bar1:#1c5136; --th-bar2:#257a52; --th-bar3:#3da872; --th-barShadow:rgba(20,80,50,.28); --th-topSub:#c9efd8;
  --th-ink:#22563a; --th-accent:#3da872; --th-accentDark:#2e9e63; --th-accent2:#4bb694; --th-accent3:#3aa889;
  --th-p1:#dff2e5; --th-p2:#c9ecd5; --th-p3:#aee0c1; --th-side1:#f1faf4; --th-side2:#f8fdf9;
  --th-sideGlow:rgba(120,200,150,.20); --th-accentSoft:rgba(61,168,114,.35); --th-accentGlow:rgba(61,168,114,.16);
  --th-headInk:#235a3c; --th-rowEven:#fbfefc; --th-rowHover:#f2faf5; --th-navHover:#1e7a4e; --th-navActive:#1a7046;
  --th-chart-bar:#58b58e; --th-chart-line:#e39a3c; --th-chart-grid:#e4f2e8; --th-chart-axis:#86a892; --th-chart-label:#6d8a78;
  --th-palette:#3da872,#5bbd90,#2e9e63,#e0a94f,#cf7f85,#8f7ecf,#3aa889,#c59a62; --th-table-line:#2e7d4f;
}
/* ---------- 经典蓝 ---------- */
body[data-theme="blue"]{
  --primary:#1164b4; --primary-2:#1d7ed6; --primary-dark:#0a3f7c;
  --bg:#f2f6fb; --card:#fff; --line:#dce6f1; --line-2:#eaf0f7; --head:#e9f2fc;
  --text:#20303f; --muted:#708298; --shadow:0 2px 12px rgba(20,60,110,.08);
  --th-bar1:#0a3f7c; --th-bar2:#1164b4; --th-bar3:#1d7ed6; --th-barShadow:rgba(10,60,120,.25); --th-topSub:#c9e2ff;
  --th-ink:#173c65; --th-accent:#1d7ed6; --th-accentDark:#1164b4; --th-accent2:#42a5c6; --th-accent3:#2480da;
  --th-p1:#e8f2ff; --th-p2:#d6e9fb; --th-p3:#bedcf5; --th-side1:#f3f8ff; --th-side2:#f8fbff;
  --th-sideGlow:rgba(140,196,255,.20); --th-accentSoft:rgba(29,126,214,.32); --th-accentGlow:rgba(29,126,214,.15);
  --th-headInk:#2b537e; --th-rowEven:#fafcff; --th-rowHover:#eef6ff; --th-navHover:#0b5ca8; --th-navActive:#0c5aa7;
  --th-chart-bar:#5aa9e6; --th-chart-line:#ed8a2b; --th-chart-grid:#e6edf5; --th-chart-axis:#95a6b8; --th-chart-label:#6b7d92;
  --th-palette:#1d7ed6,#5aa9e6,#2fae62,#f0a94c,#e05b63,#8f7ecf,#35b8bf,#c59a62; --th-table-line:#165a96;
}
/* ---------- 紫罗兰 ---------- */
body[data-theme="violet"]{
  --primary:#6b4bbf; --primary-2:#7d5ed6; --primary-dark:#432a8c;
  --bg:#f7f4fc; --card:#fff; --line:#e2daf3; --line-2:#f0ebfa; --head:#ece5fb;
  --text:#2d2545; --muted:#776d92; --shadow:0 2px 12px rgba(90,60,150,.10);
  --th-bar1:#432a8c; --th-bar2:#6b4bbf; --th-bar3:#8b6bdf; --th-barShadow:rgba(70,40,140,.28); --th-topSub:#e0d4ff;
  --th-ink:#432a8c; --th-accent:#7d5ed6; --th-accentDark:#6b4bbf; --th-accent2:#9a7ae0; --th-accent3:#8f7ecf;
  --th-p1:#f0eafc; --th-p2:#e4daf8; --th-p3:#d3c4f2; --th-side1:#f8f5fd; --th-side2:#fcfaff;
  --th-sideGlow:rgba(170,140,235,.20); --th-accentSoft:rgba(125,94,214,.32); --th-accentGlow:rgba(125,94,214,.16);
  --th-headInk:#4b3485; --th-rowEven:#fdfbff; --th-rowHover:#f5f0fd; --th-navHover:#5b3bb0; --th-navActive:#5b3bb0;
  --th-chart-bar:#9a7ae0; --th-chart-line:#e39a3c; --th-chart-grid:#eee8f9; --th-chart-axis:#a095b9; --th-chart-label:#7d7297;
  --th-palette:#7d5ed6,#9a7ae0,#6b4bbf,#e0a94f,#d4789a,#5aa9e6,#8f7ecf,#c59a62; --th-table-line:#5b3ba0;
}
/* ---------- 暖橙 ---------- */
body[data-theme="orange"]{
  --primary:#c2661c; --primary-2:#dd7d2b; --primary-dark:#8a430d;
  --bg:#fdf7f0; --card:#fff; --line:#f0ddc8; --line-2:#f9eee2; --head:#fbe9d5;
  --text:#3d2c1c; --muted:#927c66; --shadow:0 2px 12px rgba(150,90,30,.10);
  --th-bar1:#8a430d; --th-bar2:#c2661c; --th-bar3:#dd7d2b; --th-barShadow:rgba(130,70,15,.28); --th-topSub:#ffe0bf;
  --th-ink:#8a430d; --th-accent:#dd7d2b; --th-accentDark:#c2661c; --th-accent2:#e89a4c; --th-accent3:#d98c39;
  --th-p1:#fdf0e2; --th-p2:#f9e2c8; --th-p3:#f3d1ae; --th-side1:#fdf8f1; --th-side2:#fffcf8;
  --th-sideGlow:rgba(235,170,95,.22); --th-accentSoft:rgba(221,125,43,.32); --th-accentGlow:rgba(221,125,43,.16);
  --th-headInk:#8a4a12; --th-rowEven:#fffdfa; --th-rowHover:#fdf5eb; --th-navHover:#a9500d; --th-navActive:#a9500d;
  --th-chart-bar:#e89a4c; --th-chart-line:#4f9e86; --th-chart-grid:#f7eade; --th-chart-axis:#b69d84; --th-chart-label:#907862;
  --th-palette:#dd7d2b,#e89a4c,#c2661c,#4f9e86,#c96a6a,#8f7ecf,#d98c39,#a98a5f; --th-table-line:#a85a12;
}
/* ---------- 青碧 ---------- */
body[data-theme="teal"]{
  --primary:#12877f; --primary-2:#1aa398; --primary-dark:#0b5b56;
  --bg:#f0faf9; --card:#fff; --line:#c8e8e4; --line-2:#e2f4f1; --head:#d6f0ec;
  --text:#1d3a38; --muted:#668984; --shadow:0 2px 12px rgba(20,120,110,.10);
  --th-bar1:#0b5b56; --th-bar2:#12877f; --th-bar3:#1aa398; --th-barShadow:rgba(10,90,82,.28); --th-topSub:#bdece7;
  --th-ink:#0b5b56; --th-accent:#1aa398; --th-accentDark:#12877f; --th-accent2:#48bfb4; --th-accent3:#35b8bf;
  --th-p1:#e4f7f4; --th-p2:#cceede9; --th-p3:#aee2db; --th-side1:#f1faf9; --th-side2:#f8fdfc;
  --th-sideGlow:rgba(100,205,190,.20); --th-accentSoft:rgba(26,163,152,.32); --th-accentGlow:rgba(26,163,152,.16);
  --th-headInk:#14625d; --th-rowEven:#fbfffe; --th-rowHover:#f0faf8; --th-navHover:#0c7069; --th-navActive:#0c7069;
  --th-chart-bar:#48bfb4; --th-chart-line:#e39a3c; --th-chart-grid:#e0f2ef; --th-chart-axis:#82a5a0; --th-chart-label:#6b8c87;
  --th-palette:#1aa398,#48bfb4,#12877f,#e0a94f,#d4789a,#8f7ecf,#35b8bf,#c59a62; --th-table-line:#0e6b64;
}
/* ---------- 玫瑰红 ---------- */
body[data-theme="rose"]{
  --primary:#b0455e; --primary-2:#c85a75; --primary-dark:#7d2b41;
  --bg:#fdf4f6; --card:#fff; --line:#f0d7de; --line-2:#f9e9ed; --head:#fbe2e9;
  --text:#3f222c; --muted:#95727c; --shadow:0 2px 12px rgba(150,45,75,.10);
  --th-bar1:#7d2b41; --th-bar2:#b0455e; --th-bar3:#c85a75; --th-barShadow:rgba(120,35,60,.28); --th-topSub:#ffd8e2;
  --th-ink:#7d2b41; --th-accent:#c85a75; --th-accentDark:#b0455e; --th-accent2:#dc8098; --th-accent3:#cf7f85;
  --th-p1:#fceef2; --th-p2:#f9dde5; --th-p3:#f3c8d5; --th-side1:#fdf7f9; --th-side2:#fffbfc;
  --th-sideGlow:rgba(230,140,170,.20); --th-accentSoft:rgba(200,90,117,.32); --th-accentGlow:rgba(200,90,117,.16);
  --th-headInk:#8d354c; --th-rowEven:#fffbfc; --th-rowHover:#fdf2f5; --th-navHover:#a33b55; --th-navActive:#a33b55;
  --th-chart-bar:#dc8098; --th-chart-line:#4f9e86; --th-chart-grid:#f8e7ec; --th-chart-axis:#b5939d; --th-chart-label:#96747e;
  --th-palette:#c85a75,#dc8098,#b0455e,#e0a94f,#4f9e86,#8f7ecf,#cf7f85,#c59a62; --th-table-line:#8f354c;
}

/* ============================================================
 * 通用覆盖：所有系统页面（不含登录页）
 * ============================================================ */
#app .topbar{background:linear-gradient(100deg,var(--th-bar1),var(--th-bar2) 60%,var(--th-bar3));box-shadow:0 2px 8px var(--th-barShadow)}
#app .top-company{color:var(--th-topSub)}
#app .ver{color:#fff}
#app .sidebar{background:linear-gradient(160deg,var(--th-side1) 0%,var(--th-side2) 30%,#fff 62%,var(--th-side1) 100%);border-right-color:var(--th-line)}
#app .sidebar::before{background:radial-gradient(120% 80% at 20% 0%,var(--th-sideGlow),transparent 70%)}
#app .sidebar::-webkit-scrollbar-thumb{background:linear-gradient(var(--th-line),var(--th-p2))}
#app .side-caption{color:var(--th-muted)}
#app .side-line{background:linear-gradient(90deg,transparent,var(--th-line))}
#app .side-line:last-child{background:linear-gradient(90deg,var(--th-line),transparent)}
#app .nav-group-title{color:var(--th-ink)}
#app .nav-group-title::before{background:linear-gradient(120deg,#fff,var(--th-p2) 45%,rgba(255,255,255,.25))}
/* 修复：hover 时高亮遮罩不得盖住分组标题文字（文字需保持在遮罩之上） */
#app .nav-group-title::before,#app .nav-group-title::after{z-index:0}
#app .nav-group-title>.g-text{position:relative;z-index:1;color:inherit}
#app .nav-group-title:hover{color:var(--th-navHover);border-color:var(--th-accentSoft);box-shadow:0 4px 16px var(--th-shadow),inset 0 1px 0 #fff}
#app .g-ico{color:var(--th-accent);background:linear-gradient(135deg,var(--th-p1),var(--th-p2));box-shadow:inset 0 1px 0 #fff,inset 0 0 0 1px var(--th-accentSoft)}
#app .nav-group-title:hover .g-ico{box-shadow:0 3px 10px var(--th-shadow),inset 0 1px 0 #fff}
#app .nav-group-title .caret{color:var(--th-muted)}
#app .nav-items{border-left-color:var(--th-line)}
#app .nav-item{color:var(--th-text)}
#app .nav-item::before{background:var(--th-line)}
#app .nav-item::after{background:linear-gradient(115deg,rgba(255,255,255,.82),var(--th-p2) 48%,rgba(255,255,255,.2))}
#app .nav-item:hover{color:var(--th-navHover);border-color:var(--th-accentSoft);box-shadow:0 5px 18px var(--th-shadow),inset 0 1px 0 #fff}
#app .nav-item:hover::before,#app .nav-item.active::before{background:var(--th-accent);box-shadow:0 0 0 3px var(--th-accentGlow)}
#app .nav-item.active{color:var(--th-navActive);border-color:var(--th-accentSoft);background:linear-gradient(100deg,var(--th-p1),var(--th-p3));box-shadow:0 4px 14px var(--th-shadow),inset 0 1px 0 #fff}
#app .nav-item .ico{color:var(--th-accent);background:var(--th-p1)}
#app .nav-item:hover .ico,#app .nav-item.active .ico{color:var(--th-accentDark);background:#fff}
#app .statusbar{background:var(--th-p1);color:var(--th-muted)}
#app .page-title{color:var(--th-ink)}
#app .card-head{color:var(--th-ink)}
#app #content .card{border-color:var(--th-line)}
/* 注意：--th-head 未在任何主题中定义，曾导致表头背景计算为 transparent，滚动时数据行文字穿透表头形成重叠 */
#app table.grid th{background:var(--head,#eef4fb);color:var(--th-headInk);border-color:var(--th-line,var(--line))}
#app table.grid td{border-color:var(--th-line-2)}
#app table.grid tbody tr:nth-child(even){background:var(--th-rowEven)}
#app table.grid tbody tr:hover{background:var(--th-rowHover)}
#app table.grid tfoot td{background:var(--th-p1);border-top-color:var(--th-accentSoft)}
#app .btn:hover{border-color:var(--th-accentSoft);background:var(--th-p1);color:var(--primary)}
#app .btn-primary{background:var(--primary-2);border-color:var(--primary-2);color:#fff}
#app .btn-primary:hover{background:var(--primary);border-color:var(--primary);color:#fff}
#app .form-item input:focus,#app .form-item select:focus,#app .form-item textarea:focus{border-color:var(--primary-2);box-shadow:0 0 0 2px var(--th-accentGlow)}
#app .stat::after{background:var(--th-accentGlow)}
#app a{color:var(--primary-2)}
#modal-root .modal-head{background:linear-gradient(90deg,var(--th-bar2),var(--th-bar3))}
#modal-root .modal-foot,#modal-root .combo-add{background:var(--th-p1)}
#modal-root .combo-add{color:var(--primary-2)}
#toast-root .toast{border-left-color:var(--primary-2)}

/* ---------- 首页总看板（变量化，跟随主题） ---------- */
#app .pd-hero{background:linear-gradient(112deg,var(--th-p1) 0%,var(--th-p2) 45%,var(--th-p3) 100%);color:var(--th-ink);
  border-color:var(--th-accentSoft);box-shadow:0 8px 22px var(--th-shadow)}
#app .pd-hero h1,#app .pd-hero-period{color:var(--th-ink)}
#app .pd-hero p{color:var(--th-muted)}
#app .pd-hero-label{color:var(--th-muted);border-right-color:var(--th-accentSoft)}
#app .pd-filter-card{border-color:var(--th-line);border-top-color:var(--th-accent);box-shadow:0 2px 7px var(--th-shadow)}
#app .pd-filter select:focus,#app .pd-filter input:focus{border-color:var(--primary-2);box-shadow:0 0 0 2px var(--th-accentGlow)}
#app .pd-kpi{border-color:var(--th-line);box-shadow:0 3px 9px var(--th-shadow)}
#app .pd-kpi.blue{--tone:var(--th-accent)}
#app .pd-kpi.sky{--tone:var(--th-accent2)}
#app .pd-kpi.green{--tone:var(--th-accentDark)}
#app .pd-kpi.teal{--tone:var(--th-accent3)}
#app .pd-kpi.blue .pd-kpi-ico,#app .pd-kpi.sky .pd-kpi-ico,#app .pd-kpi.green .pd-kpi-ico,#app .pd-kpi.teal .pd-kpi-ico{background:var(--th-p1);color:var(--tone)}
#app .pd-kpi.blue .pd-kpi-value,#app .pd-kpi.sky .pd-kpi-value,#app .pd-kpi.green .pd-kpi-value,#app .pd-kpi.teal .pd-kpi-value{color:var(--th-ink)}
#app .pd-kpi[data-go]:hover{border-color:var(--tone);box-shadow:0 6px 16px var(--th-shadow)}
#app .pd-delta.up{color:var(--th-accentDark)!important}
#app .pd-panel{border-color:var(--th-line);box-shadow:0 3px 10px var(--th-shadow)}
#app .pd-panel-head,#app .pd-table-head{background:linear-gradient(92deg,var(--th-p1) 0%,var(--th-p2) 58%,var(--th-p3) 100%);border-bottom-color:var(--th-accentSoft);color:var(--th-ink)}
#app .pd-panel-head h3,#app .pd-panel-head h3 i,#app .pd-table-head h3,#app .pd-table-head h3 i{color:var(--th-ink)}
#app .pd-panel-head h3 i,#app .pd-table-head h3 i{background:var(--th-accent);box-shadow:0 0 7px var(--th-accentGlow)}
#app .pd-panel-note{color:var(--th-muted)}
#app .pd-rank-no.top{background:var(--th-accent);color:#fff}
#app .pd-budget-legend i.plan{background:var(--th-p2)}
#app .pd-budget-legend i.act{background:var(--th-accent)}
#app .pd-chart-legend i.bar{background:var(--th-chart-bar)}
#app .pd-chart-legend i.dot{background:var(--th-chart-line)}
#app .pd-table-panel table.grid th{background:linear-gradient(180deg,var(--th-p1),var(--th-p2));color:var(--th-headInk);border-right-color:var(--th-accentGlow)}
#app .pd-table-panel table.grid tbody tr:hover td{background:var(--th-rowHover)}
#app .pd-docno{color:var(--th-accentDark)}
#app .pd-warn-num{color:#b8842e}
#app .pd-pager{background:var(--th-rowEven);border-top-color:var(--th-line)}
#app .pd-page-btn:hover:not(:disabled){border-color:var(--th-accentSoft);color:var(--th-accentDark)}
#app .pd-page-btn.on{background:var(--th-accent);border-color:var(--th-accent);color:#fff;font-weight:700}
#app .pd-filter-actions .btn-primary{background:var(--primary-2);border-color:var(--primary-2)}
#app .pd-filter-actions .btn-primary:hover{background:var(--primary);border-color:var(--primary)}

/* ---------- 主题切换按钮 ---------- */
#app .top-btn.theme-btn{min-width:34px;padding:6px 9px;font-size:14px;line-height:1}
#theme-menu{position:fixed;top:54px;right:16px;z-index:210;width:228px;padding:10px;border-radius:10px;
  background:#fff;border:1px solid var(--th-line);box-shadow:0 16px 44px rgba(20,40,60,.22);animation:pop .16s ease-out}
#theme-menu .tm-title{font-size:11px;color:var(--th-muted);letter-spacing:1px;margin:2px 4px 8px;font-weight:700}
#theme-menu .tm-grid{display:grid;grid-template-columns:1fr 1fr;gap:6px}
#theme-menu .tm-item{display:flex;align-items:center;gap:7px;padding:7px 8px;border:1px solid var(--line);border-radius:7px;
  background:#fff;cursor:pointer;font-size:11.5px;color:var(--text);transition:background .15s,border-color .15s}
#theme-menu .tm-item:hover{border-color:var(--primary-2);background:var(--th-p1)}
#theme-menu .tm-item.on{border-color:var(--primary-2);background:var(--th-p1);color:var(--primary);font-weight:700}
#theme-menu .tm-dot{width:14px;height:14px;border-radius:50%;flex:0 0 14px;border:1px solid rgba(0,0,0,.08)}
#theme-menu .tm-foot{margin:9px 3px 1px;font-size:10px;color:var(--th-muted);text-align:center}

/* ============================================================
 * 所有页面表格：浅灰细线（仅屏幕显示；打印 / 导出表格保持原样）
 * 恢复系统最初的浅灰 1px 实线：竖列分隔线 + 横行分隔线
 * ============================================================ */
@media screen{
  #app table.grid th,
  #modal-root table.grid th{border:0 !important;border-top:1px solid #d7e4f2 !important;border-right:1px solid #d7e4f2 !important;border-bottom:1px solid #d7e4f2 !important}
  #app table.grid td,
  #modal-root table.grid td{border:0 !important;border-right:1px solid #e7eef6 !important;border-bottom:1px solid #e7eef6 !important}
  #app table.grid tr>:first-child,
  #modal-root table.grid tr>:first-child{border-left:1px solid #e7eef6 !important}
  #app table.grid thead tr>th:first-child,
  #modal-root table.grid thead tr>th:first-child{border-left-color:#d7e4f2 !important}
  #app table.grid tbody tr:last-child td,
  #modal-root table.grid tbody tr:last-child td{border-bottom:0 !important}
  #app table.grid tfoot td,
  #modal-root table.grid tfoot td{border-top:2px solid #c9dcf0 !important}
  #app .doc-items th,
  #modal-root .doc-items th{border:1px solid #d7e4f2 !important}
  #app .doc-items td,
  #modal-root .doc-items td{border:1px solid #e3ebf4 !important}
  #app .mini-list td,
  #modal-root .mini-list td{border-bottom:1px solid #eaf0f7 !important}
  #app .mini-list tr:last-child td,
  #modal-root .mini-list tr:last-child td{border-bottom:0 !important}
  #app .pick-list th,
  #modal-root .pick-list th{border-bottom:1px solid #d7e4f2 !important}
  #app .pick-list td,
  #modal-root .pick-list td{border-top:1px solid #e7eef6 !important}
  #app .table-scroll,
  #modal-root .table-scroll{border:1px solid var(--line) !important}
}
