:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e6e9f0;
  --line-2: #eef1f7;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef2ff;
  --accent: #0ea5e9;
  --ok: #16a34a;
  --ok-soft: #e9f7ef;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --gray-soft: #eef1f6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 10px 30px rgba(16,24,40,.06);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; grid-column: 1; }
.logo {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 22px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(79,70,229,.32);
}
.brand-text h1 { font-size: 17px; line-height: 1.2; }
.brand-text p { font-size: 12px; color: var(--muted); }

.topbar-actions { grid-column: 3; display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.search { flex: 0 1 auto; min-width: 0; }
.search input {
  width: clamp(170px, 20vw, 260px);
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  color: var(--ink-2);
  outline: none;
  cursor: pointer;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  background: #fff; color: var(--ink-2);
  transition: transform .06s, box-shadow .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(79,70,229,.28);
}
.btn.primary:hover { box-shadow: 0 8px 22px rgba(79,70,229,.36); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: #cfd6e4; background: #fbfcfe; }
.btn.small { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn.danger { color: var(--danger); border-color: #f3c9c9; }
.btn.danger:hover { background: var(--danger-soft); }

/* ---------- 布局 ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 28px 40px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .k { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat .v { font-size: 26px; font-weight: 720; letter-spacing: -0.02em; }
.stat .v small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.stat.accent .v { background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.hint { font-size: 12.5px; color: var(--muted); }
.toolbar-right { display: flex; gap: 8px; }

/* ---------- 卡片网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(390px, 1fr)); gap: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: #dfe4ef; }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card-title h3 { font-size: 16.5px; line-height: 1.3; word-break: break-word; }
.card-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  align-self: flex-start;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650;
  background: var(--gray-soft); color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.s-进行中 { background: var(--primary-soft); color: #4338ca; }
.badge.s-已完成 { background: var(--ok-soft); color: #15803d; }
.badge.s-未开始 { background: var(--gray-soft); color: #64748b; }
.badge.s-暂停 { background: var(--warn-soft); color: #b45309; }
.badge.s-维护中 { background: var(--danger-soft); color: #b91c1c; }

.desc { font-size: 13px; color: var(--ink-2); line-height: 1.6; }

.links { display: flex; gap: 8px; flex-wrap: wrap; }
.link-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600;
  background: var(--primary-soft); color: #4338ca;
}
.link-pill.alt { background: #eaf7fd; color: #0369a1; }
.link-pill:hover { text-decoration: none; filter: brightness(.97); }
.demo-thumb { margin-top: 2px; }
.demo-thumb img {
  width: 100%; max-height: 150px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line);
  display: block;
}

.progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.progress-label b { color: var(--ink); font-weight: 700; }
.progress { height: 8px; border-radius: 999px; background: #eef1f7; overflow: hidden; }
.progress .bar {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .4s ease;
}

.items { border-top: 1px dashed var(--line); padding-top: 10px; }
.items-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.items table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.items th {
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 4px 6px; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.items td { padding: 6px; border-bottom: 1px solid var(--line-2); vertical-align: top; color: var(--ink-2); }
.items tr:last-child td { border-bottom: none; }
.items td.amt { font-weight: 650; color: var(--ink); white-space: nowrap; }
.items td.entity { font-weight: 600; color: var(--ink); white-space: nowrap; }

.card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty p { margin: 4px 0; }

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(17,24,39,.42);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff; border-radius: 18px;
  box-shadow: 0 24px 70px rgba(16,24,40,.28);
  padding: 22px 24px;
  max-height: 90vh; overflow-y: auto;
  width: 100%;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }
.modal.narrow { max-width: 400px; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: 17px; }
.xbtn { border: none; background: transparent; font-size: 16px; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.xbtn:hover { background: var(--gray-soft); }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field label i { color: var(--danger); font-style: normal; }
.field label b { color: var(--primary); font-weight: 700; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="text"], input[type="password"], input[type="search"], input:not([type]), textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(99,102,241,.14); }
textarea { resize: vertical; min-height: 40px; }
input[type="range"] { padding: 0; accent-color: var(--primary); }

.items-section { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fbfcff; }
.items-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.items-head strong { font-size: 13.5px; }
.items-head .muted { font-size: 12px; }
.entity-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  font-size: 12.5px; cursor: pointer; user-select: none;
  transition: all .12s;
}
.check:hover { border-color: #cfd6e4; }
.check input { accent-color: var(--primary); margin: 0; }
.check.on { background: var(--primary-soft); border-color: #c7d2fe; color: #4338ca; font-weight: 600; }

.items-custom { display: flex; gap: 8px; margin-bottom: 10px; }
.items-custom input { flex: 1; }
.items-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr 1fr 1.6fr 32px;
  gap: 6px; align-items: center;
  padding: 8px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line);
}
.item-row input { padding: 7px 9px; font-size: 12.5px; border-radius: 8px; }
.item-row .i-del {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 14px; border-radius: 8px; padding: 4px;
}
.item-row .i-del:hover { background: var(--danger-soft); color: var(--danger); }
.small-hint { font-size: 12px; margin-top: 6px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #111827; color: #fff;
  padding: 11px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0,0,0,.24);
  z-index: 90;
  animation: fade .18s ease;
}
.toast.ok { background: #15803d; }
.toast.bad { background: #b91c1c; }

.footer { text-align: center; font-size: 12px; color: #9aa3b2; padding: 0 0 28px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr; gap: 10px; }
  .brand { grid-column: 1; }
  .topbar-actions { grid-column: 1; width: 100%; flex-wrap: wrap; }
  .search { flex: 1 1 220px; }
  .search input { width: 100%; }
}
@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: stretch; padding: 12px 16px; }
  .topbar-actions { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .wrap { padding: 16px 16px 32px; }
  .row2 { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row .i-note { grid-column: 1 / -1; }
  .item-row .i-del { justify-self: end; }
}
