* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: #f6f7fb; color: #1f2d3d; }

/* ========== 登录 ========== */
.login-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(135deg, #1a1c2e 0%, #2d3561 50%, #1f2d3d 100%); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.login-card { background: #fff; border-radius: 16px; padding: 48px 40px; width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; font-size: 28px; font-weight: 700; color: #1f2d3d; margin-bottom: 4px; }
.login-subtitle { text-align: center; font-size: 14px; color: #6b7a90; margin-bottom: 36px; }
.login-field { margin-bottom: 20px; }
.login-field label { display: block; font-size: 14px; font-weight: 500; color: #374151; margin-bottom: 6px; }
.login-field input { width: 100%; padding: 12px 14px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; transition: border-color 0.2s, box-shadow 0.2s; }
.login-field input:focus { border-color: #2563eb; outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.login-error { color: #dc2626; font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.login-btn { width: 100%; padding: 12px; background: #2563eb; color: #fff; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; letter-spacing: 4px; }
.login-btn:hover { background: #1d4ed8; }
.login-btn:disabled { background: #93c5fd; cursor: not-allowed; }
.login-footer { text-align: center; font-size: 12px; color: #9ca3af; margin-top: 28px; }

/* ========== 布局 ========== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1f2d3d; color: #fff; padding: 24px 16px; display: flex; flex-direction: column; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
.brand { font-size: 18px; font-weight: 600; margin-bottom: 24px; }
.admin-user { padding: 10px 12px; margin-bottom: 12px; background: rgba(255,255,255,0.08); border-radius: 6px; font-size: 13px; color: #a0aec0; }
.admin-user strong { display: block; color: #fff; font-size: 14px; margin-bottom: 2px; }
.sidebar-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.nav-btn { width: 100%; margin-bottom: 8px; padding: 10px 12px; border: none; background: #2f4058; color: #fff; border-radius: 6px; cursor: pointer; text-align: left; font-size: 14px; }
.nav-btn.active, .nav-btn:hover { background: #3b4e6b; }
.logout-btn { background: #4a1d1d !important; color: #fca5a5 !important; }
.logout-btn:hover { background: #7f1d1d !important; }
.content { flex: 1; padding: 24px; overflow-y: auto; max-height: 100vh; }
.section { display: none; }
.section.active { display: block; }

/* ========== 头部 ========== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h2 { margin: 0; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.filter-select { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; background: #fff; }

/* ========== 卡片 ========== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.card-title { font-size: 14px; color: #6b7a90; }
.card-value { font-size: 22px; margin-top: 8px; font-weight: 600; }

/* ========== 表格 ========== */
.table-wrap { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid #edf0f5; font-size: 14px; }
th { background: #f5f7fb; text-align: left; color: #6b7a90; }
.product-thumb { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: #f0f0f0; }
.tag-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; margin-right: 6px; color: #fff; }
.cat-label { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; background: #e0e7ff; color: #3730a3; }
.status-badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.status-active { background: #dcfce7; color: #166534; }
.status-inactive { background: #f3f4f6; color: #6b7280; }
.status-sold_out { background: #fee2e2; color: #991b1b; }

/* ========== 按钮 ========== */
input, select, textarea { padding: 10px; border: 1px solid #d7dce3; border-radius: 6px; font-size: 14px; font-family: inherit; }
textarea { resize: vertical; }
button { padding: 10px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: #fff; color: #2563eb; border: 1px solid #2563eb; }
.btn-outline:hover { background: #eff6ff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.action-btn { margin-right: 6px; padding: 6px 12px; background: #64748b; color: #fff; font-size: 13px; }
.action-btn.danger { background: #ef4444; }
.action-btn:hover { opacity: 0.9; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.toolbar { margin: 12px 0 16px; }
.link-btn { display: inline-block; padding: 10px 14px; border-radius: 6px; background: #0f766e; color: #fff; text-decoration: none; font-size: 14px; }
.link-btn:hover { background: #0d5d59; }

/* ========== 模态框 ========== */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 10000; align-items: flex-start; justify-content: center; padding: 30px; overflow-y: auto; }
.modal-overlay.show { display: flex; }
.modal-box { background: #fff; border-radius: 12px; width: 600px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,0.2); animation: modalIn 0.2s ease; }
.modal-large { width: 900px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid #edf0f5; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; color: #6b7a90; cursor: pointer; padding: 0 4px; }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid #edf0f5; }

/* ========== 表单分区 ========== */
.form-section { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid #f0f0f0; }
.form-section:last-child { border-bottom: none; }
.form-section-title { font-size: 15px; font-weight: 600; color: #1f2d3d; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid #2563eb; display: inline-block; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: #374151; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.full-width { grid-column: 1 / -1; }
.category-section { display: none; }
.category-section.visible { display: block; }
.category-hierarchy-row { margin-top: 4px; }
.category-selector { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.category-selector .major-cat-display {
  font-weight: 700; color: #2563eb; background: #eff6ff; padding: 10px 20px; border-radius: 8px; min-width: 100px; text-align: center;
}
.category-selector select { flex: 1; min-width: 200px; max-width: 320px; }

/* ========== 图片上传 ========== */
.image-upload-area { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px; border: 2px dashed #d1d5db; border-radius: 8px; min-height: 100px; }
.image-list { display: flex; flex-wrap: wrap; gap: 10px; }
.image-item { position: relative; width: 100px; height: 100px; border-radius: 6px; overflow: hidden; cursor: grab; }
.image-item img { width: 100%; height: 100%; object-fit: cover; }
.image-item .img-remove { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 50%; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.image-item .img-order { position: absolute; bottom: 2px; left: 2px; background: rgba(0,0,0,0.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.upload-trigger { width: 100px; height: 100px; border: 2px dashed #c0c0c0; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: #9ca3af; font-size: 13px; transition: border-color 0.2s; }
.upload-trigger:hover { border-color: #2563eb; color: #2563eb; }
.upload-icon { font-size: 28px; line-height: 1; }
.upload-loading { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.8); display: flex; align-items: center; justify-content: center; font-size: 12px; color: #2563eb; }

/* ========== 视频上传 ========== */
.video-upload-area { padding: 12px; border: 2px dashed #d1d5db; border-radius: 8px; }
.video-preview { margin-bottom: 10px; }
.video-preview video { max-width: 100%; max-height: 240px; border-radius: 6px; }
.video-preview .video-actions { margin-top: 8px; }

/* ========== 富文本编辑器 ========== */
.rich-toolbar { border: 1px solid #d1d5db; border-bottom: none; border-radius: 6px 6px 0 0; }
.rich-editor { border: 1px solid #d1d5db; border-radius: 0 0 6px 6px; min-height: 300px; }

/* ========== 动态列表 ========== */
.dynamic-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.dynamic-row input { flex: 1; padding: 8px; }
.dynamic-row .row-remove { width: 30px; height: 30px; padding: 0; background: #fee2e2; color: #ef4444; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }

/* ========== 分类管理 ========== */
.category-tips {
  font-size: 13px; color: #6b7a90; margin-bottom: 16px; padding: 12px 16px; background: #f0f9ff; border-radius: 8px; border-left: 4px solid #2563eb;
}
.category-tree { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.cat-empty {
  text-align: center; padding: 60px 40px;
}
.cat-empty-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.5; }
.cat-empty-text { font-size: 18px; font-weight: 600; color: #374151; margin: 0 0 8px; }
.cat-empty-hint { font-size: 14px; color: #6b7a90; margin: 0 0 24px; line-height: 1.6; }
.cat-group { margin-bottom: 16px; }
.cat-parent { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #f8fafc; border-radius: 8px; font-weight: 600; font-size: 15px; flex-wrap: wrap; }
.cat-parent .cat-icon { font-size: 20px; }
.cat-name { flex: 0 0 auto; }
.cat-children { padding-left: 40px; margin-top: 4px; }
.cat-child { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #f0f0f0; font-size: 14px; flex-wrap: wrap; }
.cat-child:last-child { border-bottom: none; }
.cat-actions { margin-left: auto; display: flex; gap: 6px; }
.cat-code { color: #6b7a90; font-size: 12px; background: #f3f4f6; padding: 2px 8px; border-radius: 4px; }
.cat-desc { color: #9ca3af; font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-product-count { font-size: 12px; color: #059669; background: #ecfdf5; padding: 2px 8px; border-radius: 4px; }
.cat-status { font-size: 11px; padding: 2px 8px; border-radius: 4px; }
.cat-status.cat-active { background: #dcfce7; color: #166534; }
.cat-status.cat-inactive { background: #f3f4f6; color: #6b7280; }

/* ========== 支付配置 ========== */
.pay-status-bar { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pay-status-bar.enabled { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.pay-status-bar.disabled { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.pay-config-wrap { display: flex; flex-direction: column; gap: 24px; }
.pay-section { background: #fff; border-radius: 10px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.pay-section h3 { font-size: 16px; margin: 0 0 4px; color: #1f2d3d; }
.section-desc { font-size: 13px; color: #6b7a90; margin: 0 0 20px; }
.pay-form { display: flex; flex-direction: column; gap: 18px; }
.pay-field { display: flex; flex-direction: column; gap: 6px; }
.pay-field label { font-size: 14px; font-weight: 500; color: #374151; }
.pay-field input[type="text"], .pay-field input[type="password"] { padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; max-width: 500px; }
.pay-field input:focus { border-color: #2563eb; outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.field-hint { font-size: 12px; color: #9ca3af; }
.secret-input-wrap { display: flex; gap: 8px; max-width: 500px; }
.secret-input-wrap input { flex: 1; }
.eye-btn { padding: 8px 12px; background: #e5e7eb; color: #374151; border: 1px solid #d1d5db; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.eye-btn:hover { background: #d1d5db; }
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle-input { display: none; }
.toggle-label { position: relative; width: 48px; height: 26px; background: #d1d5db; border-radius: 13px; cursor: pointer; transition: background 0.3s; }
.toggle-label::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform 0.3s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle-input:checked + .toggle-label { background: #22c55e; }
.toggle-input:checked + .toggle-label::after { transform: translateX(22px); }
.toggle-text { font-size: 13px; color: #6b7a90; }
.pay-actions { display: flex; gap: 12px; margin-top: 24px; }

/* ========== CRM 状态标签 ========== */
.status-tag { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.status-pending { background: #fef3c7; color: #d97706; }
.status-confirmed { background: #dbeafe; color: #2563eb; }
.status-checked_in { background: #d1fae5; color: #059669; }
.status-completed { background: #f0fdf4; color: #16a34a; }
.status-cancelled { background: #f3f4f6; color: #9ca3af; }
.status-no_show { background: #fef2f2; color: #dc2626; }

/* ========== 分享数据追踪 ========== */
.share-stats-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ss-card { flex: 1; min-width: 100px; background: #fff; border-radius: 10px; padding: 16px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.ss-card.ss-highlight { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }
.ss-val { font-size: 24px; font-weight: 700; color: #1f2937; }
.ss-highlight .ss-val { color: #7c3aed; }
.ss-lbl { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.funnel-card { padding: 20px; }
.funnel-bar { position: relative; height: 36px; background: #f3f4f6; border-radius: 6px; margin-bottom: 8px; overflow: hidden; }
.funnel-fill { height: 100%; background: #7c3aed; border-radius: 6px; transition: width 0.5s; }
.funnel-fill.funnel-reg { background: #2563eb; }
.funnel-fill.funnel-ord { background: #16a34a; }
.funnel-text { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 500; color: #374151; z-index: 1; }

/* ========== 优惠券 & 回复管理 ========== */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checkbox-group label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.form-section { margin-top: 16px; }
.form-section-title { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 8px; }
.rich-toolbar { border: 1px solid #d1d5db; border-bottom: none; border-radius: 6px 6px 0 0; }
.rich-editor { border: 1px solid #d1d5db; border-radius: 0 0 6px 6px; min-height: 200px; }
.modal-large { max-width: 720px; }

/* ========== 数据分析 ========== */
.analytics-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 0; }
.analytics-toolbar input[type="date"] { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }

/* ========== 权限管理 ========== */
.rbac-tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid #e5e7eb; }
.rbac-tab { padding: 10px 20px; border: 0; background: none; font-size: 14px; font-weight: 500; color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.rbac-tab.active { color: #3B82F6; border-bottom-color: #3B82F6; }
.rbac-panel { display: none; }
.rbac-panel.active { display: block; }
.rbac-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.rbac-toolbar .btn-primary { padding: 8px 16px; background: #3B82F6; color: #fff; border: 0; border-radius: 6px; cursor: pointer; font-size: 14px; }
.rbac-toolbar .btn-primary:hover { background: #2563EB; }
.form-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.form-row label { width: 100px; font-size: 13px; color: #374151; text-align: right; flex-shrink: 0; }
.form-row input, .form-row select { flex: 1; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; max-width: 400px; }
.perm-matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.perm-matrix th { background: #f3f4f6; padding: 6px 4px; border: 1px solid #e5e7eb; font-weight: 600; color: #374151; }
.perm-matrix td { padding: 6px 4px; border: 1px solid #e5e7eb; }
.perm-matrix td:first-child { background: #fafbfc; }
.perm-matrix input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.btn-sm { padding: 4px 10px; font-size: 12px; border: 1px solid #d1d5db; border-radius: 4px; cursor: pointer; color: #374151; }
.btn-sm:hover { background: #f3f4f6; }
.btn-sm.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-sm.btn-primary:hover { background: #1d4ed8; }
.btn-sm.btn-outline { background: #fff; color: #2563eb; border-color: #2563eb; }
.btn-sm.btn-outline:hover { background: #eff6ff; }
.btn-sm.btn-danger { background: #fff; color: #DC2626; border-color: #FCA5A5; }
.btn-sm.btn-danger:hover { background: #FEE2E2; }
.btn-sm.btn-accent { background: var(--color-accent, #F5A623); color: #fff; border-color: var(--color-accent, #F5A623); }
.btn-sm.btn-accent:hover { background: var(--color-accent-dark, #D4930D); }
.btn-danger { color: #DC2626; border-color: #FCA5A5; }
.btn-danger:hover { background: #FEE2E2; }
.btn-ghost { padding: 8px 16px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; }
.btn-ghost:hover { background: #f3f4f6; }
.nav-btn-em { font-weight: 700; color: #3B82F6; }

/* 模态框 */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px; width: min(600px,92vw); max-height: 85vh; overflow: auto; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.modal-large { width: min(800px,95vw); }
.btn-close { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--color-text-secondary, #8C9BAB); padding: 4px 8px; }

/* 富文本编辑器容器 */
.rich-editor-container {  }
.rich-editor-container .w-e-text-container { border-radius: 0 0 6px 6px !important; }
.rich-editor-container .w-e-toolbar { border-radius: 6px 6px 0 0 !important; }
.analytics-toolbar label { font-size: 14px; font-weight: 500; color: #374151; }

/* 二级导航 */
.nav-parent { font-weight: 700 !important; }
.nav-sub { display: none; margin-left: 8px; border-left: 2px solid var(--color-primary-light, #EBF4FF); padding-left: 4px; }
.nav-sub.open { display: block; }
.nav-sub-btn { font-size: 13px !important; padding: 6px 10px !important; padding-left: 20px !important; }
.nav-sub-btn.active { background: var(--color-primary-light, #EBF4FF) !important; color: var(--color-primary, #3B82F6) !important; font-weight: 600; }
.nav-parent.active { background: var(--color-primary-light, #EBF4FF); color: var(--color-primary, #3B82F6); }
