/* 企业端 / 平台端共用样式：左侧深色菜单 + 顶栏 + 卡片内容区 */
:root {
  --pri: #1664ff; --pri-weak: #e8f0ff; --pri-dark: #0e4fd6;
  --ok: #00b42a; --ok-weak: #e8ffea; --warn: #ff7d00; --warn-weak: #fff3e8;
  --bad: #f53f3f; --bad-weak: #ffece8; --purple: #722ed1; --purple-weak: #f5e8ff;
  --text: #1d2129; --text2: #4e5969; --muted: #86909c; --line: #e5e6eb; --line2: #f2f3f5;
  --bg: #f2f3f5; --card: #fff; --side: #0b1a33; --side-text: #a9b4c8;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5715 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--pri); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.side { width: 220px; background: var(--side); color: var(--side-text); flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; color: #fff;
  font-weight: 600; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.logo .mark { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #1664ff, #00c2ff); display: grid; place-items: center; }
.logo .mark svg { width: 18px; height: 18px; }
.logo small { display: block; font-size: 11px; font-weight: 400; color: #6f7d96; }
.menu { padding: 8px 10px 24px; }
.menu-group { font-size: 12px; color: #5d6b85; padding: 16px 12px 6px; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px;
  color: var(--side-text); margin: 2px 0; white-space: nowrap; }
.menu a:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu a.active { background: var(--pri); color: #fff; }
.menu svg { width: 16px; height: 16px; flex-shrink: 0; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { height: 60px; background: var(--card); border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 10; gap: 12px; }
.top h2 { font-size: 16px; }
.top-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.top .balance { font-size: 13px; color: var(--text2); cursor: pointer; }
.top .balance b { color: var(--text); font-size: 15px; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--pri-weak); color: var(--pri);
  display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.dropdown { position: absolute; right: 0; top: 40px; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.08); min-width: 140px; padding: 4px; display: none; }
.dropdown.open { display: block; }
.dropdown a { display: block; padding: 8px 12px; color: var(--text); border-radius: 4px; }
.dropdown a:hover { background: var(--line2); }
.page { padding: 20px 24px 40px; width: 100%; max-width: 1440px; }
.banner { margin: 16px 24px 0; padding: 10px 14px; border-radius: 6px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.banner.warn { background: var(--warn-weak); color: #b65200; border: 1px solid #ffd2a8; }
.banner.bad { background: var(--bad-weak); color: #cb2634; border: 1px solid #fdcdc5; }
.banner.info { background: var(--pri-weak); color: var(--pri-dark); border: 1px solid #bed4ff; }

/* ---------- 卡片 / 栅格 ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .k-label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 26px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.kpi .k-value small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi::after { content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%;
  background: var(--accent, var(--pri-weak)); opacity: .7; }
.kpi.c-ok { --accent: var(--ok-weak); } .kpi.c-warn { --accent: var(--warn-weak); }
.kpi.c-bad { --accent: var(--bad-weak); } .kpi.c-purple { --accent: var(--purple-weak); }

/* ---------- 表单 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
input, select, textarea { font: inherit; color: var(--text); padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; outline: none; min-height: 34px; }
input:focus, select:focus, textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 2px var(--pri-weak); }
input[type=checkbox], input[type=radio] { min-height: auto; accent-color: var(--pri); }
textarea { width: 100%; min-height: 90px; resize: vertical; line-height: 1.6; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; color: var(--text2); font-size: 13px; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text2); }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 16px;
  border-radius: 6px; border: 1px solid var(--pri); background: var(--pri); color: #fff; cursor: pointer;
  font: inherit; white-space: nowrap; }
.btn:hover { background: var(--pri-dark); border-color: var(--pri-dark); }
.btn.ghost { background: #fff; color: var(--pri); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--pri); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.danger.ghost { background: #fff; color: var(--bad); border-color: var(--line); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--pri); cursor: pointer; padding: 0 4px; font: inherit; }
.link.danger { color: var(--bad); }
.link:disabled { color: var(--muted); cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
th { color: var(--text2); font-weight: 500; font-size: 13px; background: #f7f8fa; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
tr.click { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { color: var(--muted); font-size: 12px; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- 标签 ---------- */
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px;
  background: var(--line2); color: var(--text2); white-space: nowrap; margin-right: 4px; }
.tag.ok { background: var(--ok-weak); color: var(--ok); } .tag.pri { background: var(--pri-weak); color: var(--pri); }
.tag.warn { background: var(--warn-weak); color: var(--warn); } .tag.bad { background: var(--bad-weak); color: var(--bad); }
.tag.purple { background: var(--purple-weak); color: var(--purple); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 10px; background: var(--line2); color: var(--muted); white-space: nowrap; }
.pill.on { background: var(--ok-weak); color: var(--ok); } .pill.off { background: var(--warn-weak); color: var(--warn); }

/* ---------- 进度 / 图表 ---------- */
.progress { height: 6px; background: var(--line2); border-radius: 3px; overflow: hidden; display: flex; min-width: 120px; }
.progress span { display: block; height: 100%; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.chart .bar { width: 40%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .x { font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 70px minmax(0, 1fr) 50px; gap: 10px; align-items: center; margin: 10px 0; font-size: 13px; }
.hbar .track { height: 8px; background: var(--line2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; }

/* ---------- 弹窗 / 提示 ---------- */
.mask { position: fixed; inset: 0; background: rgba(29,33,41,.45); display: flex; align-items: flex-start;
  justify-content: center; z-index: 100; padding: 60px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 560px; max-width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.modal.wide { width: 860px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line2); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line2); display: flex; justify-content: flex-end; gap: 8px; }
.x-btn { background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; }
.toast-box { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.12); font-size: 14px; border-left: 3px solid var(--ok); }
.toast.err { border-left-color: var(--bad); }

/* ---------- 对话 ---------- */
.chat { height: 440px; overflow-y: auto; background: #f7f8fa; border-radius: 8px; padding: 14px; }
.msg { max-width: 78%; margin: 8px 0; padding: 9px 13px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.msg.user { background: var(--pri); color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.msg.assistant { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg.partial { opacity: .6; }
.msg.sys { max-width: 100%; text-align: center; color: var(--muted); font-size: 12px; background: none; padding: 2px; }
.msg .meta { font-size: 11px; opacity: .7; margin-top: 3px; }
.list-item { padding: 12px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; margin-bottom: 4px; }
.list-item:hover { background: var(--line2); }
.list-item.active { background: var(--pri-weak); border-color: #bed4ff; }
.hint { background: #f7f8fa; border-left: 3px solid var(--pri); padding: 9px 12px; color: var(--text2); font-size: 13px; margin-bottom: 14px; border-radius: 0 4px 4px 0; }
.muted { color: var(--muted); font-size: 12px; }
.desc { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; }
.desc dt { color: var(--muted); } .desc dd { margin: 0; word-break: break-all; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--text2); border-bottom: 2px solid transparent; font: inherit; }
.tabs button.active { color: var(--pri); border-color: var(--pri); font-weight: 500; }

/* ---------- 登录页 ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: #fff; }
.login-hero { background: linear-gradient(150deg, #0b1a33 0%, #10306b 55%, #1664ff 130%); color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero h1 { font-size: 34px; line-height: 1.3; margin-top: 80px; }
.login-hero p { color: #b8c6e3; font-size: 15px; max-width: 460px; }
.login-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; color: #d5def0; }
.login-hero li::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #3ec6ff; margin-right: 10px; vertical-align: 2px; }
.login-box { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 24px; margin-bottom: 6px; }
.login-form .field { margin-top: 18px; }
.login-form input { height: 42px; }
.login-form .btn { width: 100%; height: 42px; margin-top: 24px; font-size: 15px; }

@media (max-width: 960px) {
  .g2, .g3, .g21, .split, .form { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .side { width: auto; height: auto; position: static; }
  .menu { display: flex; overflow-x: auto; padding: 6px; }
  .menu-group { display: none; }
  .top { padding: 0 16px; height: auto; min-height: 56px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .page { padding: 16px; }
  .banner { margin: 12px 16px 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .k-value { font-size: 20px; }
}
