:root {
  --navy: #12263a;
  --primary: #2e5e8c;
  --accent: #c0504d;
  --teal: #4bacc6;
  --green: #9bbb59;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #22303f;
  --muted: #7b8794;
  --line: #e7ecf2;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- 固定侧边栏 ---------- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 224px;
  height: 100vh;
  overflow: hidden;
  background: var(--navy);
  color: #dbe6f0;
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 10;
}

.brand { display: flex; gap: 10px; align-items: center; padding: 0 4px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #2e5e8c, #4bacc6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: 1px; color: #fff; font-size: 14px;
}
.brand strong { display: block; font-size: 14px; color: #fff; line-height: 1.3; }
.brand small { display: block; font-size: 10.5px; color: #8fa6bd; margin-top: 2px; }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: #b9cadb; text-decoration: none; font-size: 13.5px;
  padding: 10px 13px; border-radius: 8px; transition: background .15s ease, color .15s ease;
  display: block;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar-foot {
  margin-top: auto; font-size: 10.5px; line-height: 1.6; color: #7f95ab;
  padding: 0 4px;
}

/* ---------- 主区域：独立滚动、隐藏滚动条 ---------- */
.main {
  margin-left: 224px;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 26px 24px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.main::-webkit-scrollbar { width: 0; height: 0; display: none; }

.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.topbar h1 { margin: 0; font-size: 23px; letter-spacing: .5px; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; }
.stamp {
  font-size: 11.5px; color: var(--primary); border: 1px solid #c9d8e6;
  padding: 5px 11px; border-radius: 18px; background: #eef4fa; white-space: nowrap;
}

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px; margin-bottom: 14px;
}
.kpi-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi {
  background: var(--card); border-radius: 11px; padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(18,38,58,.05); border: 1px solid var(--line);
}
.kpi span { display: block; color: var(--muted); font-size: 11.5px; }
.kpi strong { display: block; font-size: 23px; margin: 6px 0 1px; color: var(--navy); font-weight: 700; }
.kpi small { color: #9aa7b4; font-size: 10.5px; }

/* ---------- 布局 ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-2.tight { margin-bottom: 12px; }
.grid-predict { display: grid; grid-template-columns: 1.12fr 1fr; gap: 14px; margin-bottom: 14px; }

.card {
  background: var(--card); border-radius: 11px; padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(18,38,58,.05); border: 1px solid var(--line);
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 14.5px; color: var(--navy); font-weight: 600; }
.chart { width: 100%; height: 290px; }
.chart.tall { height: 380px; }
.chart.short { height: 240px; }

/* ---------- 表格 ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfd;
  position: sticky; top: 0; z-index: 1;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid #f1f4f8; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table.compact td, .data-table.compact th { padding: 6px 9px; font-size: 11.5px; }
.ellipsis { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { color: var(--muted); font-size: 11.5px; max-width: 230px; }

.scroll-area { max-height: 380px; overflow-y: auto; scrollbar-width: none; }
.scroll-area::-webkit-scrollbar { display: none; }

/* ---------- 表单 ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filter-bar select, .filter-bar input {
  padding: 8px 11px; border: 1px solid #d9e2ec; border-radius: 7px;
  font-size: 12.5px; background: #fff; color: var(--text); min-width: 112px;
}
.filter-bar button {
  padding: 8px 18px; border: none; border-radius: 7px; background: var(--primary);
  color: #fff; font-size: 12.5px; cursor: pointer;
}
.filter-bar button:hover { background: #26507a; }
.filter-bar .reset { align-self: center; font-size: 12.5px; color: var(--muted); text-decoration: none; }

.pager { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 12.5px; }
.pager a { color: var(--primary); text-decoration: none; padding: 5px 11px; border: 1px solid #d9e2ec; border-radius: 6px; }
.pager a.disabled { color: #c3ccd6; border-color: #eef1f5; pointer-events: none; }
.pager span { color: var(--muted); }

.predict-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.predict-form label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); }
.predict-form input, .predict-form select {
  padding: 9px 11px; border: 1px solid #d9e2ec; border-radius: 7px; font-size: 13.5px; color: var(--text);
}
.predict-form .checks { grid-column: 1 / -1; display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text); }
.predict-form .checks label { flex-direction: row; align-items: center; gap: 5px; }
.predict-form button {
  grid-column: 1 / -1; padding: 11px; border: none; border-radius: 7px;
  background: var(--primary); color: #fff; font-size: 13.5px; cursor: pointer;
}
.predict-form button:hover { background: #26507a; }

.result-card { display: flex; flex-direction: column; }
.result-empty { color: #9aa7b4; font-size: 12.5px; padding: 34px 0; text-align: center; }
.result-main { text-align: center; padding: 12px 0 8px; }
.result-main span { display: block; font-size: 11.5px; color: var(--muted); }
.result-main strong { display: block; font-size: 36px; color: var(--accent); margin: 4px 0 1px; }
.result-main small { color: #9aa7b4; font-size: 11.5px; }
.result-sub { display: flex; justify-content: space-between; padding: 10px 4px; border-top: 1px dashed var(--line); font-size: 12.5px; }
.result-sub span { color: var(--muted); }
.error { color: var(--accent); font-size: 12.5px; }
.note { font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.static-notice {
  margin: -2px 0 12px; padding: 9px 13px; border: 1px solid #dbe7f3;
  border-radius: 8px; background: #f2f7fc; color: #52677c;
}
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* ---------- 标签页 ---------- */
.tab-card { padding-top: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab {
  border: none; background: transparent; padding: 9px 16px; font-size: 13px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  font-family: inherit;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 任务页 ---------- */
.action-card p { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin: 0 0 12px; }
.btn {
  border: 1px solid #d3dfeb; background: #fff; color: var(--primary);
  padding: 9px 18px; border-radius: 8px; font-size: 13px; cursor: pointer; font-family: inherit;
  transition: all .15s ease;
}
.btn:hover { background: #f2f7fc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #26507a; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.job-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.job-head h2 { margin: 0; }
.job-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.badge { padding: 3px 10px; border-radius: 12px; background: #eef2f7; color: #5b6b7c; font-size: 11.5px; }
.badge.running { background: #e8f2fb; color: #2e5e8c; }
.badge.done { background: #edf6e6; color: #4f7a20; }
.badge.error { background: #fbeceb; color: #a33c39; }

.progress { height: 4px; background: #eef2f7; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.progress div { height: 100%; width: 0; background: var(--primary); transition: width .3s ease; }
.progress div.idle { width: 0; }
.progress div.running { width: 100%; background: linear-gradient(90deg, #dce9f5, #2e5e8c, #dce9f5); background-size: 200% 100%; animation: flow 1.4s linear infinite; }
.progress div.done { width: 100%; background: #7aa84f; }
.progress div.error { width: 100%; background: #c0504d; }
@keyframes flow { 0% { background-position: 0 0; } 100% { background-position: 200% 0; } }

.console {
  margin: 0; padding: 12px 14px; height: 340px; overflow-y: auto;
  background: #0f1c2a; color: #cfe0f0; border-radius: 8px;
  font-family: Consolas, "Courier New", monospace; font-size: 12px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-all;
  scrollbar-width: none;
}
.console::-webkit-scrollbar { display: none; }
.job-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ---------- 加载遮罩 ---------- */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(18, 38, 58, .28);
  display: flex; align-items: center; justify-content: center; z-index: 999;
  backdrop-filter: blur(1.5px);
}
.loading-overlay[hidden] { display: none; }
.loading-box {
  background: #fff; border-radius: 12px; padding: 22px 30px; min-width: 190px;
  text-align: center; box-shadow: 0 12px 34px rgba(18,38,58,.24);
}
.loading-box p { margin: 12px 0 0; font-size: 13px; color: #405060; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto; border-radius: 50%;
  border: 3px solid #e3ebf3; border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2, .grid-predict { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  html, body { overflow: auto; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-foot { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .main { margin-left: 0; height: auto; overflow: visible; padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
