:root {
  --green-900: #0f2e1e;
  --green-800: #143d28;
  --green-700: #1b5236;
  --green-600: #1f6f43;
  --green-500: #2e8b57;
  --green-400: #48a370;
  --green-100: #e6f2ea;
  --green-50: #f2f8f4;
  --ink: #1c2420;
  --ink-2: #46524b;
  --muted: #78857d;
  --line: #e2e8e4;
  --bg: #f4f7f5;
  --white: #fff;
  --amber: #b7791f;
  --amber-bg: #fdf5e6;
  --red: #b3261e;
  --red-bg: #fdeceb;
  --blue: #1d5c8a;
  --blue-bg: #e9f2f9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 61, 40, .06), 0 8px 24px rgba(20, 61, 40, .05);
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-600); text-decoration: none; }
a:hover { color: var(--green-500); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 10px; }
img { max-width: 100%; }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(170deg, var(--green-900), var(--green-700) 70%, #1d5a3a);
  color: #d9e8df;
  padding: 18px 14px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px;
  background: linear-gradient(135deg, #63c98d, #2e8b57);
  display: grid; place-items: center; color: #06281a; font-weight: 800; font-size: 18px;
}
.brand-text { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.3; }
.brand-text small { display: block; font-size: 10.5px; color: #9fc4ae; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; }

.nav-group { margin-top: 16px; }
.nav-label { font-size: 10.5px; letter-spacing: .14em; color: #7fa892; padding: 0 10px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 9px; color: #cfe3d7; font-size: 13.2px;
  margin-bottom: 2px; transition: background .15s, color .15s;
}
.nav-item svg { width: 16px; height: 16px; opacity: .85; flex: 0 0 16px; }
svg.ico { width: 16px; height: 16px; flex: 0 0 16px; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, .15); color: #fff; font-weight: 600; box-shadow: inset 2px 0 0 #7dd3a0; }
.nav-badge {
  margin-left: auto; background: #d9534f; color: #fff; font-size: 10.5px;
  padding: 0 6px; border-radius: 9px; line-height: 17px; min-width: 18px; text-align: center;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px;
  padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar .crumb strong { color: var(--ink); font-weight: 600; }
.topbar-spacer { flex: 1; }

.tenant-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--green-50);
  border: 1px solid #cfe6d8; color: var(--green-700); padding: 4px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.tenant-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green-500); }

.userbox { display: flex; align-items: center; gap: 9px; padding-left: 14px; border-left: 1px solid var(--line); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--green-100);
  color: var(--green-700); display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.userbox .meta { line-height: 1.25; }
.userbox .meta b { display: block; font-size: 13px; }
.userbox .meta span { font-size: 11px; color: var(--muted); }

.content { padding: 22px 24px 48px; max-width: 1560px; width: 100%; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; }
.page-head .sub { color: var(--muted); font-size: 12.8px; margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 14.5px; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 27px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; color: var(--green-800); font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .delta { font-size: 12px; color: var(--green-600); margin-top: 3px; }
.stat .delta.down { color: var(--red); }
.stat::after { content: ""; position: absolute; right: -22px; top: -22px; width: 72px; height: 72px; border-radius: 50%; background: var(--green-50); }
.stat > * { position: relative; z-index: 1; }

/* ---------- 按钮 / 徽标 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 34px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--white); color: var(--ink-2); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap; font-family: inherit;
}
.btn:hover { border-color: #c4d5ca; background: #fbfdfc; color: var(--green-700); }
.btn-primary { background: var(--green-600); border-color: var(--green-600); color: #fff; box-shadow: 0 1px 2px rgba(31, 111, 67, .3); }
.btn-primary:hover { background: var(--green-500); border-color: var(--green-500); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--green-600); }
.btn-danger { color: var(--red); border-color: #f2cfcc; background: #fff; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600; background: #eef2ef; color: var(--ink-2);
  white-space: nowrap;
}
.badge.green { background: var(--green-100); color: var(--green-700); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: #f0f2f1; color: var(--muted); }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.pill-tabs { display: inline-flex; background: #eef2ef; border-radius: 9px; padding: 3px; gap: 2px; }
.pill-tabs a { padding: 5px 12px; border-radius: 7px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.pill-tabs a.on { background: #fff; color: var(--green-700); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 11.8px;
  letter-spacing: .03em; background: #fafcfb; padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #eef2ef; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fbfdfc; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .strong { font-weight: 600; color: var(--ink); }
table.data .sub { color: var(--muted); font-size: 11.8px; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- 表单 ---------- */
.form-row { display: grid; gap: 14px; margin-bottom: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
label.field { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
label.field span { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 36px; border: 1px solid #d7e0d9; border-radius: 8px; padding: 0 11px;
  font-size: 13.2px; font-family: inherit; color: var(--ink); background: #fff; transition: border .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 80px; padding: 9px 11px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(46, 139, 87, .12); }
.form-hint { font-size: 11.8px; color: var(--muted); margin-top: 4px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .f { min-width: 140px; }
.filter-bar input, .filter-bar select { height: 34px; }

.alert { border-radius: 9px; padding: 10px 13px; font-size: 13px; margin-bottom: 12px; display: flex; gap: 8px; align-items: flex-start; }
.alert.success { background: var(--green-50); color: var(--green-700); border: 1px solid #cfe6d8; }
.alert.error { background: var(--red-bg); color: var(--red); border: 1px solid #f4d3d0; }
.alert.warn { background: var(--amber-bg); color: var(--amber); border: 1px solid #f0dfc0; }

/* ---------- 模块卡片 ---------- */
.section-block { margin-bottom: 24px; }
.section-title { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
.section-title h2 { font-size: 15.5px; }
.section-title .count { font-size: 12px; color: var(--muted); background: #eef2ef; border-radius: 20px; padding: 1px 8px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; }
.module-card {
  background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 14px;
  display: flex; flex-direction: column; gap: 7px; transition: all .16s; position: relative;
}
.module-card:hover { border-color: var(--green-400); box-shadow: 0 6px 18px rgba(31, 111, 67, .1); transform: translateY(-1px); }
.module-card .top { display: flex; align-items: flex-start; gap: 8px; }
.module-card .ico {
  width: 30px; height: 30px; border-radius: 8px; background: var(--green-50); color: var(--green-600);
  display: grid; place-items: center; flex: 0 0 30px; font-size: 13px; font-weight: 700;
}
.module-card h3 { font-size: 13.8px; line-height: 1.4; }
.module-card p { font-size: 12.4px; color: var(--muted); line-height: 1.6; margin: 0; }
.module-card .foot { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; border-top: 1px dashed #eef2ef; }
.module-card .foot .algo { font-size: 11px; color: var(--muted); font-family: Consolas, monospace; }
.module-card .foot .go { margin-left: auto; font-size: 12px; font-weight: 600; }

/* ---------- 图表（内联） ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 132px; padding-top: 8px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #6cc492, var(--green-600)); border-radius: 5px 5px 2px 2px; min-height: 3px; }
.bars .bar-label { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.25; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 56px; }
.spark i { flex: 1; background: var(--green-100); border-radius: 2px; min-height: 2px; }
.spark i.hot { background: var(--green-500); }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); }

/* ---------- 时间线 ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: #dfe9e2; }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -22px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--green-500); box-shadow: 0 0 0 3px #eef7f2;
}
.tl-item.critical::before { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.tl-item .tl-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.tl-item .tl-time { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.tl-item .tl-body { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.tl-item .tl-hash { font-family: Consolas, monospace; font-size: 10.5px; color: var(--muted); margin-top: 3px; word-break: break-all; }

/* ---------- 详情 ---------- */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .big { font-size: 26px; margin-bottom: 6px; }

.progress { height: 6px; background: #eef2ef; border-radius: 20px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-500), #63c98d); border-radius: 20px; transition: width .4s; }

.metric-tile { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: #fbfdfc; }
.metric-tile .k { font-size: 11.5px; color: var(--muted); }
.metric-tile .v { font-size: 17px; font-weight: 700; color: var(--green-800); margin-top: 2px; }
.metric-tile.warn { background: var(--amber-bg); border-color: #f0dfc0; }
.metric-tile.warn .v { color: var(--amber); }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: #fff; }
.login-hero {
  background: radial-gradient(1200px 500px at 10% 10%, #2f7f56 0%, #143d28 55%, #0d2a1b 100%);
  color: #e8f3ec; padding: 52px 56px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.login-hero::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px;
  border-radius: 50%; border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 0 0 60px rgba(255, 255, 255, .03), 0 0 0 130px rgba(255, 255, 255, .02);
}
.login-hero h1 { font-size: 30px; line-height: 1.35; margin: 28px 0 14px; font-weight: 750; letter-spacing: -.02em; }
.login-hero p.lead { color: #b7d4c2; font-size: 14px; max-width: 460px; }
.hero-points { margin-top: auto; display: grid; gap: 12px; }
.hero-point { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: #cfe6d8; }
.hero-point b { color: #fff; display: block; font-size: 13.5px; }
.hero-stat { display: flex; gap: 26px; margin-top: 22px; }
.hero-stat div b { display: block; font-size: 25px; color: #fff; }
.hero-stat div span { font-size: 11.5px; color: #9fc4ae; }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-form { width: 100%; max-width: 356px; }
.login-form h2 { font-size: 22px; margin-bottom: 6px; }
.login-form .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.demo-accounts { margin-top: 22px; border-top: 1px dashed var(--line); padding-top: 14px; }
.demo-accounts .t { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; letter-spacing: .04em; }
.demo-accounts .list { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-accounts button {
  border: 1px solid var(--line); background: #fbfdfc; border-radius: 7px; padding: 4px 9px;
  font-size: 11.8px; cursor: pointer; color: var(--ink-2); font-family: inherit;
}
.demo-accounts button:hover { border-color: var(--green-400); color: var(--green-700); background: var(--green-50); }

/* ---------- 公开追溯页 ---------- */
.public-shell { min-height: 100vh; background: linear-gradient(180deg, #f2f8f4, #fff 260px); }
.public-head {
  background: linear-gradient(120deg, var(--green-800), var(--green-600)); color: #fff;
  padding: 22px 24px;
}
.public-head .inner { max-width: 940px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.public-head h1 { font-size: 18px; }
.public-head p { margin: 0; color: #c7e3d2; font-size: 12.5px; }
.public-body { max-width: 940px; margin: -34px auto 40px; padding: 0 20px; }
.public-search { background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 10px 30px rgba(20, 61, 40, .1); }
.public-search form { display: flex; gap: 8px; }
.trace-hero { background: #fff; border-radius: 14px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.chain-banner { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; font-size: 12.8px; }
.chain-banner.ok { background: var(--green-50); color: var(--green-700); border: 1px solid #cfe6d8; }
.chain-banner.bad { background: var(--red-bg); color: var(--red); border: 1px solid #f4d3d0; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-top: 1px solid var(--line); }
.pager .info { font-size: 12px; color: var(--muted); margin-right: auto; }
.pager a, .pager span.pg {
  min-width: 30px; height: 30px; padding: 0 8px; display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px; color: var(--ink-2); background: #fff;
}
.pager a:hover { border-color: var(--green-400); color: var(--green-700); }
.pager span.pg.on { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.pager span.pg.disabled { color: #c3ccc6; }

/* ---------- 打印 / 响应式 ---------- */
@media (max-width: 1200px) {
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .content { padding: 16px 14px 40px; }
  .grid-3, .grid-2, .span-2 { grid-template-columns: 1fr; grid-column: auto; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar .crumb { display: none; }
  .userbox .meta { display: none; }
  .page-head h1 { font-size: 18px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .menu-toggle { display: inline-grid !important; }
}
@media (max-width: 640px) {
  .grid-6, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 22px; }
  .module-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 82px 1fr; }
}

.menu-toggle { display: none; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(10, 30, 20, .35); z-index: 30; }
.scrim.show { display: block; }
