/* 商家 AI 客服 UI 原画 · 样式 */

:root {
  --admin-bg: #f4f6f9;
  --admin-sidebar: #151821;
  --admin-sidebar-2: #1c2030;
  --admin-sidebar-text: #9aa3b2;
  --admin-sidebar-active: #ffffff;
  --card-bg: #ffffff;
  --border: #e6eaf0;
  --border-soft: #eef1f6;
  --text: #141824;
  --text-secondary: #64748b;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --primary-hover: #1d4ed8;
  --primary-light: #60a5fa;
  --primary-grad-end: #60a5fa;
  --primary-rgb: 37, 99, 235;
  --accent: #3b82f6;
  --success: #059669;
  --warn: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 36, 0.04), 0 4px 12px rgba(20, 24, 36, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 24, 36, 0.08);
  --shadow-lg: 0 20px 50px rgba(20, 24, 36, 0.12);
  --font: "DM Sans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37, 99, 235, 0.08), transparent),
    linear-gradient(180deg, #eceff4 0%, #e2e8f0 100%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
}

a:hover,
a:focus,
a:active {
  text-decoration: none;
}

/* ===== 预览外壳 ===== */
.preview-shell { padding-bottom: 40px; }

.preview-header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.preview-header-inner {
  padding: 20px 32px 12px;
  max-width: 1400px;
  margin: 0 auto;
}

.preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.preview-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.preview-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.preview-tabs {
  display: flex;
  gap: 8px;
  padding: 0 32px 16px;
  max-width: 1400px;
  margin: 16px auto 0;
}

.tab {
  padding: 8px 18px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 999px;
  margin-bottom: 0;
  font-family: inherit;
  transition: var(--transition);
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.tab.active {
  color: var(--primary);
  background: #fff;
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.view { display: none; }
.view.active { display: block; }

/* ===== 管理后台布局 ===== */
.admin-layout {
  display: flex;
  height: 100vh;
  min-height: 0;
  width: 100%;
  margin: 0;
  max-width: none;
  background: var(--card-bg);
  border-radius: 0;
  overflow: hidden;
  border: none;
  box-shadow: none;
}

body.admin-page {
  background: var(--admin-bg);
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

.preview-shell .admin-layout {
  min-height: calc(100vh - 140px);
  max-width: 1400px;
  margin: 8px auto 32px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-lg);
}

.admin-sidebar {
  width: 232px;
  background: linear-gradient(180deg, var(--admin-sidebar) 0%, #12151c 100%);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 0 8px 24px;
  border-bottom: 1px solid #2d323c;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

/* 一级菜单 */
.nav-l1-btn,
.nav-l1-flat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--admin-sidebar-text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  font-family: inherit;
  text-decoration: none;
}

.nav-l1-flat { font-weight: 500; margin-top: 8px; }

.nav-l1-btn:hover,
.nav-l1-flat:hover { background: #2d323c; color: #fff; }

.nav-l1-flat.active { background: #2d323c; color: #fff; }

.nav-group.nav-l1.open > .nav-l1-btn {
  background: #2d323c;
  color: #fff;
}

.nav-group.nav-l1.open > .nav-l1-btn .nav-icon,
.nav-group.nav-l1.open > .nav-l1-btn .nav-chevron {
  opacity: 1;
}

.nav-chevron {
  font-size: 12px;
  transition: transform 0.2s;
  opacity: 0.6;
  flex-shrink: 0;
}

.nav-item-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.82;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
}

.nav-l1-btn:hover .nav-icon,
.nav-l1-flat:hover .nav-icon,
.nav-l2:hover .nav-icon,
.nav-l2.active .nav-icon {
  opacity: 1;
}

.nav-group.open > .nav-l1-btn .nav-chevron,
.nav-group.open > .nav-l2-btn .nav-chevron {
  transform: rotate(90deg);
}

.nav-l1-children {
  display: none;
  padding-left: 8px;
  margin-bottom: 4px;
}

.nav-group.nav-l1.open > .nav-l1-children { display: block; }

/* 二级 */
.nav-l2 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
  margin: 2px 0;
}

.nav-l2:hover { background: #2d323c; color: #fff; }
.nav-l2.active {
  color: #fff;
  background: #2d323c;
}

.nav-l2-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px 8px 20px;
  border: none;
  background: transparent;
  color: #d1d5db;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
  text-align: left;
}

.nav-l2-btn:hover { background: #2d323c; }

.nav-l2-children {
  display: none;
  padding-left: 12px;
}

.nav-group.nav-l2-branch.open > .nav-l2-children { display: block; }

/* 三级 */
.nav-l3 {
  display: block;
  padding: 7px 12px 7px 28px;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 12px;
  border-radius: 6px;
  margin: 1px 0;
}

.nav-l3:hover {
  color: #fff;
  background: #252830;
}

.nav-l3.active {
  color: #fff;
  background: rgba(37, 99, 235, 0.15);
}

.admin-subview { display: none; }
.admin-subview.active { display: block; }

.nav-group.nav-l2-branch[hidden] { display: none; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.breadcrumb span:not(:last-child)::after {
  content: "›";
  margin-left: 6px;
  opacity: 0.5;
}

.single-col { max-width: 640px; }

.logo-preview.lg {
  width: 120px;
  height: 120px;
  border-radius: 20px;
}

.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

/* ===== 商户端（浅色侧栏，与平台后台区分） ===== */
.merchant-layout .admin-main {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.merchant-sidebar {
  width: 248px;
  background: #fff;
  border-right: 1px solid var(--border-soft);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  min-height: 0;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.8);
  overflow: hidden;
}

.merchant-nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.merchant-sidebar-foot {
  margin-top: auto;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.merchant-contact-wrap {
  position: relative;
  margin-bottom: 12px;
}

.merchant-contact-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.merchant-contact-btn:hover,
.merchant-contact-wrap:hover .merchant-contact-btn {
  background: #f3f4f6;
  color: var(--text);
}

.merchant-contact-btn .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.merchant-contact-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  width: auto;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 120;
  pointer-events: none;
}

.merchant-contact-wrap:hover .merchant-contact-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.merchant-contact-popover::before {
  content: '';
  position: absolute;
  left: 24px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  transform: rotate(45deg);
}

.merchant-contact-popover-title {
  padding: 14px 16px 10px;
  font-size: 14px;
  font-weight: 600;
  color: #4f46e5;
  border-bottom: 1px solid var(--border-soft);
}

.merchant-contact-popover-body {
  padding: 12px 16px 16px;
}

.merchant-contact-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
}

.merchant-contact-row + .merchant-contact-row {
  border-top: 1px solid #f1f5f9;
}

.merchant-contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.merchant-contact-icon svg {
  width: 14px;
  height: 14px;
}

.merchant-contact-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  padding-top: 4px;
  word-break: break-all;
}

.merchant-contact-qr {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
}

.merchant-contact-qr-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.merchant-contact-qr-img {
  width: 148px;
  height: 148px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #fff;
}

.merchant-shop-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(135deg, #fffaf7 0%, #fff 100%);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: var(--radius);
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.merchant-shop-card .shop-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.merchant-shop-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.merchant-shop-id {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-family: monospace;
}

.merchant-nav .nav-l1-btn,
.merchant-nav .nav-l1-flat {
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 0;
}

.merchant-nav .nav-group + .nav-group {
  margin-top: 4px;
}

.merchant-nav .nav-l1-flat {
  justify-content: flex-start;
}

.merchant-nav .nav-l1-btn {
  font-weight: 600;
  color: var(--text);
}

.merchant-nav .nav-l1-btn:hover,
.merchant-nav .nav-l1-flat:hover {
  background: #f3f4f6;
  color: var(--text);
}

.merchant-nav .nav-l1-flat.active {
  background: #f3f4f6;
  color: var(--text);
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.merchant-nav .nav-group.nav-l1.open > .nav-l1-btn {
  background: #f3f4f6;
  color: var(--text);
}

.merchant-nav .nav-l2,
.merchant-nav .nav-l2-btn,
.merchant-nav .nav-l3 {
  color: var(--text-secondary);
}

.merchant-nav .nav-l2 {
  padding-left: 16px;
}

.merchant-nav .nav-l2-btn {
  color: var(--text);
  padding-left: 16px;
  font-weight: 500;
}

.merchant-nav .nav-l3 {
  padding-left: 28px;
  font-size: 13px;
}

.merchant-nav .nav-l2:hover,
.merchant-nav .nav-l2.active,
.merchant-nav .nav-l2-btn:hover,
.merchant-nav .nav-l3:hover,
.merchant-nav .nav-l3.active {
  background: #f3f4f6;
  color: var(--text);
}

.merchant-nav .nav-l2.active,
.merchant-nav .nav-l3.active {
  font-weight: 500;
}

.merchant-nav .nav-group + .nav-l1-flat {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.merchant-nav .nav-l2-btn.active {
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.merchant-nav .nav-l2-children {
  padding-left: 4px;
}

.merchant-user {
  border-top: 1px solid var(--border);
  margin-top: 0;
  padding-top: 16px;
  flex-shrink: 0;
}

.merchant-user .user-name { color: var(--text); }
.merchant-user .user-role { color: var(--text-secondary); }

.merchant-avatar {
  background: #2563eb;
  color: #fff;
}

.merchant-subview { display: none; }
.merchant-subview.active { display: block; }

.stat-value.stat-ok {
  font-size: 20px;
  color: var(--success);
}

/* ===== 商户工作台 ===== */
.merchant-dashboard {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.merchant-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.m-stat-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.m-stat-card:hover {
  border-color: var(--border-soft);
  box-shadow: none;
}

.m-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
}

.m-stat-icon svg {
  width: 20px;
  height: 20px;
}

.m-stat-icon-chat,
.m-stat-icon-doc,
.m-stat-icon-ok,
.m-stat-icon-expire {
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
}

.m-stat-body {
  flex: 1;
  min-width: 0;
}

.m-stat-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.m-stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

.m-stat-value-ok {
  font-size: 22px;
  color: var(--text);
}

.m-stat-icon-expire + .m-stat-body .m-stat-value {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.m-stat-value-warn {
  color: #b45309;
}

.m-stat-value-danger {
  color: #dc2626;
}

.m-stat-meta {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.m-stat-meta.is-up {
  color: var(--text-secondary);
}

.shortcut-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.shortcut-panel-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.shortcut-panel-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.shortcut-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 16px;
  border: none;
  border-right: 1px solid var(--border-soft);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition);
}

.shortcut-btn:last-child {
  border-right: none;
}

.shortcut-btn:hover {
  background: #fafbfc;
}

.shortcut-btn:active {
  background: #f4f6f8;
}

.shortcut-btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: #f8fafc;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.shortcut-btn-icon svg {
  width: 18px;
  height: 18px;
}

.shortcut-btn:hover .shortcut-btn-icon {
  border-color: #d8dee8;
  color: var(--text);
  background: #fff;
}

.shortcut-btn-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  text-align: center;
}

.m-conv-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.m-conv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.m-conv-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.m-conv-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.m-conv-list {
  display: flex;
  flex-direction: column;
}

.m-conv-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--transition);
  cursor: pointer;
}

.m-conv-item:last-child {
  border-bottom: none;
}

.m-conv-item:hover {
  background: #fafbfd;
}

.m-conv-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.m-conv-q {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-conv-rounds {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .merchant-stats {
    grid-template-columns: 1fr;
  }

  .shortcut-grid {
    grid-template-columns: 1fr;
  }

  .shortcut-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }

  .shortcut-btn:last-child {
    border-bottom: none;
  }

  .shortcut-btn-label {
    text-align: left;
  }
}

.merchant-quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.action-card {
  text-align: left;
  padding: 18px;
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.action-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  opacity: 0;
  transition: var(--transition);
}

.action-card:hover {
  border-color: rgba(37, 99, 235, 0.25);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.action-card:hover::before {
  opacity: 1;
}

.action-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text);
}

.action-card span {
  font-size: 12px;
  color: var(--text-secondary);
}

.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 0;
}

.table-card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

@media (max-width: 1100px) {
  .merchant-quick-actions { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 广告 ===== */
.ad-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ad-thumb {
  width: 72px;
  height: 36px;
  border-radius: 6px;
  flex-shrink: 0;
}

.ad-preview-banner,
.merchant-ad-banner {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.merchant-ad-banner.clickable {
  cursor: pointer;
  margin-bottom: 24px;
  transition: var(--transition);
}

.merchant-ad-banner.clickable:hover {
  border-color: rgba(37, 99, 235, 0.28);
  background: #fffcfa;
}

.ad-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.ad-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary);
}

.ad-banner-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  min-width: 0;
}

.ad-banner-copy strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ad-banner-copy span {
  font-size: 12px;
  color: var(--text-secondary);
}

.ad-arrow {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition);
}

.merchant-ad-banner.clickable:hover .ad-arrow {
  color: var(--primary);
  transform: translateX(2px);
}

.merchant-preview-shell {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  box-shadow: var(--shadow-sm);
}

.merchant-preview-top {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.merchant-preview-shell .merchant-ad-banner {
  border-radius: 0;
  margin: 0;
}

.merchant-preview-body {
  padding: 12px;
}

.ad-display-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
}

.ad-display-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ad-display-card .merchant-ad-banner {
  border-radius: 0;
}

.ad-display-meta {
  padding: 14px 16px;
}

.ad-display-meta strong {
  margin-right: 8px;
}

.ad-display-meta p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.nav-item {
  display: block;
  padding: 10px 12px;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 14px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.nav-item:hover { background: #2d323c; color: #fff; }

.nav-item.active {
  background: #2d323c;
  color: var(--admin-sidebar-active);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid #2d323c;
  margin-top: 16px;
  flex-shrink: 0;
}

.avatar {
  width: 36px;
  height: 36px;
  background: #3d4450;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
}

.user-name { color: #fff; font-size: 13px; font-weight: 500; }
.user-role { color: var(--admin-sidebar-text); font-size: 11px; }

.sidebar-user-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.info-summary {
  display: grid;
  gap: 12px;
  padding: 16px 20px;
  background: var(--admin-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.info-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
}

.info-summary-row span {
  color: var(--text-muted);
}

.info-summary-row strong {
  color: var(--text);
  font-weight: 600;
}

.quick-buttons-list {
  display: grid;
  gap: 8px;
}

.quick-button-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.quick-button-row .quick-button-input {
  flex: 1;
}

.modal-panel-wide {
  max-width: 720px;
}

.conv-meta {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.conv-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.conv-meta-row span {
  color: var(--text-muted);
}

.conv-messages {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
}

.conv-message {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--admin-bg);
}

.conv-message-assistant {
  border-left: 3px solid var(--primary);
}

.conv-message-role {
  display: inline-block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.table-ellipsis {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-upload-card {
  margin-bottom: 20px;
}

.kb-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 140px;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--admin-bg);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kb-upload-zone:hover,
.kb-upload-zone.is-dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--admin-bg));
}

.kb-upload-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.kb-upload-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.kb-doc-title {
  font-weight: 600;
  color: var(--text);
}

.kb-doc-filename {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.role-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.role-list {
  display: grid;
  gap: 8px;
}

.role-list-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.role-list-item:hover,
.role-list-item.is-active {
  border-color: var(--primary);
  background: #f8fbff;
}

.role-list-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.role-list-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.role-list-badge {
  justify-self: start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
}

.role-perm-section {
  margin-top: 8px;
}

.role-perm-group {
  margin-bottom: 16px;
}

.role-perm-group-title {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.role-perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px 12px;
}

.role-perm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.role-super-hint {
  margin-top: 0;
}

.role-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-delete-btn {
  color: #dc2626;
}

.role-delete-btn:hover {
  color: #b91c1c;
  background: #fef2f2;
}

.role-delete-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

@media (max-width: 960px) {
  .role-layout {
    grid-template-columns: 1fr;
  }
}

.admin-main {
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding: 28px 32px;
  background: var(--admin-bg);
  overflow-y: auto;
  overflow-x: hidden;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.page-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.back-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  display: block;
  margin-bottom: 8px;
}

.back-link:hover { color: var(--primary); }

.header-actions { display: flex; gap: 10px; }

/* 按钮 */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-ghost {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: #cbd5e1;
  background: #fafbfc;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  padding: 0 6px;
  font-family: inherit;
  text-decoration: none;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.table-action {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.table-action:hover {
  border-color: #cbd5e1;
  color: var(--text);
  background: #f8fafc;
}

.table-action-primary {
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--primary-soft);
  color: var(--primary);
}

.table-action-primary:hover {
  border-color: var(--primary);
  background: #dbeafe;
  color: var(--primary-hover);
}

.table-action-danger {
  border-color: rgba(239, 68, 68, 0.35);
  color: #dc2626;
}

.table-action-danger:hover {
  border-color: #ef4444;
  background: #fef2f2;
  color: #b91c1c;
}

.expire-date {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.expire-date-overdue {
  color: #dc2626;
  font-weight: 500;
}

.modal[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-lg);
}

.modal-panel-wide {
  max-width: 720px;
}

.modal-panel-wide .modal-body {
  max-height: min(72vh, 640px);
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 0;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
}

.modal-body {
  padding: 18px 22px 8px;
}

.modal-body .field:last-of-type {
  margin-bottom: 8px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 22px 20px;
}

.modal-error {
  min-height: 20px;
  font-size: 13px;
  color: #dc2626;
  margin-top: 4px;
}

body.modal-open {
  overflow: hidden;
}

button.table-action {
  cursor: pointer;
  font-family: inherit;
}

.full-width { width: 100%; margin-top: 12px; }

/* 统计卡片 */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}

.stats-row-plain .stat-card {
  box-shadow: none;
}

.stats-row-plain .stat-card:hover {
  transform: none;
  box-shadow: none;
}

.stat-label {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
}

/* 表格 */
.table-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-toolbar {
  padding: 14px 20px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: #fff;
}

.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.toolbar-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.toolbar-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1;
}

.toolbar-input {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: var(--transition);
}

.toolbar-input::placeholder {
  color: #94a3b8;
}

.toolbar-input:hover {
  border-color: #cbd5e1;
}

.toolbar-input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.toolbar-input-search {
  width: 260px;
}

.toolbar-input-select {
  width: 120px;
  min-height: 36px;
  padding: 8px 28px 8px 12px;
  line-height: 1.3;
  cursor: pointer;
}

.toolbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.toolbar-actions .btn {
  transition: none;
  transform: none;
}

.toolbar-actions .btn:hover {
  transform: none;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.table-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 16px !important;
}

.table-action-muted {
  color: var(--text-secondary);
  font-size: 13px;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover td {
  background: #fafbfd;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 500;
  color: var(--text-secondary);
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  background: #fafbfc;
}

.pagination-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination-meta strong {
  color: var(--text);
  font-weight: 600;
}

.pagination-per-page {
  color: var(--text-muted, #94a3b8);
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn,
.pagination-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.pagination-page {
  min-width: 34px;
  padding: 0;
}

.pagination-btn:hover,
.pagination-page:hover {
  border-color: #93c5fd;
  color: var(--primary);
}

.pagination-page.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.pagination-btn.is-disabled,
.pagination-page.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  color: var(--text-secondary);
  font-size: 14px;
}

@media (max-width: 640px) {
  .table-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-nav {
    justify-content: center;
  }
}

.shop-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shop-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.shop-name { font-weight: 500; }
.shop-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

code {
  font-size: 12px;
  background: #f3f4f6;
  padding: 3px 8px;
  border-radius: 4px;
  color: #374151;
}

.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tag-success { background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0; }
.tag-warn { background: #fffbeb; color: var(--warn); border: 1px solid #fde68a; }

.ad-preview-banner {
  width: 100%;
  margin-bottom: 8px;
}

/* ===== 配置表单 ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.form-card {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.form-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: -8px 0 16px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.field input,
.field textarea,
.field select,
.field .field-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: #fafbfc;
  transition: var(--transition);
}

.field select,
.field .field-select {
  min-height: 42px;
  line-height: 1.4;
  padding-right: 36px;
  appearance: auto;
}

.field select.toolbar-input,
.field .field-select.toolbar-input {
  height: auto;
  min-height: 42px;
  padding: 10px 36px 10px 14px;
  line-height: 1.4;
  font-size: 14px;
  background: #fafbfc;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.field .field-select:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field input.readonly {
  background: #f9fafb;
  color: var(--text-secondary);
}

.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.field-hint-warn {
  color: #d97706;
}

.field-prefix-input {
  display: flex;
  align-items: center;
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field-prefix-input:focus-within {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-prefix {
  display: flex;
  align-items: center;
  align-self: stretch;
  height: 100%;
  padding: 0 12px;
  margin: 0;
  background: #f1f5f9;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

.field .field-prefix-input .field-prefix-control {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 100%;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  box-shadow: none;
  line-height: normal;
}

.field .field-prefix-input .field-prefix-control:focus {
  outline: none;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.field .field-prefix-input .field-prefix-control::placeholder {
  color: #94a3b8;
}

.qr-preview {
  width: 140px;
  height: 140px;
  margin-top: 0;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.qr-preview img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

.qr-preview-empty {
  font-size: 12px;
  color: var(--text-secondary);
}

.qr-upload {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 8px;
}

.qr-upload-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qr-upload-btn {
  cursor: pointer;
}

.settings-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
}

.settings-card,
.settings-log-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.settings-card-title {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 600;
}

.settings-section-title {
  margin: 20px 0 6px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.settings-card-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.settings-card-title-row .page-desc {
  margin: 0;
}

.settings-form {
  display: grid;
  gap: 18px;
}

.settings-form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-form-actions {
  margin-top: 4px;
}

.storage-driver-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.storage-driver-legend {
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.storage-driver-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.storage-driver-tab {
  position: relative;
  display: block;
  cursor: pointer;
}

.storage-driver-tab input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.storage-driver-tab-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.storage-driver-tab-body strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.storage-driver-tab-body small {
  font-size: 12px;
  color: var(--text-secondary);
}

.storage-driver-tab:hover .storage-driver-tab-body {
  border-color: #93c5fd;
}

.storage-driver-tab.is-active .storage-driver-tab-body,
.storage-driver-tab input:checked + .storage-driver-tab-body {
  border-color: #2563eb;
  background: #f8fbff;
  box-shadow: 0 0 0 1px #2563eb inset;
}

.storage-driver-hint {
  margin: 10px 0 0;
}

.checkbox-field .checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #0f172a;
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #2563eb;
  flex-shrink: 0;
}

.field-switch {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
}

.field-switch > .field-hint {
  grid-column: 1 / -1;
  margin: 0;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s ease;
  cursor: pointer;
}

.switch-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.group-storage-section {
  margin: 6px 0 10px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: #fff;
}

.group-storage-section .storage-panels {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.group-storage-section .storage-panel {
  padding-top: 0;
}

.group-storage-section.storage-cloud-only .storage-driver-fieldset {
  margin: 0;
}

.group-storage-section.storage-cloud-only .storage-driver-legend {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.group-storage-section.storage-cloud-only .storage-driver-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 10px;
  grid-template-columns: none;
}

.group-storage-section.storage-cloud-only .storage-driver-tab {
  flex: 1;
  min-width: 0;
}

.group-storage-section.storage-cloud-only .storage-driver-tab-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px 10px;
  gap: 6px;
  border: none;
  border-radius: 7px;
  background: transparent;
  text-align: center;
  box-shadow: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.group-storage-section.storage-cloud-only .storage-brand-logo {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 5px;
  object-fit: contain;
  opacity: 0.82;
  transition: opacity 0.15s ease;
}

.group-storage-section.storage-cloud-only .storage-driver-tab.is-active .storage-brand-logo,
.group-storage-section.storage-cloud-only .storage-driver-tab input:checked + .storage-driver-tab-body .storage-brand-logo {
  opacity: 1;
}

.group-storage-section.storage-cloud-only .storage-driver-tab-body strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.group-storage-section.storage-cloud-only .storage-driver-tab-body small {
  display: none;
}

.group-storage-section.storage-cloud-only .storage-driver-tab:hover .storage-driver-tab-body {
  background: rgba(255, 255, 255, 0.55);
}

.group-storage-section.storage-cloud-only .storage-driver-tab.is-active .storage-driver-tab-body,
.group-storage-section.storage-cloud-only .storage-driver-tab input:checked + .storage-driver-tab-body {
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.group-storage-section.storage-cloud-only .storage-driver-tab.is-active .storage-driver-tab-body strong,
.group-storage-section.storage-cloud-only .storage-driver-tab input:checked + .storage-driver-tab-body strong {
  color: var(--primary);
}

.group-storage-section.storage-cloud-only .storage-driver-hint {
  display: none;
}

.group-storage-section.storage-cloud-only .storage-panel .settings-card-title {
  display: none;
}

.shop-storage-type-fieldset {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

.shop-storage-type-legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 0;
}

.shop-storage-type-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.04);
}

.shop-storage-type-tab {
  margin: 0;
  cursor: pointer;
}

.shop-storage-type-tab input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.shop-storage-type-tab-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 7px;
  background: transparent;
  text-align: center;
  transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.shop-storage-type-tab-body strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.shop-storage-type-tab-body small {
  display: none;
}

.shop-storage-type-tab.is-active .shop-storage-type-tab-body,
.shop-storage-type-tab input:checked + .shop-storage-type-tab-body {
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.shop-storage-type-tab.is-active .shop-storage-type-tab-body strong,
.shop-storage-type-tab input:checked + .shop-storage-type-tab-body strong {
  color: var(--primary);
}

.settings-readonly-note {
  padding: 4px 0;
}

.settings-readonly-note p {
  margin: 0 0 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.settings-readonly-list {
  margin: 0 0 12px;
  padding-left: 18px;
  color: var(--text-secondary);
  line-height: 1.7;
}


.group-storage-section.storage-cloud-only .settings-form-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}

.group-storage-section.storage-cloud-only .field {
  margin-bottom: 0;
}

.group-storage-section.storage-cloud-only .field > span {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text-secondary);
}

.group-storage-section.storage-cloud-only .field input,
.group-storage-section.storage-cloud-only .field-prefix-input {
  font-size: 13px;
}

.group-storage-section.storage-cloud-only .field input {
  padding: 9px 12px;
  background: #fff;
}

.group-storage-section.storage-cloud-only .field-prefix-input {
  height: 40px;
  background: #fff;
}

.group-storage-section.storage-cloud-only .field-prefix {
  font-size: 13px;
  padding: 0 10px;
}

.storage-panels {
  margin-top: 8px;
}

.storage-panel {
  padding-top: 8px;
}

.storage-panel .settings-card-title {
  margin-bottom: 16px;
}

.storage-provider {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.storage-provider-active {
  background: #f8fbff;
  margin-left: -16px;
  margin-right: -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-radius: var(--radius-sm);
  border-top-color: transparent;
}

@media (max-width: 900px) {
  .storage-driver-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .settings-form-grid {
    grid-template-columns: 1fr;
  }
}

.toast-stack {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  color: #fff;
  background: #16a34a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-error {
  background: #dc2626;
}

.logo-upload {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 8px;
}

.logo-upload-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo-upload-btn {
  cursor: pointer;
}

.logo-preview {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.logo-preview img { width: 100%; height: 100%; object-fit: cover; }

.logo-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 12px;
  color: var(--text-secondary);
  background: #f8fafc;
}

.color-fields { display: grid; gap: 14px; }

.color-field span {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.color-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.color-input-row input[type="color"] {
  width: 44px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
}

.color-text {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: monospace;
}

.kb-list { margin-bottom: 8px; }

.kb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.kb-item:last-child { border-bottom: none; }

.kb-icon {
  width: 36px;
  height: 36px;
  background: #f3f4f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
}

.kb-name { font-size: 14px; font-weight: 500; }
.kb-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.sticky-preview { position: sticky; top: 140px; }

/* ===== 手机框 / H5 ===== */
.phone-frame {
  width: 280px;
  margin: 0 auto;
  background: #fff;
  border-radius: 32px;
  border: 4px solid #1a1d24;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 520px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.phone-frame-large {
  width: 375px;
  min-height: 680px;
  border-width: 5px;
  border-radius: 36px;
}

.phone-notch {
  height: 32px;
  background: #1a1d24;
  flex-shrink: 0;
  position: relative;
}

.phone-notch::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: 96px;
  height: 24px;
  background: #0d0f14;
  border-radius: 20px;
}

/* H5 对话页：头/底固定，中间滚动 */
html:has(body.chat-page),
body.chat-page {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f5f3f0;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: #fff;
  overflow: hidden;
}

.chat-shell .h5-header,
.chat-shell .h5-input-area {
  flex-shrink: 0;
  z-index: 2;
}

.chat-shell .h5-header {
  position: sticky;
  top: 0;
}

.chat-shell .h5-input-area {
  position: sticky;
  bottom: 0;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.chat-shell .h5-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.55) transparent;
}

.chat-shell .h5-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-shell .h5-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-shell .h5-messages::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.55);
  border-radius: 999px;
}

.chat-shell .h5-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.75);
}

.chat-shell .h5-messages::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.h5-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.h5-header.theme-midian { border-bottom-color: var(--border-soft); }

.h5-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.h5-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.h5-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

.h5-messages {
  flex: 1;
  padding: 18px 14px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 10%, rgba(var(--primary-rgb), 0.05) 0%, transparent 40%),
    linear-gradient(180deg, #faf9f7 0%, #f5f3f0 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-ai { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.user-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-grad-end, var(--primary-light)) 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.ai-bubble {
  background: #fff;
  color: var(--text);
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border-soft);
  word-break: break-word;
  line-height: 1.6;
}

.ai-bubble .md-h1,
.ai-bubble .md-h2,
.ai-bubble .md-h3 {
  font-weight: 700;
  color: var(--text);
  margin: 0.65em 0 0.35em;
  line-height: 1.35;
}

.ai-bubble .md-h1 { font-size: 1.12em; }
.ai-bubble .md-h2 { font-size: 1.06em; }
.ai-bubble .md-h3 { font-size: 1.02em; }

.ai-bubble .md-h1:first-child,
.ai-bubble .md-h2:first-child,
.ai-bubble .md-h3:first-child {
  margin-top: 0;
}

.ai-bubble .md-li {
  position: relative;
  padding-left: 0.2em;
  margin: 0.2em 0;
}

.ai-bubble .md-num {
  color: var(--text-secondary, #64748b);
  font-variant-numeric: tabular-nums;
}

.msg-time {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 4px;
  padding: 0 4px;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots i {
  width: 6px;
  height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  display: block;
  animation: blink 1.2s infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

.h5-input-area {
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding: 10px 12px 14px;
}

.h5-quick-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}

.h5-quick-chips::-webkit-scrollbar { display: none; }

.quick-chip {
  flex-shrink: 0;
  padding: 7px 15px;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--primary);
  background: #fff;
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: var(--transition);
}

.quick-chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.h5-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.h5-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  font-size: 14px;
  font-family: inherit;
  background: #fafbfc;
  transition: var(--transition);
}

.h5-input-row input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

/* 后台快捷按钮编辑 */
.quick-btn-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-btn-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 14px;
  background: var(--primary-soft);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  border-radius: 999px;
  font-size: 13px;
}

.quick-btn-tag button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.quick-btn-add {
  display: flex;
  gap: 8px;
}

.quick-btn-add input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.send-btn {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-grad-end, var(--primary-light)) 100%);
  color: #fff;
  border: none;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
  transition: var(--transition);
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.32);
}

/* H5 全屏展示 */
.h5-showcase {
  display: flex;
  gap: 56px;
  max-width: 960px;
  margin: 48px auto;
  padding: 0 24px;
  align-items: flex-start;
}

.showcase-note {
  flex: 1;
  padding-top: 48px;
}

.showcase-note h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.showcase-note p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.showcase-note ul {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 2;
  padding-left: 0;
  list-style: none;
}

.showcase-note ul li::before {
  content: "—";
  color: var(--primary);
  margin-right: 10px;
  font-weight: 600;
}

/* 主题：科技蓝 */
.theme-midian .user-bubble,
.theme-midian .send-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-grad-end, var(--primary-light)) 100%);
}
.theme-midian .quick-chip {
  color: var(--primary);
  border-color: rgba(var(--primary-rgb), 0.35);
}
.theme-midian .quick-chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.theme-midian .h5-input-row input:focus { border-color: var(--primary); }

@media (max-width: 1100px) {
  .form-grid { grid-template-columns: 1fr; }
  .preview-col { order: -1; }
  .sticky-preview { position: static; }
  .h5-showcase { flex-direction: column; align-items: center; }
}
