:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2d3d;
  --muted: #6b7785;
  --line: #e3e8ef;
  --brand: #e23b3b;       /* 安全红：警示/主行动 */
  --brand-d: #c52f2f;
  --blue: #2f6fed;
  --blue-d: #1f57c9;
  --ok: #1f9d55;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(31,45,61,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 38px; height: 38px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.cta-top {
  text-decoration: none; color: #fff; background: var(--brand);
  padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  white-space: nowrap;
}
.cta-top:hover { background: var(--brand-d); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 16px 48px; }
.hero { text-align: center; margin: 8px 0 22px; }
.hero h1 { font-size: 26px; margin: 0 0 8px; }
.hero h1 strong { color: var(--brand); }
.lead { color: var(--muted); margin: 0; font-size: 15px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 4px 0 12px; display: flex; align-items: center; gap: 8px; }
.auto { font-size: 11px; background: #eaf1ff; color: var(--blue); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.hidden { display: none !important; }
.req { color: var(--brand); }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }

/* 类型选择 */
.type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.type-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px;
  cursor: pointer; text-align: left; font-size: 14px; transition: .15s; font-weight: 600; color: var(--ink);
}
.type-btn:hover { border-color: var(--blue); }
.type-btn.active { border-color: var(--brand); background: #fff5f5; color: var(--brand-d); }
.level-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.level-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px;
  cursor: pointer; font-size: 13px;
}
.level-btn:hover { border-color: var(--blue); }
.level-btn.active { border-color: var(--brand); background: #fff5f5; color: var(--brand-d); font-weight: 600; }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-size: 14px; font-family: inherit; color: var(--ink); background: #fff;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--blue); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 措施清单 */
.measures { list-style: none; margin: 0 0 10px; padding: 0; }
.measures li {
  display: flex; gap: 9px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 7px; font-size: 13.5px; background: #fcfdff;
}
.measures li input { margin-top: 3px; }
.measures li.checked { background: #f3fbf6; border-color: #cdeed7; }

/* 按钮 */
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.btn { border: none; border-radius: 9px; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn.block { display: block; text-align: center; text-decoration: none; margin: 6px 0; }
.save-tip { color: var(--ok); font-size: 13px; margin: 10px 0 0; }

/* 预览 */
.preview-card { position: sticky; top: 78px; }
.preview-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.preview-no { color: var(--brand); font-weight: 600; }
.permit { border: 2px solid var(--ink); border-radius: 8px; padding: 16px; background: #fff; }
.permit-title { text-align: center; font-size: 18px; font-weight: 800; letter-spacing: 4px; margin-bottom: 12px; }
.permit-meta { font-size: 13px; display: grid; gap: 5px; margin-bottom: 12px; }
.permit-meta b { color: var(--muted); font-weight: 600; }
.permit-section { font-weight: 700; font-size: 13px; border-left: 3px solid var(--brand); padding-left: 8px; margin: 8px 0; }
.pv-measures { margin: 0; padding-left: 20px; font-size: 12.5px; display: grid; gap: 4px; }
.permit-sign { display: grid; gap: 8px; font-size: 13px; margin: 14px 0 8px; }
.permit-foot { font-size: 11px; color: var(--muted); text-align: center; border-top: 1px dashed var(--line); padding-top: 8px; }

/* 留资条 */
.leadbar {
  margin-top: 20px; background: linear-gradient(135deg,#fff,#fff7f7); border: 1px solid #ffd9d9;
  border-radius: var(--radius); padding: 16px 18px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: center;
}
.leadbar-text b { display: block; font-size: 15px; margin-bottom: 3px; }
.leadbar-text span { font-size: 13px; color: var(--muted); }
.leadbar-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; }
.leadbar-form input { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 13px; }
.leadbar-form input:focus { outline: none; border-color: var(--blue); }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 26px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(20,30,45,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: #fff; border-radius: 14px; padding: 22px; max-width: 420px; position: relative; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-box h3 { margin: 0 0 10px; font-size: 18px; }
.modal-box p { font-size: 14px; color: var(--ink); }
.modal-x { position: absolute; top: 10px; right: 14px; border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); }

/* 响应式 */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .leadbar { grid-template-columns: 1fr; }
  .leadbar-form { grid-template-columns: 1fr 1fr; }
  .row2 { grid-template-columns: 1fr; }
}

/* 打印：只保留许可证 */
@media print {
  .topbar, .hero, .form-card, .leadbar, .foot, .modal { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: 100%; }
  .grid { display: block; }
  .preview-card { position: static; box-shadow: none; border: none; padding: 0; }
  .permit { border-width: 2px; }
}
