/* 股票多公式监控系统 — 设计系统（参考 Element Plus / Vben Admin） */
:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e5e8ef;
  --border-light: #f0f2f6;
  --text: #26303e;
  --text-2: #5a6577;
  --muted: #8a94a6;
  --primary: #2f6fed;
  --primary-weak: #e8f0fe;
  --green: #18a058;
  --green-weak: #e8f7ef;
  --red: #d03050;
  --red-weak: #fdecef;
  --orange: #f0a020;
  --orange-weak: #fdf3e3;
  --purple: #7c3aed;
  --purple-weak: #f1e9fd;
  --gray: #9096a3;
  --gray-weak: #f0f2f5;
  --radius: 10px;
  --shadow-1: 0 1px 2px rgba(16,24,40,.04);
  --shadow-2: 0 4px 16px rgba(16,24,40,.08);
  --sidebar-w: 216px;
  --sidebar-bg: #151c2c;
}
[data-theme="dark"] {
  --bg: #10141d;
  --card: #1a2029;
  --border: #2a3341;
  --border-light: #232b38;
  --text: #dbe2ec;
  --text-2: #a8b3c4;
  --muted: #6d7889;
  --primary-weak: #1d2b45;
  --green-weak: #12271c;
  --red-weak: #2e1720;
  --orange-weak: #2d2312;
  --purple-weak: #221a33;
  --gray-weak: #232b38;
  --shadow-1: none;
  --shadow-2: 0 4px 16px rgba(0,0,0,.4);
  --sidebar-bg: #0c1017;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(128,140,160,.35); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 应用壳：侧栏固定，内容独立滚动 ---------- */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: #cdd3e0;
  flex-shrink: 0; display: flex; flex-direction: column;
  transition: width .18s ease, transform .18s ease;
}
body.side-collapsed .sidebar { width: 64px; }
body.side-collapsed .sidebar .logo-text, body.side-collapsed .menu-label,
body.side-collapsed .sidebar .foot-user { display: none; }
body.side-collapsed .sidebar nav a { justify-content: center; padding: 11px 0; }
.sidebar .logo {
  padding: 16px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07); overflow: hidden; white-space: nowrap;
}
.sidebar .logo svg { width: 30px; height: 30px; flex-shrink: 0; }
.sidebar .logo-text { font-size: 14.5px; font-weight: 600; color: #fff; line-height: 1.25; }
.sidebar .logo-text small { display: block; font-weight: 400; font-size: 10.5px; color: #7f8ba3; letter-spacing: .4px; }
.sidebar nav { flex: 1; padding: 10px 0; overflow-y: auto; overflow-x: hidden; }
.menu-label { padding: 12px 20px 4px; font-size: 11px; color: #5d6a82; letter-spacing: 1px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; margin: 2px 8px; padding: 9px 12px;
  color: #cdd3e0; font-size: 13.5px; border-radius: 8px; white-space: nowrap;
}
.sidebar nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; font-weight: 500; }
.sidebar nav a.active svg { opacity: 1; }
.sidebar .foot { padding: 12px 16px; font-size: 12px; color: #7f8ba3; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar .foot-user { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.topbar {
  height: 52px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  flex-shrink: 0; gap: 10px;
}
.topbar .crumb { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; min-width: 0; }
.topbar .crumb .sys { color: var(--muted); font-weight: 400; }
.topbar .crumb .sep { color: var(--muted); font-weight: 400; }
.topbar .tools { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 7px; border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--gray-weak); color: var(--primary); }
.icon-btn svg { width: 17px; height: 17px; }
.hamburger { display: none; }
.topbar .user { color: var(--muted); font-size: 13px; }
.content { flex: 1; padding: 16px 20px 28px; overflow-y: auto; }
.page { animation: pageIn .18s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 顶部进度条 ---------- */
#nprogress-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 999;
  background: linear-gradient(90deg, #2f6fed, #22c1dc);
  border-radius: 0 2px 2px 0; transition: width .2s ease, opacity .3s ease;
  box-shadow: 0 0 8px rgba(47,111,237,.6);
}

/* ---------- 卡片与统计 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-1);
}
.card h3 { font-size: 14px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h3 .sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-1); display: flex; gap: 12px; align-items: flex-start;
}
.stat .stat-ico {
  width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat .stat-ico svg { width: 19px; height: 19px; }
.stat .num { font-size: 24px; font-weight: 700; margin-top: 2px; line-height: 1.15; }
.stat .lbl { color: var(--muted); font-size: 12.5px; }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; color: var(--text-2); font-weight: 500; padding: 9px 10px;
  background: var(--gray-weak); white-space: nowrap;
}
table.tbl th:first-child { border-radius: 6px 0 0 6px; }
table.tbl th:last-child { border-radius: 0 6px 6px 0; }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
table.tbl tbody tr:hover td { background: var(--primary-weak); }

/* ---------- 徽章 / 芯片 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; line-height: 18px; white-space: nowrap; }
.badge.green { background: var(--green-weak); color: var(--green); }
.badge.red { background: var(--red-weak); color: var(--red); }
.badge.orange { background: var(--orange-weak); color: #b97a0d; }
.badge.gray { background: var(--gray-weak); color: var(--gray); }
.badge.blue { background: var(--primary-weak); color: var(--primary); }
.badge.purple { background: var(--purple-weak); color: var(--purple); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--gray-weak); color: var(--text-2); border-radius: 5px; padding: 2px 8px; font-size: 11.5px; font-family: Consolas, monospace; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); border-radius: 7px; padding: 6px 14px; font-size: 13px; cursor: pointer; transition: all .12s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { opacity: .88; color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
input, select, textarea {
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; font-size: 13px;
  font-family: inherit; background: var(--card); color: var(--text); outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
textarea.code { font-family: "JetBrains Mono", Consolas, monospace; font-size: 13px; line-height: 1.55; min-height: 260px; white-space: pre; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
input[type="checkbox"] { width: auto; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; top: 16px; right: 16px; z-index: 999; background: #26303e; color: #fff;
  border-radius: 8px; padding: 11px 18px; font-size: 13px; box-shadow: var(--shadow-2); max-width: 420px;
  animation: toastIn .18s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,20,30,.5); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto;
}
.modal {
  background: var(--card); border-radius: 12px; width: 720px; max-width: 96vw; padding: 20px 22px;
  box-shadow: var(--shadow-2); animation: pageIn .16s ease;
}
.modal h3 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- 错误/告警块 ---------- */
.err-list { background: var(--red-weak); border: 1px solid #f5c6cb; color: var(--red); border-radius: 6px; padding: 10px 12px; font-size: 12.5px; margin-top: 10px; white-space: pre-wrap; }
.warn-list { background: var(--orange-weak); border: 1px solid #f2ddc0; color: #b97a0d; border-radius: 6px; padding: 10px 12px; font-size: 12.5px; margin-top: 10px; }
[data-theme="dark"] .warn-list { border-color: #4a3c1a; }
.ok-list { background: var(--green-weak); border: 1px solid #bfe8cf; color: var(--green); border-radius: 6px; padding: 10px 12px; font-size: 12.5px; margin-top: 10px; }

/* ---------- 骨架屏 ---------- */
.sk { position: relative; overflow: hidden; background: var(--gray-weak); border-radius: 6px; }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  animation: shimmer 1.2s infinite;
}
[data-theme="dark"] .sk::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.sk-stat { height: 76px; }
.sk-line { height: 14px; margin: 10px 0; }
.sk-line.w60 { width: 60%; } .sk-line.w80 { width: 80%; }

/* ---------- 空状态 ---------- */
.empty {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 34px 20px;
  text-align: center; color: var(--muted); font-size: 13px;
}
.empty svg { width: 34px; height: 34px; opacity: .45; margin-bottom: 8px; }
.empty .empty-action { margin-top: 12px; }

/* ---------- 图表 ---------- */
.chart { width: 100%; height: 420px; }
.chart-loading { height: 420px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; gap: 8px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 其他 ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.mt { margin-top: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: flex-end; }
.filters .field { min-width: 130px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.rel-time { cursor: default; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, #2b3a5c 0%, #151c2c 55%), var(--sidebar-bg);
  padding: 20px;
}
.login-card-zone { display: flex; gap: 60px; align-items: center; max-width: 880px; width: 100%; justify-content: center; flex-wrap: wrap; }
.login-brand { color: #e6ebf5; max-width: 340px; }
.login-brand h1 { font-size: 24px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.login-brand h1 svg { width: 34px; height: 34px; }
.login-brand p { color: #97a3ba; font-size: 13.5px; line-height: 1.9; }
.login-brand ul { list-style: none; margin-top: 14px; }
.login-brand li { color: #aab5c8; font-size: 12.5px; padding: 4px 0; display: flex; gap: 8px; align-items: center; }
.login-brand li svg { width: 14px; height: 14px; color: #22c1dc; flex-shrink: 0; }
.login-box { background: var(--card); border-radius: 14px; padding: 32px 34px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-box h2 { font-size: 18px; margin-bottom: 4px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-box .field { margin-bottom: 14px; }
.login-box .btn { width: 100%; justify-content: center; padding: 9px; font-size: 14px; }

/* ---------- 移动端 ---------- */
.side-backdrop { display: none; }
@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  .sidebar { position: fixed; z-index: 60; height: 100vh; transform: translateX(-100%); width: var(--sidebar-w) !important; }
  body.side-open .sidebar { transform: translateX(0); }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  body.side-collapsed .sidebar nav a { justify-content: flex-start; padding: 9px 12px; }
  body.side-collapsed .menu-label, body.side-collapsed .sidebar .logo-text, body.side-collapsed .sidebar .foot-user { display: block; }
  .content { padding: 12px; }
  .kv { grid-template-columns: 100px 1fr; }
  .login-brand { display: none; }
}
