/* =====================================================================
   云脉 CRM · 设计系统
   参考：现代 SaaS 后台（Stripe / Linear / Ant Design Pro）设计规范
   要点：4px 间距栅格、语义化色板、48px 行高、等宽数字、1px 分隔线
   ===================================================================== */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --border: #e6e9ef;
  --border-strong: #d3d8e0;
  --text: #101828;
  --text-2: #475467;
  --muted: #7c8698;
  --accent: #2563eb;
  --accent-weak: #eff4ff;
  --accent-2: #1d4ed8;
  --green: #12b76a;
  --green-weak: #ecfdf3;
  --amber: #f79009;
  --amber-weak: #fffaeb;
  --red: #f04438;
  --red-weak: #fef3f2;
  --violet: #7a5af8;
  --violet-weak: #f4f3ff;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --side-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
.num, .money, td.num, td.money, th.num, th.money { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 登录 */
.auth { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }
.auth-aside {
  background: linear-gradient(150deg, #0f172a 0%, #16234a 55%, #1e3a8a 100%);
  color: #fff; padding: 64px 60px; display: flex; flex-direction: column; justify-content: center; gap: 22px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .3px; }
.auth-aside h1 { font-size: 34px; line-height: 1.35; font-weight: 650; letter-spacing: -.5px; }
.auth-aside p { color: #b9c6e4; max-width: 460px; font-size: 15px; line-height: 1.7; }
.auth-points { list-style: none; display: grid; gap: 10px; margin-top: 8px; }
.auth-points li { color: #cfdaf3; font-size: 13.5px; padding-left: 22px; position: relative; }
.auth-points li::before {
  content: "✓"; position: absolute; left: 0; top: 0; color: #60a5fa; font-weight: 700;
}
.auth-panel { display: flex; align-items: center; justify-content: center; background: var(--surface); }
#login-form { width: 340px; }
#login-form h2 { font-size: 24px; letter-spacing: -.3px; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 6px 0 26px; }
#login-form label { display: block; font-size: 12.5px; color: var(--text-2); margin: 16px 0 6px; font-weight: 500; }
#login-form input {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 14px; outline: none; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
#login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
#login-form button {
  width: 100%; height: 44px; margin-top: 24px; border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 500; letter-spacing: 2px;
  cursor: pointer; transition: background .15s;
}
#login-form button:hover { background: var(--accent-2); }
#login-form button:disabled { opacity: .6; cursor: default; }
.auth-tip { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }
.auth-tip.err { color: var(--red); }
.logo {
  width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
}
.logo.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }

/* ---------------------------------------------------------------- 骨架 */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--side-w); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-head {
  height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 18px;
  border-bottom: 1px solid var(--border); font-weight: 600; letter-spacing: .2px;
}
.brand-text { font-size: 15px; }
.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group { margin-bottom: 14px; }
.nav-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: 6px 10px; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; cursor: pointer; margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: #f2f4f7; color: var(--text); }
.nav a.active { background: var(--accent-weak); color: var(--accent-2); font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; opacity: .85; font-size: 14px; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.stat { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.stat b { color: var(--text-2); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.menu-toggle { display: none; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.crumbs b { color: var(--text); font-weight: 600; font-size: 14.5px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.search-box {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); width: 280px;
}
.search-box input { border: 0; background: transparent; outline: none; flex: 1; font-size: 13px; color: var(--text); }
.search-box kbd {
  font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 4px; background: #fff;
}
.search-ico { color: var(--muted); font-size: 15px; }
.env-chip {
  font-size: 11.5px; color: var(--green); background: var(--green-weak);
  border: 1px solid #d1fadf; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.user-menu { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-weak); color: var(--accent-2);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.user-info { display: grid; line-height: 1.25; }
.user-info b { font-size: 13px; font-weight: 600; }
.user-info span { font-size: 11px; color: var(--muted); }
.icon-btn {
  width: 32px; height: 32px; border: 1px solid var(--border); background: #fff; border-radius: 8px;
  cursor: pointer; color: var(--text-2); font-size: 14px;
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }

.view { padding: 20px 22px 48px; flex: 1; }

/* ---------------------------------------------------------------- 通用 */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; letter-spacing: -.3px; font-weight: 650; }
.page-head p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

.btn {
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--accent-2); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #d92d20; }
.btn.ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn.ghost:hover { background: #f2f4f7; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-body { padding: 16px 18px; }

/* ---------------------------------------------------------------- 工作台 */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 650; letter-spacing: -.8px; margin: 8px 0 6px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.kpi .delta { font-size: 12px; display: flex; gap: 6px; align-items: center; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.delta-flat { color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.chart-svg { width: 100%; height: 220px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); padding: 8px 18px 14px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f2f4f7; }
.rank-row:last-child { border-bottom: 0; }
.rank-row .idx {
  width: 22px; height: 22px; border-radius: 6px; background: #f2f4f7; color: var(--muted);
  font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.rank-row:nth-child(1) .idx { background: #fef3c7; color: #b45309; }
.rank-row:nth-child(2) .idx { background: #e0e7ff; color: #4338ca; }
.rank-row:nth-child(3) .idx { background: #d1fae5; color: #047857; }
.rank-row .name { flex: 1; font-size: 13px; }
.rank-row .name span { color: var(--muted); font-size: 11.5px; margin-left: 6px; }
.rank-row .val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.todo-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f2f4f7; font-size: 13px; }
.todo-row:last-child { border-bottom: 0; }
.todo-row .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); flex-shrink: 0; }
.todo-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-row .d { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 列表页 */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.input, .select {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13px; background: #fff; color: var(--text); outline: none; min-width: 120px;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.input.search { min-width: 240px; padding-left: 30px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c8698' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 9px center no-repeat; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px 0 10px;
  background: var(--accent-weak); color: var(--accent-2); border-radius: 999px; font-size: 12px;
}
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 13px; line-height: 1; }

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); background: var(--surface-2);
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
table.data th.num, table.data td.num { text-align: right; }
table.data td { padding: 0 14px; height: 48px; border-bottom: 1px solid #f2f4f7; white-space: nowrap; color: var(--text-2); }
table.data tbody tr:hover td { background: #fbfcfe; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.name { color: var(--text); font-weight: 500; }
table.data th.sticky, table.data td.sticky {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
}
table.data th.sticky { z-index: 3; background: var(--surface-2); }
table.data tbody tr:hover td.sticky { background: #fbfcfe; }
table.data td.actions { text-align: right; }
.row-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity .12s; }
tr:hover .row-actions { opacity: 1; }
.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.b-green { background: var(--green-weak); color: #067647; }
.b-blue { background: var(--accent-weak); color: var(--accent-2); }
.b-amber { background: var(--amber-weak); color: #b54708; }
.b-red { background: var(--red-weak); color: #b42318; }
.b-gray { background: #f2f4f7; color: #475467; }
.b-violet { background: var(--violet-weak); color: #5925dc; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); }
.pager .info { font-size: 12.5px; color: var(--muted); }
.pager .info b { color: var(--text-2); font-weight: 600; }
.pager-btns { display: flex; gap: 8px; align-items: center; }
.page-size { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .ico { font-size: 30px; opacity: .5; }
.empty h4 { margin: 10px 0 4px; color: var(--text-2); font-size: 14px; font-weight: 500; }
.empty p { font-size: 12.5px; margin-bottom: 14px; }

.skeleton-row td { padding: 0 14px; height: 48px; }
.sk { height: 12px; border-radius: 4px; background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 40%, #eef1f5 55%); background-size: 300% 100%; animation: sk 1.2s ease-in-out infinite; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------------------------------------------------------------- 抽屉 */
.drawer { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 80; display: flex; justify-content: flex-end; }
.drawer-panel {
  width: 720px; max-width: 94vw; background: var(--surface); height: 100%; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: slidein .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.drawer-head .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-head h2 { font-size: 18px; letter-spacing: -.3px; }
.drawer-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.drawer-body { padding: 18px 24px 40px; }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin: 0 -24px; padding: 0 24px; }
.tab { padding: 10px 0; font-size: 13.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); font-weight: 600; }
.kv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; padding: 18px 0; }
.kv { min-width: 0; }
.kv span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.kv b { font-size: 13.5px; font-weight: 500; word-break: break-all; }
.kv .badge { width: max-content; }
.section { margin-top: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title h4 { font-size: 13.5px; font-weight: 600; }
.mini-table { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.mini-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.mini-table td { padding: 9px 10px; border-bottom: 1px solid #f2f4f7; color: var(--text-2); }
.mini-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; padding-left: 16px; border-left: 2px solid #eaecf0; }
.timeline li { position: relative; padding: 0 0 14px 6px; font-size: 12.5px; color: var(--text-2); }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: #d0d5dd; border: 2px solid #fff; }
.timeline li.contract::before { background: var(--accent); }
.timeline li.receipt::before { background: var(--green); }
.timeline time { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-panel { background: var(--surface); border-radius: 12px; width: 760px; max-width: 96vw; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.98); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-group { margin-bottom: 18px; }
.form-group > .gtitle { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; padding-left: 8px; border-left: 3px solid var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-item { display: grid; gap: 5px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 12px; color: var(--text-2); }
.form-item label .req { color: var(--red); margin-left: 2px; }
.form-item input, .form-item select, .form-item textarea {
  height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13px; outline: none; background: #fff; color: var(--text);
}
.form-item textarea { height: 72px; padding: 8px 10px; resize: vertical; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.form-item .err { color: var(--red); font-size: 11.5px; }

/* ---------------------------------------------------------------- 提示 */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #101828; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: var(--shadow-lg); z-index: 500;
}
.toast.err { background: var(--red); }
.toast.ok { background: #054f31; }

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .search-box { width: 200px; }
  .env-chip { display: none; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .kv-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}




.kpi.clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.kpi.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi .label .src {
  font-style: normal; font-size: 10.5px; color: var(--accent-2); background: var(--accent-weak);
  border-radius: 4px; padding: 1px 5px; margin-left: 4px;
}
.kpi .formula { font-size: 11.5px; color: var(--muted); margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 6px; }


/* ================= 顶部页签 ================= */
.tabbar {
  display: flex; align-items: center; gap: 4px; padding: 0 12px;
  height: 38px; background: #fff; border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.tab-item {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border-radius: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer;
  white-space: nowrap; border: 1px solid transparent; flex-shrink: 0;
}
.tab-item:hover { background: #f2f4f7; }
.tab-item.active { background: var(--accent-weak); color: var(--accent-2); border-color: #d8e2fd; font-weight: 600; }
.tab-ico { font-size: 11px; opacity: .8; }
.tab-x {
  font-size: 10px; line-height: 1; width: 14px; height: 14px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.tab-x:hover { background: #e4e7ec; color: var(--text); }

/* ================= 抽屉栈 ================= */
.drawer-stack { position: fixed; inset: 0; pointer-events: none; z-index: 200; }
.dlayer { position: fixed; inset: 0; pointer-events: auto; }
.dlayer .dmask { position: absolute; inset: 0; background: rgba(16, 24, 40, .42); transition: background .15s; }
.dlayer .dpanel {
  position: absolute; top: 0; right: 0; height: 100%; max-width: 96vw;
  background: var(--surface); box-shadow: -12px 0 32px rgba(16, 24, 40, .18);
  display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s;
  animation: slidein .22s cubic-bezier(.2, .8, .2, 1);
}
.dlayer .dpanel.is-covered { transform: translateX(-22px) scale(.986); box-shadow: -4px 0 12px rgba(16, 24, 40, .10); }
.dhead {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.dhead-text h2 { font-size: 17px; letter-spacing: -.3px; }
.dhead-text .dsub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.dhead .btn, .dhead .icon-btn { flex-shrink: 0; }
.dbody { padding: 16px 22px 28px; overflow-y: auto; flex: 1; }
.dfoot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 12px 22px;
  border-top: 1px solid var(--border); background: var(--surface-2); flex-shrink: 0;
}
.dtabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin: -4px 0 16px; }
.dtabs .tab { padding: 9px 0; font-size: 13.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dtabs .tab.active { color: var(--accent-2); border-bottom-color: var(--accent); font-weight: 600; }



/* ================= 通知铃铛 ================= */
.bell-wrap { position: relative; }
#bell { position: relative; font-size: 14px; }
.bell-badge {
  position: absolute; top: -4px; right: -4px; min-width: 15px; height: 15px; padding: 0 4px;
  background: var(--red); color: #fff; border-radius: 999px; font-size: 10px; line-height: 15px; text-align: center;
}
.bell-panel {
  position: absolute; right: 0; top: 40px; width: 320px; max-height: 420px; overflow: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 60;
}
.bell-head { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; }
.bell-head button { border: 0; background: none; color: var(--accent); font-size: 12px; cursor: pointer; }
.bell-item { padding: 10px 14px; border-bottom: 1px solid #f2f4f7; cursor: pointer; }
.bell-item:hover { background: #f9fafb; }
.bell-item .t { font-size: 13px; color: var(--text); }
.bell-item .b { font-size: 12px; color: var(--muted); margin-top: 3px; }
.bell-item.unread { background: #f5f8ff; }

/* ================= 批量操作条 ================= */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; margin-bottom: 10px;
  background: var(--accent-weak); border: 1px solid #d8e2fd; border-radius: 8px; font-size: 13px; color: var(--accent-2);
}
.bulk-bar b { font-weight: 600; }
.bulk-bar .spacer2 { flex: 1; }
table.data td.sel, table.data th.sel { width: 38px; text-align: center; padding-right: 0; }


/* ================= 手机端适配 ================= */
@media (max-width: 900px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .crumbs { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search-box { width: 150px; }
  .view { padding: 16px 14px 40px; }
  .dlayer .dpanel { width: 100% !important; max-width: 100vw; }
  .dlayer .dpanel.is-covered { transform: translateX(-12px) scale(.99); }
  .dhead { padding: 14px 16px 12px; }
  .dbody { padding: 14px 16px 24px; }
  .dfoot { padding: 10px 16px; }
  .card-body { overflow-x: auto; }
  .bulk-bar { flex-wrap: wrap; }
  .level-row { flex-wrap: wrap; row-gap: 6px; }
  .dtabs { overflow-x: auto; }
  .page-head { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  .search-box { display: none; }
  .user-info { display: none; }
  .env-chip { display: none; }
  .top-actions { gap: 8px; }
  .view { padding: 14px 12px 36px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head h1 { font-size: 18px; }
  .page-actions { justify-content: flex-end; flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 24px; }
  .toolbar { gap: 8px; }
  .toolbar .input.search { min-width: 0; width: 100%; }
  .toolbar .select { min-width: 0; flex: 1; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .rank-row .name span { display: none; }
  .bell-panel { width: calc(100vw - 24px); right: -10px; }
  .tabbar { padding: 0 8px; }
  .table-scroll { -webkit-overflow-scrolling: touch; }
  .mini-table { white-space: nowrap; }
  .kv-grid { grid-template-columns: 1fr 1fr; }
}

