:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --brand: #1f4e78;
  --brand-soft: #eef4fa;
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--brand); }

.layout { display: flex; min-height: 100vh; }

/* ── 侧边栏 ── */
.sidebar {
  width: 224px; flex: 0 0 224px;
  background: #0f2740; color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
body.embed .sidebar { display: none; }
.brand { padding: 18px 20px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand h1 { margin: 0; font-size: 16px; color: #fff; letter-spacing: .3px; }
.brand .sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg,#38bdf8,#2563eb); display: inline-flex; align-items: center; justify-content: center; color:#fff; font-weight:700; font-size:14px; margin-right:8px; vertical-align: middle;}

.nav { padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 0; color: #cbd5e1;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; text-align: left; font-family: inherit;
}
.nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav button.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav .grp { font-size: 11px; text-transform: uppercase; color: #64748b; padding: 12px 12px 6px; letter-spacing: .6px; }

.sb-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: #94a3b8; }
.dot { display:inline-block; width:7px; height:7px; border-radius:50%; background: var(--ok); margin-right:6px; }
.dot.warn { background: var(--warn); } .dot.err { background: var(--err); }

/* ── 主区 ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 12px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.content { padding: 20px 22px 60px; }

/* ── 组件 ── */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.card .desc { color: var(--muted); font-size: 12.5px; margin: -6px 0 12px; }

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.4px; }
.stat .d { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.btn {
  background: var(--brand); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; font-family: inherit; font-weight: 500;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: var(--err); }
.btn.ok { background: var(--ok); }

input, select, textarea {
  font-family: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1; min-width: 130px; margin-bottom: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfc; position: sticky; top: 0; }
tbody tr:hover { background: #fafbfc; }
.table-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--border); border-radius: 10px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: var(--brand-soft); color: var(--brand); margin: 1px 3px 1px 0; }
.tag.g { background: #ecfdf5; color: var(--ok); }
.tag.y { background: #fffbeb; color: var(--warn); }
.tag.r { background: #fef2f2; color: var(--err); }
.tag.gray { background: #f3f4f6; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.pre { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px; overflow: auto; font-size: 12px; max-height: 380px; }
.hr { height: 1px; background: var(--border); margin: 14px 0; }
.pill { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 999;
  background: #111827; color: #fff; padding: 12px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow); max-width: 420px; opacity: 0;
  transform: translateY(8px); transition: .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: #7f1d1d; }
.toast.ok { background: #064e3b; }

.bar { height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg,#38bdf8,#2563eb); }
.bar.ok > i { background: linear-gradient(90deg,#34d399,#059669); }
.bar.warn > i { background: linear-gradient(90deg,#fbbf24,#d97706); }

.chart { width: 100%; height: 220px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

.notice { border-left: 3px solid var(--warn); background: #fffbeb; padding: 10px 12px; border-radius: 6px; font-size: 12.5px; color: #78350f; }
.notice.info { border-color: var(--brand); background: var(--brand-soft); color: #1e3a5f; }
.notice.err { border-color: var(--err); background: #fef2f2; color: #7f1d1d; }
.notice.ok { border-color: var(--ok); background: #ecfdf5; color: #064e3b; }

.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }

.steps { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.steps b { color: var(--text); }

.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 13px; }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 20px; }
.modal { background: #fff; border-radius: 14px; max-width: 720px; width: 100%; max-height: 88vh; overflow: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { margin-top: 0; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: flex; overflow-x: auto; }
  .nav button { white-space: nowrap; }
  .nav .grp { display: none; }
}
