/* ==========================================================================
   SAG 设计系统 v2 —— 现代 SaaS 视觉语言
   令牌 / 基础 / 组件 / 外壳 / 数据展示 / 反馈
   ========================================================================== */

:root {
  /* 中性色 */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --surface-3: #f2f4f7;
  --line: #e9ecf2;
  --line-strong: #dbe1ea;
  --text: #0f172a;
  --text-2: #475467;
  --text-3: #98a2b3;

  /* 品牌与语义 */
  --brand: #335cff;
  --brand-600: #2749d8;
  --brand-50: #eef2ff;
  --ok: #12b76a;
  --ok-50: #ecfdf3;
  --warn: #f79009;
  --warn-50: #fffaeb;
  --danger: #f04438;
  --danger-50: #fef3f2;

  /* 形状与阴影 */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
  --ring: 0 0 0 3px rgba(51, 92, 255, 0.16);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 13.5px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); }
button { font: inherit; cursor: pointer; }
h1, h2, h3, b, strong { letter-spacing: -0.01em; }
::selection { background: rgba(51, 92, 255, 0.16); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #dfe3ea; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #cbd2dd; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- 基础 */
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pad { padding: 18px 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: #cdd5e1; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(51, 92, 255, .35), inset 0 1px 0 rgba(255,255,255,.12); }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--danger); border-color: #f6c9c5; }
.btn.danger:hover { background: var(--danger-50); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------------------------------------------------------------- 表单 */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--text-3); }
input, select, textarea { font: inherit; color: var(--text); }
.field input, .field select, .field textarea, .input {
  height: 36px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; padding: 9px 11px; line-height: 1.6; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--brand); box-shadow: var(--ring);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.toolbar input, .toolbar select {
  height: 34px; padding: 0 11px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface); font-size: 13px; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); box-shadow: var(--ring); }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
}
.card.hover:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-b { padding: 14px 20px 18px; }

/* ---------------------------------------------------------------- 徽标 */
.tag, .pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: var(--brand-50); color: var(--brand-600);
  white-space: nowrap;
}
.tag.ok, .pill.g { background: var(--ok-50); color: #067647; }
.tag.warn, .pill.a { background: var(--warn-50); color: #b54708; }
.tag.danger, .pill.r { background: var(--danger-50); color: #b42318; }
.pill.n { background: var(--surface-3); color: var(--text-2); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------------------------------------------------------------- 外壳 */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh; overflow: auto;
  padding: 16px 12px;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}
.side .brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 14px;
  font-size: 14.5px; font-weight: 650; color: var(--text);
}
.side .brand i {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #335cff, #6f8bff);
  box-shadow: 0 2px 6px rgba(51, 92, 255, .35), inset 0 1px 0 rgba(255,255,255,.28);
  position: relative;
}
.side .brand i::after {
  content: ""; position: absolute; inset: 7px; border-radius: 4px;
  background: radial-gradient(circle at 50% 45%, #fff 0 2px, transparent 2.4px) 0 0 / 8px 8px;
}
.side .who {
  display: flex; justify-content: space-between; gap: 8px;
  margin: 0 4px 12px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); box-shadow: var(--shadow-xs);
  font-size: 12.5px; color: var(--text-2);
}
.side .who span:first-child { white-space: nowrap; flex: none; font-weight: 600; color: var(--text); }
.side .who span:last-child { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.nav-g {
  margin: 16px 10px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-3); text-transform: uppercase;
}
.nav-i {
  display: flex; align-items: center; gap: 9px; width: 100%;
  height: 34px; padding: 0 10px; margin: 1px 0;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; color: var(--text-2);
  font-size: 13.5px; text-align: left;
  transition: background .14s, color .14s, box-shadow .14s;
}
.nav-i svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.nav-i:hover { background: var(--surface-3); color: var(--text); }
.nav-i.on {
  background: var(--surface); color: var(--text);
  border-color: var(--line); box-shadow: var(--shadow-xs); font-weight: 600;
}
.nav-i.on svg { opacity: 1; color: var(--brand); }
.nav-i em {
  margin-left: auto; font-style: normal; font-size: 11px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--brand); color: #fff;
}
.nav-i.exit { color: var(--text-3); }
.nav-i.exit:hover { color: var(--danger); background: var(--danger-50); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  height: 56px; padding: 0 24px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); }
.crumb b { color: var(--text); font-weight: 600; }
.crumb .sep { color: var(--line-strong); }

.searchbox {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 11px; width: 250px;
  background: var(--surface-3); border: 1px solid transparent; border-radius: var(--r-sm);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.searchbox:focus-within { background: var(--surface); border-color: var(--brand); box-shadow: var(--ring); }
.searchbox svg { width: 15px; height: 15px; stroke: var(--text-3); fill: none; stroke-width: 1.8; }
.searchbox input { width: 100%; border: 0; background: none; outline: none; font-size: 13px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #dbe7ff, #c7d8ff);
  color: var(--brand-600); font-size: 12.5px; font-weight: 650;
  border: 1px solid #c7d8ff;
}

.main { padding: 24px 28px 72px; min-width: 0; }
.ph { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.ph h1 { margin: 0; font-size: 21px; font-weight: 650; }
.ph .sub { margin-top: 4px; font-size: 13px; color: var(--text-3); }

.sec { display: none; }
.sec.on { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- 数据展示 */
.kpi { padding: 16px 18px; }
.kpi .l { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.kpi .n { margin-top: 8px; font-size: 27px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .d { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.kpi .d.up { color: #067647; }
.kpi .d.down { color: #b42318; }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 11px 14px; vertical-align: middle; }
th {
  font-size: 12px; font-weight: 600; color: var(--text-3);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { border-bottom: 1px solid var(--line); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }
.tablewrap { overflow: auto; border-radius: var(--r); }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 12px 2px 0; }
.chart .bar { max-width: 34px; }
.chart .bar {
  flex: 1; min-height: 3px; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, #8fa8ff, #335cff);
  position: relative; opacity: .9; transition: opacity .15s, transform .15s;
}
.chart .bar:hover { opacity: 1; transform: scaleY(1.02); transform-origin: bottom; }
.chart .bar:hover::after {
  content: attr(data-v); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); padding: 3px 7px; border-radius: 6px;
  background: var(--text); color: #fff; font-size: 11px; white-space: nowrap;
  box-shadow: var(--shadow-md); z-index: 2;
}

.bars { display: flex; flex-direction: column; gap: 10px; }
.bars .b { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 52px; align-items: center; gap: 10px; font-size: 12.5px; }
.bars .b > span:first-child { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .b i { display: block; height: 8px; border-radius: 999px; background: linear-gradient(90deg, #dbe4ff, #335cff); }
.bars .b > span:last-child { text-align: right; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.empty {
  display: grid; place-items: center; gap: 6px;
  padding: 44px 20px; text-align: center;
  color: var(--text-3); font-size: 13px;
}
.empty b { display: block; color: var(--text-2); font-weight: 600; font-size: 13.5px; }

/* ---------------------------------------------------------------- 反馈 */
.toast {
  position: fixed; left: 50%; bottom: 30px; z-index: 999;
  transform: translateX(-50%) translateY(14px);
  padding: 10px 16px; border-radius: 10px;
  background: #101828; color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: min(560px, calc(100vw - 40px));
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b42318; }

.skeleton { border-radius: 8px; background: linear-gradient(90deg, #f1f3f7 25%, #e9ecf2 37%, #f1f3f7 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand, .side .who, .nav-g { display: none; }
  .nav-i { width: auto; white-space: nowrap; }
  .searchbox { display: none; }
  .main { padding: 18px 16px 60px; }
  .ph { flex-direction: column; align-items: flex-start; }
}

/* ---- 设置页组件 ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { height: 34px; padding: 0 12px; border: 0; background: none; color: var(--text-2); font-size: 13.5px;
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.pane { display: none; }
.pane.on { display: block; }
.pane h4 { margin: 0 0 14px; font-size: 14px; font-weight: 600; }
#set-body h4 span { display: block; font-weight: 400; color: var(--text-3); font-size: 12.5px; margin-top: 4px; }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.set-grid .field.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; margin: 4px 0 18px; }
.note { background: var(--surface-3); border-radius: 10px; padding: 10px 12px; color: var(--text-2);
  font-size: 12.5px; line-height: 1.65; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin-bottom: 14px; }
.switch input { width: 16px; height: 16px; accent-color: var(--brand); }
@media (max-width: 860px) { .set-grid { grid-template-columns: 1fr; } }

.pane h4 span { display: block; margin: 4px 0 0; font-weight: 400; color: var(--text-3); font-size: 12.5px; }

[hidden] { display: none !important; }

.checklist { display: grid; gap: 6px; margin-top: 6px; max-height: 220px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 3px 2px; cursor: pointer; }
.chk input { width: 15px; height: 15px; accent-color: var(--brand); }
.checklist+.row { margin-top: 8px; }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.c3 { grid-template-columns: 1fr; } }

.wbadge, .gbadge{display:inline-block;min-width:16px;margin-left:5px;padding:0 5px;border-radius:9px;background:#EF4444;color:#fff;font-size:11px;line-height:16px;text-align:center}

/* ==========================================================================
   视觉增强 v3（2026-11-23）—— 覆盖式微调，不改结构
   目标：更清晰的层级、更安静的边框、状态色统一
   ========================================================================== */
:root {
  --bg: #f5f7fb;
  --line: #e7ebf3;
  --line-strong: #d5dbe6;
  --r: 14px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 16px -6px rgba(16, 24, 40, .10);
}

.main { padding: 26px 30px 80px; }
.ph { align-items: flex-start; margin-bottom: 22px; }
.ph h1 { font-size: 22px; letter-spacing: -.022em; }
.ph .sub { margin-top: 5px; color: #8b93a3; }

.card { border-radius: var(--r); box-shadow: var(--shadow-xs); }
.card.pad { padding: 18px 20px; }
.card.hover { transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.card.hover:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.side { background: #fbfcfe; }
.nav-g { margin: 18px 10px 6px; letter-spacing: .08em; }
.nav-i { height: 35px; border-radius: 9px; }
.nav-i.on {
  position: relative;
  background: var(--brand-50); border-color: transparent; color: var(--brand-600);
  box-shadow: none; font-weight: 650;
}
.nav-i.on::before {
  content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}

.tablewrap { background: #fff; }
th {
  position: sticky; top: 0; z-index: 1;
  background: #f8fafc; color: #7a8496; font-size: 11.5px; letter-spacing: .03em;
  border-bottom: 1px solid var(--line-strong);
}
td { padding: 12px 14px; }
tbody tr:hover { background: #f8faff; }

.tab { height: 36px; border-radius: 8px 8px 0 0; }
.tab:hover { background: #f4f6fb; }

.kpi .n { font-size: 26px; }
.btn { border-radius: 9px; }
.btn.sm { border-radius: 8px; }
.pill { font-weight: 600; }
.empty { padding: 40px 20px; }

/* 开关（通用对话等布尔项）：不依赖第三方库 */
.sw { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.sw input { position: absolute; opacity: 0; width: 0; height: 0; }
.sw i { width: 36px; height: 20px; border-radius: 999px; background: #E4E8F0; position: relative; flex: none; transition: background .16s ease; }
.sw i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.25); transition: transform .16s ease; }
.sw input:checked + i { background: var(--brand); }
.sw input:checked + i::after { transform: translateX(16px); }
.sw input:focus-visible + i { box-shadow: 0 0 0 3px var(--brand-50); }
.sw input:disabled + i { opacity: .55; }
.sw span { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.sw input:checked ~ span { color: var(--text); }

/* 在线状态点 */
.dot-on, .dot-off { display: inline-block; width: 7px; height: 7px; border-radius: 50%; vertical-align: middle; }
.dot-on { background: #12B76A; box-shadow: 0 0 0 3px rgba(18,183,106,.16); }
.dot-off { background: #D0D5DD; }

