:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #38bdf8 100%);
}
.login-card {
  width: 380px; background: #fff; border-radius: 14px; padding: 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #0f172a; color: #cbd5e1; padding: 16px 0; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.sidebar .brand { padding: 8px 20px 18px; font-size: 16px; font-weight: 600; color: #fff; }
.sidebar .brand small { display: block; font-weight: 400; font-size: 12px; color: #64748b; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #cbd5e1;
  cursor: pointer; border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #1e293b; color: #fff; }
.sidebar nav a.active { background: #1e293b; color: #fff; border-left-color: var(--primary); }
.sidebar .quota { margin: 16px 20px; padding: 12px; background: #1e293b; border-radius: 8px; font-size: 12px; }
.sidebar .quota .bar { height: 6px; background: #334155; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.sidebar .quota .bar i { display: block; height: 100%; background: var(--primary); }
.sidebar .foot { margin-top: auto; padding: 12px 20px; font-size: 12px; color: #64748b; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
}
.topbar .crumb { flex: 1; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; }
.topbar .crumb span { cursor: pointer; color: var(--muted); }
.topbar .crumb span:hover { color: var(--primary); }
.topbar .crumb b { color: var(--text); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.content { flex: 1; padding: 16px 20px 40px; overflow: auto; }

/* ---------- 组件 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 13px; color: var(--text);
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; background: #fff; font-family: inherit;
}
.input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f9fafb; color: var(--muted); font-weight: 500; white-space: nowrap; }
tr:hover td { background: #f9fafb; }
td .icon { margin-right: 8px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: #eef2ff; color: #4338ca; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.err { background: #fee2e2; color: #991b1b; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal { background: #fff; border-radius: 12px; width: 520px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal .head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; }
.modal .head .x { margin-left: auto; cursor: pointer; color: var(--muted); }
.modal .body { padding: 20px; }
.modal .foot { padding: 12px 20px; border-top: 1px solid var(--border); text-align: right; display: flex; gap: 8px; justify-content: flex-end; }
.modal.large { width: 900px; }

.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

.drop-hint {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px; text-align: center;
  color: var(--muted); background: #fff;
}
.drop-hint.over { border-color: var(--primary); background: #eff6ff; }

.progress { height: 6px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--primary); transition: width .2s; }

.preview-body { text-align: center; }
.preview-body img { max-width: 100%; max-height: 70vh; }
.preview-body pre {
  text-align: left; background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px;
  max-height: 60vh; overflow: auto; white-space: pre-wrap; font-size: 13px;
}
.preview-body iframe { width: 100%; height: 70vh; border: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs .tab { padding: 8px 16px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 24px; font-weight: 600; }
.stat .l { color: var(--muted); font-size: 12px; margin-top: 4px; }

.muted { color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.checkbox-col { width: 36px; }
.empty { text-align: center; padding: 50px; color: var(--muted); }

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -220px; top: 0; bottom: 0; z-index: 60; transition: left .2s; }
  .sidebar.open { left: 0; }
  .content { padding: 12px; }
  .topbar { padding: 0 12px; }
  table th:nth-child(n+4), table td:nth-child(n+4) { display: none; }
}
.mask-side { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; display: none; }
.mask-side.show { display: block; }
.menu-btn { display: none; }
@media (max-width: 768px) { .menu-btn { display: inline-flex; } }

/* ---- 新增下拉 / 类型筛选 / 预览 ---- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; z-index: 60; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,.12); min-width: 170px; padding: 6px; margin-top: 4px; }
.dropdown-item { padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.dropdown-item:hover { background: #eff6ff; color: #2563eb; }
.type-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.type-tabs .tt { padding: 5px 14px; border-radius: 999rpx; border-radius: 999px; background: #fff; font-size: 13px;
  color: #334155; cursor: pointer; border: 1px solid #e2e8f0; }
.type-tabs .tt.on { background: #2563eb; color: #fff; border-color: #2563eb; }
.drop-zone { min-height: 120px; }
.drop-zone.over { outline: 2px dashed #2563eb; background: #eff6ff; }
.preview-body { text-align: center; }
.pv-frame { width: 100%; height: 68vh; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; }
.pv-image img { max-width: 100%; max-height: 68vh; }
.qr-box { text-align: center; padding: 10px; }
.qr-box img { width: 190px; height: 190px; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px; background: #fff; }
.designer-item { border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fff; }
.designer-item .hd { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.designer-item input, .designer-item select { padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; }
.opt-list { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.opt-list input { width: 110px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #f1f5f9; font-size: 12px; color: #475569; }
