:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e6e8eb;
  --text: #1f2329;
  --muted: #8a9099;
  --brand: #2f7dff;
  --brand-d: #1f5fd6;
  --ok: #18a058;
  --warn: #f0a020;
  --danger: #e23c3c;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
header {
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 10;
}
header h1 { font-size: 18px; margin: 0; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.status-pill { font-size: 12px; padding: 3px 10px; border-radius: 20px; background: #eef1f5; color: var(--muted); }
.status-pill.ok { background: #e7f7ee; color: var(--ok); }
.status-pill.bad { background: #fdeaea; color: var(--danger); }

nav { display: flex; gap: 4px; margin-left: auto; }
nav button {
  border: none; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 14px;
}
nav button.active { background: #eaf1ff; color: var(--brand); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 24px 60px; }
section { display: none; }
section.active { display: block; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.btn {
  background: var(--brand); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--brand-d); }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f3c2c2; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

.code-head { display: flex; gap: 14px; }
.qr { width: 110px; height: 110px; border: 1px solid var(--border); border-radius: 8px; object-fit: cover; background: #fafafa; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; text-align: center; }
.qr img { width: 100%; height: 100%; object-fit: contain; }
.meta { flex: 1; }
.meta h3 { margin: 0 0 6px; font-size: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag { background: #eef1f5; color: #555; padding: 2px 8px; border-radius: 6px; font-size: 12px; }

.risk-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; border-top: 1px dashed var(--border); }
.bar { flex: 1; height: 8px; background: #eef1f5; border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar > i.warn { background: var(--warn); }
.bar > i.paused { background: var(--danger); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.badge.ok { background: #e7f7ee; color: var(--ok); }
.badge.warn { background: #fdf3e3; color: var(--warn); }
.badge.paused { background: #fdeaea; color: var(--danger); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.kpi .n { font-size: 28px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; }

.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; padding: 22px; }
.modal h2 { margin: 0 0 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit;
}
.field textarea { min-height: 60px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.tag-picker { max-height: 160px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.tag-picker label { display: inline-flex; align-items: center; gap: 6px; margin: 4px 8px 4px 0; font-size: 13px; color: var(--text); }

.note { line-height: 1.7; }
.note code { background: #eef1f5; padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.note ol { padding-left: 20px; }
.note li { margin-bottom: 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .25s; z-index: 100; }
.toast.show { opacity: 1; }
