:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --line: #e6e8ec;
  --line-2: #f0f1f4;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #8a93a3;
  --primary: #1f6feb;
  --primary-2: #e8f0fe;
  --primary-ink: #ffffff;
  --ok: #0f8a4a;   --ok-bg: #e7f6ee;
  --warn: #b26a00; --warn-bg: #fff4e0;
  --bad: #c62f2f;  --bad-bg: #fdecec;
  --run: #1f6feb;  --run-bg: #e8f0fe;
  --muted-bg: #f1f2f5;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 20px; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; color: var(--text); white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #1f6feb, #6250d6);
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; letter-spacing: -.5px;
}
.brand small { font-weight: 500; color: var(--text-3); font-size: 12px; margin-left: 2px; }
.topnav { display: flex; gap: 4px; height: 100%; }
.topnav a {
  display: flex; align-items: center; padding: 0 12px; color: var(--text-2); border-bottom: 2px solid transparent; height: 100%;
}
.topnav a:hover { color: var(--text); }
.topnav a.on { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary-2); color: var(--primary);
  display: grid; place-items: center; font-weight: 650; font-size: 13px; text-transform: uppercase;
}
.linkbtn { background: none; border: 0; padding: 0; color: var(--text-3); cursor: pointer; }
.linkbtn:hover { color: var(--text); }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: calc(100vh - 56px); }
.side {
  width: 208px; flex: none; background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px;
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.side h6 { margin: 18px 10px 6px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.side h6:first-child { margin-top: 4px; }
.side a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); margin-bottom: 2px;
}
.side a svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; }
.side a:hover { background: var(--line-2); color: var(--text); }
.side a.on { background: var(--primary-2); color: var(--primary); font-weight: 600; }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.page-title { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.page-title h1 { font-size: 18px; font-weight: 650; margin: 0; }
.page-title .spacer { flex: 1; }

/* ---------- 卡片与统计 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-h .sub { color: var(--text-3); font-size: 12.5px; }
.card-h .spacer { flex: 1; }
.card-b { padding: 16px 20px 20px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { padding: 16px 18px; }
.stat .k { color: var(--text-3); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 650; margin-top: 8px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.stat .d { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-32 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
@media (max-width: 1200px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid2, .grid-32 { grid-template-columns: 1fr; } }

/* ---------- 表单控件 ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.input, .select {
  height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 10px; min-width: 0; outline: none;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.select { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.daterange { display: inline-flex; align-items: center; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 4px; }
.daterange input { border: 0; height: 30px; outline: none; background: transparent; width: 128px; padding: 0 6px; }
.daterange span { color: var(--text-3); }
.btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text);
}
.btn:hover { border-color: #cfd3da; background: #fafbfc; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: #1a5fd0; }
.btn.danger { color: var(--bad); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.iconbtn { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--text-3); cursor: pointer; }
.iconbtn:hover { background: var(--line-2); color: var(--text); }
.iconbtn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-2); }
.field .input { height: 36px; width: 100%; }
.field .hint { font-size: 12px; color: var(--text-3); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.switch { position: relative; width: 34px; height: 20px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #cfd4dc; border-radius: 20px; cursor: pointer; transition: .15s; }
.switch i::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(14px); }
.checks { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th {
  text-align: left; font-weight: 600; color: var(--text-2); font-size: 13px; padding: 11px 14px; background: #fafbfc;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
table.t td.wrap { white-space: normal; min-width: 160px; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #fafcff; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr.click { cursor: pointer; }
.empty { padding: 56px 0; text-align: center; color: var(--text-3); }
.empty svg { width: 40px; height: 40px; stroke: #c5cad3; fill: none; stroke-width: 1.3; display: block; margin: 0 auto 8px; }
.table-foot { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line-2); color: var(--text-3); font-size: 13px; }
.table-foot .spacer { flex: 1; }
.pager { display: flex; gap: 4px; align-items: center; }
.pager button { min-width: 30px; height: 30px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; cursor: pointer; padding: 0 8px; }
.pager button.on { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.pager button[disabled] { opacity: .45; cursor: default; }

/* ---------- 标签 ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; background: var(--muted-bg); color: var(--text-2); }
.tag.blue { background: var(--primary-2); color: var(--primary); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.run { background: var(--run-bg); color: var(--run); }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* ---------- 弹窗 / 抽屉 / 提示 ---------- */
.mask { position: fixed; inset: 0; background: rgba(17, 24, 39, .35); z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal { width: 460px; max-width: 100%; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.modal.wide { width: 640px; }
.modal-h { display: flex; align-items: center; padding: 18px 20px 6px; }
.modal-h h3 { margin: 0; font-size: 16px; font-weight: 650; flex: 1; }
.modal-b { padding: 12px 20px 4px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.drawer-mask { position: fixed; inset: 0; background: rgba(17,24,39,.25); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 760px; max-width: 100vw; background: var(--bg); z-index: 41; overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.12); }
.drawer-h { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 14px 20px; z-index: 2; }
.drawer-h h3 { margin: 0; font-size: 16px; flex: 1; }
.drawer-b { padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 16px; }
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 80; background: #111827; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast.err { background: var(--bad); }
.keybox { display: flex; align-items: center; gap: 8px; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: var(--mono); font-size: 13px; word-break: break-all; }
.keybox span { flex: 1; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 10px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login { width: 380px; max-width: 100%; padding: 32px 30px 28px; }
.login .brand { justify-content: center; font-size: 18px; margin-bottom: 6px; }
.login p.sub { text-align: center; color: var(--text-3); margin: 0 0 24px; }
.login .btn { width: 100%; justify-content: center; height: 38px; margin-top: 6px; }
.login .err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

/* ---------- 图表 ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: #eef0f3; stroke-width: 1; }
.chart .axis text { fill: var(--text-3); font-size: 11px; }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar:hover, .chart .col.hover rect { filter: brightness(1.08); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(16,24,40,.1); padding: 8px 10px; font-size: 12.5px; min-width: 150px; z-index: 5; white-space: nowrap;
}
.tip .h { color: var(--text-3); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.tip .r i { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tip .r b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tip .r span { color: var(--text-3); }

/* ---------- 素材 ---------- */
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.glist { max-height: calc(100vh - 210px); overflow-y: auto; padding: 6px; }
.gitem { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.gitem:hover { background: var(--line-2); }
.gitem.on { background: var(--primary-2); }
.gitem .n { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.gitem .n .c { margin-left: auto; color: var(--text-3); font-weight: 400; font-size: 12.5px; }
.gitem .i { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--muted-bg); display: grid; place-items: center; color: var(--text-3); flex: none; }
.thumb svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.cell-flex { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-flex .t1 { font-weight: 550; }
.cell-flex .t2 { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
iframe.docs { width: 100%; height: calc(100vh - 170px); border: 0; background: #fff; border-radius: var(--radius); }
