:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e3e6ec;
  --text: #1f2430;
  --muted: #7a8494;
  --primary: #2f6bff;
  --primary-dark: #2557d6;
  --green: #1f9d62;
  --red: #d64545;
  --amber: #c47f17;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); }
.spacer { flex: 1; }

/* 登录 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef3ff 0%, #f6f7f9 55%);
  padding: 24px;
}
.login-card {
  width: 340px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 10px 30px rgba(31, 36, 48, .06);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { margin: 0 0 18px; }
.login-card label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.login-card input { margin-top: 6px; }

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); }

.badge {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--muted);
}
.badge.mock { background: #fff4de; color: var(--amber); }
.badge.live { background: #e6f7ee; color: var(--green); }

/* 布局 */
.container { max-width: 1120px; margin: 0 auto; padding: 24px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { font-size: 17px; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; }

/* 表单 */
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
}
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form-grid h3 { grid-column: 1 / -1; margin: 8px 0 0; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }
.form-grid small { font-size: 12px; }
.form-grid details { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; }
.form-grid details summary { cursor: pointer; color: var(--muted); }
.form-grid details textarea { margin-top: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

.contacts .contact-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1.8fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.contacts .contact-row input { min-width: 0; }
.contacts .contact-label { font-size: 12px; color: var(--muted); margin: 2px 0 4px; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.table th { color: var(--muted); font-weight: 500; background: #fafbfc; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafcff; }
.table .link { color: var(--primary); cursor: pointer; text-decoration: none; }

/* 状态 */
.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.status.DRAFT { background: #eef1f6; color: #5b6577; }
.status.SUBMITTED { background: #e8f0ff; color: var(--primary); }
.status.ISSUED { background: #e6f7ee; color: var(--green); }
.status.FAILED { background: #fdeaea; color: var(--red); }
.status.CANCELLED { background: #f1f1f1; color: #777; }
.status.REPLACED { background: #f3ecff; color: #6d3fd1; }
.status.REVOKED { background: #fdeaea; color: var(--red); }

/* 按钮 */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 13px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f7f9fc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); border-color: #f2caca; }
.btn.danger:hover { background: #fdf3f3; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 8px; }
.btn.ghost:hover { background: #f1f4f9; color: var(--text); }
.btn.block { width: 100%; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 详情 */
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 18px; }
.detail-grid div { font-size: 13px; }
.detail-grid .k { color: var(--muted); font-size: 12px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
pre.pem { background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; overflow: auto; max-height: 180px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline .meta { color: var(--muted); font-size: 12px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(20, 24, 33, .38); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 20; }
.modal-card { background: #fff; border-radius: 12px; width: min(620px, 92vw); max-height: 84vh; overflow: auto; padding: 18px 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  z-index: 30;
  opacity: .96;
}
.toast.err { background: var(--red); }

@media (max-width: 900px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contacts .contact-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { display: block; overflow-x: auto; }
}
