* { box-sizing: border-box; }
:root {
  --accent: #6366f1;
  --accent-d: #4f46e5;
  --accent-soft: #eef2ff;
  --ink: #1f2937;
  --ink-2: #6b7280;
  --line: #e8eaf1;
  --bg: #f4f6fb;
  --sidebar-w: 220px;
  --topbar-h: 60px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 20px 45px rgba(16,24,40,.18);
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-d); }
.hidden { display: none !important; }

/* ============ 登录 ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, #6366f133, transparent),
              radial-gradient(1000px 500px at 100% 110%, #22d3ee22, transparent),
              linear-gradient(135deg, #0f172a, #1e293b);
}
.login-wrap {
  width: 100%;
  max-width: 380px;
  background: #fff;
  padding: 34px 32px 30px;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo {
  width: 52px; height: 52px; margin: 0 auto 12px;
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 8px 20px rgba(99,102,241,.4);
}
.login-brand h2 { margin: 0; font-size: 20px; }
.login-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; }
.login-wrap label { display: block; font-size: 12px; color: var(--ink-2); margin: 12px 0 5px; }
.login-wrap input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.login-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-wrap button { width: 100%; margin-top: 20px; padding: 12px; font-size: 15px; letter-spacing: 2px; }
.remember-row {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 0; font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.remember-row input { width: auto; margin: 0; cursor: pointer; }
.remember-row span { user-select: none; }

/* ============ 广字布局 ============ */
.layout { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: linear-gradient(180deg, #1e293b, #0f172a);
  border-bottom: 1px solid #0b1220;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 18px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
}
.topbar .title { font-weight: 700; font-size: 16px; color: #f1f5f9; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent-soft); color: var(--accent-d);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.user-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px #22c55e33; }

.body { flex: 1; display: flex; min-height: 0; }

/* 左侧边栏(广字的一竖) */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #1e293b, #0f172a);
  color: #cbd5e1;
  padding: 18px 14px;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.nav-group-label { font-size: 11px; letter-spacing: 1px; color: #64748b; text-transform: uppercase; padding: 4px 10px 10px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.tab {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 10px; cursor: pointer;
  font-size: 14px; color: #cbd5e1;
  transition: background .15s, color .15s;
}
.tab:hover { background: #ffffff12; color: #fff; }
.tab.active { background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; box-shadow: 0 8px 18px rgba(99,102,241,.35); }
.nav-ico { width: 20px; text-align: center; font-size: 14px; opacity: .9; }

/* 右内容区 */
.content { flex: 1; overflow-y: auto; padding: 24px 26px; }

/* ============ 通用组件 ============ */
button {
  background: var(--accent-d); color: #fff; border: 0;
  padding: 9px 17px; border-radius: 9px; font-size: 14px; cursor: pointer;
  font-weight: 600; transition: transform .06s, box-shadow .15s, background .15s;
  box-shadow: 0 1px 2px rgba(79,70,229,.25);
}
button:hover { background: var(--accent); box-shadow: 0 4px 12px rgba(99,102,241,.35); }
button:active { transform: translateY(1px); }
button.ghost { background: #eef0f5; color: #374151; box-shadow: none; }
button.ghost:hover { background: #e2e5ee; }
button.danger { background: #ef4444; box-shadow: 0 1px 2px rgba(239,68,68,.25); }
button.danger:hover { background: #dc2626; }
button.sm { padding: 6px 11px; font-size: 13px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.page-head-text { min-width: 0; }
.page-head h1 { margin: 0; font-size: 21px; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; }
.page-head > button { flex: 0 0 auto; }

.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
  background: #fff; padding: 12px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.toolbar select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; background: #fff;
}
.toolbar .search {
  flex: 1; min-width: 180px; max-width: 340px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; background: #fff;
}
.toolbar .search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar .filter {
  width: 150px; min-width: 110px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; background: #fff;
}
.toolbar input.filter:focus, .toolbar select.filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar-add { margin-left: auto; }

/* 分页 */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; flex-wrap: wrap; gap: 10px;
}
.pager-info { color: var(--ink-2); font-size: 13px; }
.pager-btns { display: flex; gap: 8px; }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
button:disabled:hover { background: #eef0f5; }

.card-table {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { background: #fafbfe; color: var(--ink-2); font-weight: 600; font-size: 12px; letter-spacing: .3px; text-transform: uppercase; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }
td .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--ink-2); word-break: break-all; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #fee2e2; color: #991b1b; }
.empty { text-align: center; color: #9aa2b1; padding: 34px 0; }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; overflow: auto; z-index: 50;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 580px;
  padding: 24px 26px; box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
  margin: auto; max-height: calc(100vh - 48px); overflow-y: auto;
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 18px; font-size: 18px; }

/* 确认弹窗 */
.modal-confirm { max-width: 400px; text-align: center; }
.modal-confirm h3 { margin: 4px 0 8px; }
.confirm-icon {
  width: 54px; height: 54px; margin: 0 auto 4px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; line-height: 1;
  background: var(--accent-soft); color: var(--accent-d);
}
.confirm-icon.danger { background: #fee2e2; color: #dc2626; }
.confirm-msg { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.7; }
.modal-confirm .modal-actions { justify-content: center; margin-top: 22px; }
.modal-confirm .modal-actions button { min-width: 92px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 62px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* 只读输入(系统生成/展示用) */
input.ro { background: #f4f6fb; color: var(--ink-2); cursor: not-allowed; }

/* 品牌图标上传 */
.icon-uploader { display: flex; align-items: center; gap: 14px; }
.icon-preview {
  width: 64px; height: 64px; flex: 0 0 64px;
  border-radius: 12px; object-fit: cover;
  border: 1px solid var(--line); background: #f4f6fb;
}
.icon-preview.empty {
  background: repeating-conic-gradient(#eef0f5 0% 25%, #f8f9fc 0% 50%) 50% / 16px 16px;
}
.icon-uploader-body { flex: 1; min-width: 0; }
.icon-uploader-body input[type="file"] { font-size: 13px; }
.icon-uploader-body .hint { margin: 6px 0 0; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #111827; color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 100;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hint { color: var(--ink-2); font-size: 13px; }

/* ============ 使用说明 / 接入指南 ============ */
.guide-flow {
  display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.guide-step {
  flex: 1; min-width: 180px;
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.guide-step .guide-num {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 30px; padding: 0 10px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff;
  font-size: 13px; font-weight: 700;
}
.guide-step b { font-size: 14px; }
.guide-step p { margin: 3px 0 0; font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.guide-arrow { display: flex; align-items: center; color: #c3c8d4; font-size: 20px; font-weight: 700; }

.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.guide-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px;
}
.guide-card h3 { margin: 0 0 12px; font-size: 16px; }
.guide-card p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.7; color: #374151; }
.guide-card code {
  background: var(--accent-soft); color: var(--accent-d);
  padding: 1px 6px; border-radius: 6px; font-size: 12.5px;
  font-family: ui-monospace, Menlo, monospace;
}
.guide-code {
  background: #0f172a; color: #93c5fd;
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px;
  padding: 12px 14px; border-radius: 10px; margin: 4px 0 4px;
  word-break: break-all; line-height: 1.6;
}
.guide-btn {
  display: inline-block; margin-top: 12px;
  background: var(--accent-d); color: #fff; text-decoration: none;
  padding: 9px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
}
.guide-btn:hover { background: var(--accent); }
.guide-list { margin: 6px 0 0; padding-left: 20px; }
.guide-list li { font-size: 13.5px; line-height: 1.8; color: #374151; }
.guide-api { width: 100%; border-collapse: collapse; margin-top: 4px; }
.guide-api th, .guide-api td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.guide-api th { color: var(--ink-2); font-weight: 600; }
.guide-api td.mono { font-family: ui-monospace, Menlo, monospace; color: var(--accent-d); }
.guide-tip { margin-top: 16px; border-left: 3px solid var(--accent); }
@media (max-width: 720px) { .guide-grid { grid-template-columns: 1fr; } }

/* 文案编辑区 */
.text-editor { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 20px 22px; }
.text-editor .field-row { margin-bottom: 15px; }
.text-editor .field-row:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
  :root { --sidebar-w: 60px; }
  .tab span:not(.nav-ico) { display: none; }
  .nav-group-label, .sidebar-footer { display: none; }
  .topbar .title { font-size: 14px; }
  .form-grid { grid-template-columns: 1fr; }
}
