:root {
  --side: #0f172a;
  --side-2: #1e293b;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --primary: #2563eb;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a8a22, transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px; box-shadow: 0 20px 40px -24px #0f172a55; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand-dot { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .02em; }
.login-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; outline: none; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #2563eb1a; }
.btn { height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font-weight: 600; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.danger { background: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.msg { margin-top: 12px; font-size: 12.5px; color: var(--danger); min-height: 18px; }

/* ---------- 主框架 ---------- */
.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #cbd5e1; padding: 20px 14px; display: flex; flex-direction: column; }
.side .brand-name { color: #fff; }
.side-sub { font-size: 11.5px; color: #64748b; margin: 2px 0 22px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button { text-align: left; background: transparent; color: #cbd5e1; border: 0;
  padding: 9px 12px; border-radius: 9px; }
.nav button:hover { background: var(--side-2); color: #fff; }
.nav button.on { background: var(--primary); color: #fff; font-weight: 600; }
.side-foot { margin-top: auto; font-size: 12px; color: #64748b; }
.side-foot button { background: transparent; border: 0; color: #94a3b8; padding: 6px 0; }
.side-foot button:hover { color: #fff; }

.main { padding: 26px 30px 40px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.page-desc { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { height: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; }
.toolbar input { width: 240px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f1f5f9; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td.mono, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px;
  border-radius: 999px; border: 1px solid; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { color: var(--ok); border-color: #a7f3d0; background: #ecfdf5; }
.badge.suspended { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.badge.provisioning { color: var(--warn); border-color: #fde68a; background: #fffbeb; }
.badge.migrating { color: var(--primary); border-color: #bfdbfe; background: #eff6ff; }

/* ---------- 弹窗 / 抽屉 ---------- */
.mask { position: fixed; inset: 0; background: #0f172a66; display: flex; justify-content: flex-end; z-index: 50; }
.mask.center { justify-content: center; align-items: center; }
.sheet { width: min(560px, 100%); background: #fff; height: 100%; overflow: auto; padding: 24px; }
.dialog { width: min(520px, 92vw); background: #fff; border-radius: 16px; padding: 24px; max-height: 86vh; overflow: auto; }
.sheet h3, .dialog h3 { margin: 0 0 4px; font-size: 17px; }
.sheet .sub, .dialog .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; margin-bottom: 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.section-title { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 18px 0 8px; }
.store-row { display: grid; grid-template-columns: 1fr 1fr 96px 32px; gap: 8px; margin-bottom: 8px; }
.store-row input, .store-row select { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; }
.icon-btn { width: 32px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 9px; color: var(--muted); }
.icon-btn:hover { color: var(--danger); border-color: #fecaca; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.hint { font-size: 12px; color: var(--muted); background: #f8fafc; border: 1px dashed var(--line);
  padding: 10px 12px; border-radius: 10px; margin-top: 12px; }
.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.events li:last-child { border-bottom: 0; }
.events .t { color: var(--muted); font-size: 11.5px; }
.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99; }
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

/* ---------- B1 总览驾驶舱 ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 26px; font-weight: 700; line-height: 1.3; }
.metric .h { font-size: 11px; color: #94a3b8; }
.ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.card.pad { padding: 16px; overflow: auto; }
.dist-row { display: grid; grid-template-columns: 56px 1fr 36px; gap: 10px; align-items: center; font-size: 12.5px; margin-bottom: 9px; }
.bar { height: 9px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.feed li:last-child { border-bottom: 0; }
.feed .t { margin-left: auto; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.act { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eff6ff; color: var(--primary); font-size: 12px; white-space: nowrap; }
.note p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------- B1/B2 分页与筛选 ---------- */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 2px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pager span { margin-right: auto; }
.toolbar-hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.toolbar .date { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.toolbar input[type="date"] { width: 150px; }
.toolbar select { max-width: 220px; }

/* ---------- B4 运维中心 ---------- */
.metrics.compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.water { display: flex; gap: 12px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.water-bar { flex: 1; min-width: 180px; height: 12px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.water-bar i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.water-bar i.danger { background: var(--danger); }
.note { margin-top: 12px; }
.note .mono { word-break: break-all; }

/* ---------- v4.1 授权确认 ---------- */
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--ink);
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 12px; margin: 4px 0 14px; }
.check input { margin-top: 3px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
  .side-sub, .side-foot { display: none; }
  .nav { flex-direction: row; }
  .main { padding: 16px; }
  .ov-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .store-row { grid-template-columns: 1fr 1fr 72px 32px; }
  /* B5 窄屏：表格转卡片，列名由 data-label 保留，避免横向滚动丢上下文 */
  .card table, .card tbody, .card tr, .card td { display: block; width: 100%; }
  .card thead { display: none; }
  .card tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .card td { border: 0; padding: 3px 0; }
  .card td::before { content: attr(data-label); display: inline-block; width: 92px;
    color: var(--muted); font-size: 12px; vertical-align: top; }
}
