/* =============================================================================
   Waho Support Center · Design system (V7)
   - 设计令牌 / 布局壳（侧边栏 + 顶栏）/ 通用组件 / 收件箱与设备页
   - 页面专用的旧样式在 legacy.css（内部聊天、会议室等）
   ============================================================================= */

:root {
  --font-sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-soft: #dbeafe;
  --primary-ink: #1e3a8a;
  --wa: #16a34a;
  --wa-600: #15803d;
  --wa-soft: #dcfce7;
  --wa-bubble: #e7ffdb;
  --success: #059669;
  --success-soft: #d1fae5;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0284c7;
  --info-soft: #e0f2fe;

  --sidebar-bg: #0f172a;
  --sidebar-bg-2: #111c33;
  --sidebar-text: rgba(255, 255, 255, 0.72);
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 74px;
  --topbar-h: 60px;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.18);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.18);

  /* 兼容旧模板里引用的变量名 */
  --surface-alt: var(--surface-2);
  --warning-soft: #fef3c7;
  --danger-soft: #fee2e2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}
body[dir="rtl"] { font-family: "Noto Naskh Arabic", "Segoe UI", Tahoma, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
img, svg, video { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: 0.98rem; }
p { margin: 0 0 0.6em; }
p:last-child { margin-bottom: 0; }
small { font-size: 0.86em; }
code, pre { font-family: var(--font-mono); font-size: 0.9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
::selection { background: var(--primary-soft); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.ico { width: 18px; height: 18px; flex: 0 0 auto; vertical-align: -0.2em; }
.ico--sm { width: 14px; height: 14px; }
.ico--lg { width: 22px; height: 22px; }
.ico--xl { width: 28px; height: 28px; }

.container { width: min(1180px, calc(100vw - 32px)); margin: 0 auto; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-right { text-align: end; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =============================================================================
   Shell：侧边栏 + 顶栏
   ============================================================================= */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width 0.18s ease, transform 0.2s ease;
}
.sidebar__brand { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px; }
.sidebar__close { display: none; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.brand__mark {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 6px 14px rgba(22, 163, 74, 0.35);
}
.brand__icon { width: 22px; height: 22px; }
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__name { font-weight: 800; font-size: 0.98rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__sub { font-size: 0.74rem; color: rgba(255, 255, 255, 0.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand--light .brand__name { color: var(--text); }
.brand--light .brand__sub { color: var(--muted); }

.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: 4px 10px 10px; scrollbar-width: thin; }
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 6px; }
.nav-group { margin-top: 10px; }
.nav-group__title {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.38); padding: 8px 12px 4px; white-space: nowrap; overflow: hidden;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; margin: 2px 0;
  color: var(--sidebar-text); font-size: 0.92rem; font-weight: 500;
  width: 100%; border: 0; background: transparent; cursor: pointer; text-align: start;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.is-active { background: rgba(37, 99, 235, 0.32); color: #fff; box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.35); }
.nav-item__icon { width: 19px; height: 19px; opacity: 0.85; }
.nav-item.is-active .nav-item__icon { opacity: 1; }
.nav-item__label { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item__badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 0.72rem; font-weight: 700;
  display: inline-grid; place-items: center;
}
.sidebar__footer { padding: 8px 10px 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); }

.shell__main { flex: 1 1 auto; min-width: 0; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; transition: margin 0.18s ease; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__title { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .topbar__menu { display: none; }
.page { padding: 22px 22px 48px; flex: 1 1 auto; min-width: 0; }
.page--fluid { padding: 16px; }
.page--flush { padding: 0; }

/* 折叠侧边栏 */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .shell__main { margin-inline-start: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand__text,
body.sidebar-collapsed .nav-item__label,
body.sidebar-collapsed .nav-group__title { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 10px; }
body.sidebar-collapsed .nav-item__badge { position: absolute; transform: translate(14px, -12px); }
body.sidebar-collapsed .nav-item { position: relative; }
body.sidebar-collapsed .sidebar__brand { justify-content: center; padding-inline: 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 38px; height: 38px; padding: 0 10px;
  border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--text { font-weight: 600; font-size: 0.9rem; }
.icon-btn--light { color: var(--text-2); }
.icon-btn__badge {
  position: absolute; top: 4px; inset-inline-end: 4px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 0.68rem; font-weight: 700;
  display: none; place-items: center;
}
.icon-btn.has-badge .icon-btn__badge { display: inline-grid; }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-3); display: inline-grid; place-items: center; font-weight: 700; color: var(--primary-ink); flex: 0 0 auto; }
.avatar--sm { width: 32px; height: 32px; font-size: 0.85rem; }
.avatar--lg { width: 56px; height: 56px; font-size: 1.2rem; }
.avatar--initials { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.avatar--wa { background: var(--wa-soft); color: var(--wa-600); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; list-style: none; }
.user-chip::-webkit-details-marker { display: none; }
.user-chip:hover { background: var(--surface-3); }
.user-chip__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.user-chip__name { font-weight: 700; font-size: 0.88rem; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.user-chip__role { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

/* 下拉菜单（details 实现，无需 JS） */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown__menu {
  position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 60;
  min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.dropdown__menu--end { inset-inline-start: auto; inset-inline-end: 0; }
.dropdown__menu--grid { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 2px; min-width: 300px; max-height: 60vh; overflow-y: auto; }
.dropdown__item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; font-size: 0.9rem; color: var(--text-2); white-space: nowrap; }
.dropdown__item:hover { background: var(--surface-3); color: var(--text); }
.dropdown__item.is-active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.dropdown__item--danger { color: var(--danger); }
.dropdown__divider { height: 1px; background: var(--line); margin: 6px 4px; }
.lang-menu__current { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 移动端 */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 35; }
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); width: min(300px, 86vw); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .shell__main, body.sidebar-collapsed .shell__main { margin-inline-start: 0; }
  body.sidebar-collapsed .sidebar { width: min(300px, 86vw); }
  body.sidebar-collapsed .brand__text, body.sidebar-collapsed .nav-item__label, body.sidebar-collapsed .nav-group__title { display: initial; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 9px 12px; }
  body.sidebar-collapsed .nav-item__badge { position: static; transform: none; }
  .topbar .topbar__menu { display: inline-flex; }
  .sidebar__close { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, 0.08); color: #fff; cursor: pointer; }
  #sidebarCollapse { display: none; }
  .topbar { padding: 0 12px; }
  .page { padding: 14px 12px 40px; }
  .user-chip__text { display: none; }
  .lang-menu__current { display: none; }
  .dropdown__menu--grid { min-width: 260px; }
}

/* =============================================================================
   前台壳
   ============================================================================= */
.public-topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.public-topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding: 8px 0; }
.public-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.public-nav__link { padding: 8px 12px; border-radius: 10px; font-weight: 600; color: var(--text-2); font-size: 0.92rem; }
.public-nav__link:hover { background: var(--surface-3); color: var(--text); }
.public-nav__link.is-active { background: var(--primary-soft); color: var(--primary-ink); }
.public-main { padding: 28px 0 56px; min-height: calc(100vh - 140px); }
.public-footer { padding: 20px 0 32px; color: var(--muted-2); font-size: 0.82rem; text-align: center; }
.main-container { padding: 28px 0 56px; }

/* =============================================================================
   通用组件
   ============================================================================= */

/* 页头 */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-header h1 { font-size: 1.4rem; }
.page-header__intro { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-header__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 卡片 / 面板 */
.card, .panel, .detail-card, .hero-card, .login-card, .success-card, .settings-card, .form-section-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card, .panel, .detail-card, .hero-card, .success-card, .settings-card, .form-section-card { padding: 20px; margin-bottom: 18px; }
.card--flush, .panel--flush { padding: 0; }
.card--soft, .panel--soft { background: var(--surface-2); box-shadow: none; }
.detail-card--plain { box-shadow: none; }
.card__header, .panel__head, .section-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel__head > div:first-child, .card__header > div:first-child { min-width: 0; }
.panel__head h1, .panel__head h2, .panel__head h3, .card__header h2, .section-head h1, .section-head h2 { margin: 0; }
.panel__head .muted, .card__header .muted { margin-top: 3px; }
.panel__head--stacked { flex-direction: column; align-items: stretch; }
.card__body { padding: 0; }
.card__footer { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.section-block { margin-top: 28px; }
.admin-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.admin-panels--wide { grid-template-columns: 1fr; }
.admin-panels .panel { margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.two-col--side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 900px) { .two-col, .two-col--side { grid-template-columns: 1fr; } }

/* 统计卡 */
.admin-stats, .stat-grid, .desk-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 4px 0 18px; }
.stat-card, .desk-kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; min-height: 84px; display: flex; flex-direction: column; justify-content: center; gap: 4px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card--clickable { cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease; }
.stat-card--clickable:hover { transform: translateY(-2px); border-color: var(--primary); }
.stat-card__label, .desk-kpi span { font-size: 0.8rem; color: var(--muted); font-weight: 600; letter-spacing: 0.01em; }
.stat-card__value, .desk-kpi strong { font-size: 1.6rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.stat-card__hint { font-size: 0.78rem; color: var(--muted-2); }
.stat-card--accent { border-color: transparent; background: linear-gradient(135deg, #1e3a8a, #2563eb); color: #fff; }
.stat-card--accent .stat-card__label, .stat-card--accent .stat-card__hint { color: rgba(255, 255, 255, 0.75); }
.stat-card--wa { border-color: #bbf7d0; background: linear-gradient(135deg, #f0fdf4, #dcfce7); }
.stat-card--warn { border-color: #fde68a; background: #fffbeb; }
.stat-card--danger { border-color: #fecaca; background: #fef2f2; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; padding: 9px 14px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap; line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3); }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text-2); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger, .btn-secondary.btn-danger { color: var(--danger); border-color: #fca5a5; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-wa, .btn-success { background: var(--wa); color: #fff; box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3); }
.btn-wa:hover, .btn-success:hover { background: var(--wa-600); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-link { padding: 0; color: var(--primary); background: none; border: none; font-weight: 600; }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; border-radius: 8px; }
.btn-lg { padding: 12px 20px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; min-width: 36px; }
.action-row, .card-actions, .table-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.action-row { margin-top: 16px; }
.table-actions--stacked { flex-direction: column; align-items: stretch; }

/* 表单 */
.label { display: block; font-size: 0.84rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.label--inline { display: inline; margin: 0; }
.input, .textarea, select.input, .select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
  outline: none;
  min-height: 40px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select.input, .select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-inline-end: 32px; }
[dir="rtl"] select.input, [dir="rtl"] .select { background-position: left 10px center; }
.input:focus, .textarea:focus, select.input:focus, .select:focus { border-color: var(--primary); box-shadow: var(--ring); }
.input[readonly], .textarea[readonly] { background: var(--surface-2); color: var(--text-2); }
.input--sm { padding: 6px 10px; min-height: 34px; font-size: 0.85rem; border-radius: 8px; }
.input--ghost { border-color: transparent; background: var(--surface-2); }
.input--ghost:focus { background: #fff; }
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.input[type="file"] { padding: 7px; }
.form-grid, .compact-form.form-grid, .filter-grid, .desk-filter-grid, .settings-inline-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px;
}
.filter-grid, .desk-filter-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-item--full, .form-grid .action-row, .form-grid > .checkbox-row { grid-column: 1 / -1; }
.form-grid .action-row { margin-top: 4px; }
.form-grid .muted, .help-text { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.form-warning { font-size: 0.82rem; color: var(--warning); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text-2); cursor: pointer; min-height: 40px; }
.checkbox-row--compact { min-height: auto; }
.checkbox-row input[type="checkbox"], .checkbox-row input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline-form--tight { gap: 4px; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row .input { flex: 1 1 auto; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
@media (max-width: 720px) { .form-grid, .compact-form.form-grid, .settings-inline-grid, .form-grid--3 { grid-template-columns: 1fr; } }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 0.9rem; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { width: 40px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background 0.15s ease; flex: 0 0 auto; }
.switch__track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s ease; box-shadow: var(--shadow-sm); }
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .switch__track::after { transform: translateX(-18px); }

/* 表格 */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.table-wrap--card { box-shadow: var(--shadow-sm); }
.data-table, .table, .professional-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .table th, .professional-table th {
  text-align: start; font-weight: 700; font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table td, .table td, .professional-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td, .table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover, .table tbody tr:hover { background: #f8fafc; }
.data-table td a:not(.btn), .table td a:not(.btn) { color: var(--primary); font-weight: 600; }
.data-table .input, .data-table select.input { min-height: 34px; padding: 6px 10px; font-size: 0.86rem; }
.table-primary { font-weight: 600; }
.table-secondary { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.row-updated-flash { animation: rowFlash 1.6s ease; }
@keyframes rowFlash { 0% { background: #dbeafe; } 100% { background: transparent; } }
.table-empty { padding: 28px; text-align: center; color: var(--muted); }

/* 徽章 / 状态 */
.badge, .status-pill, .tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700; line-height: 1.4;
  background: var(--primary-soft); color: var(--primary-ink); white-space: nowrap;
}
.tag { background: var(--surface-3); color: var(--text-2); font-weight: 600; }
.badge-warning, .badge--warning, .status-pill--warning { background: var(--warning-soft); color: #92400e; }
.badge-success, .badge--success, .status-pill--success { background: var(--success-soft); color: #065f46; }
.badge-danger, .badge--danger, .status-pill--danger { background: var(--danger-soft); color: #991b1b; }
.badge-info, .badge--info { background: var(--info-soft); color: #075985; }
.badge-muted, .badge--muted, .status-pill--muted { background: var(--surface-3); color: var(--muted); }
.badge-wa, .badge--wa { background: var(--wa-soft); color: var(--wa-600); }
.status-pill--new, .badge--new_not_contacted { background: var(--surface-3); color: var(--text-2); }
.status-pill--dialed { background: var(--info-soft); color: #075985; }
.status-pill--reached, .status-pill--reached-flag, .badge--contacted_not_opened { background: var(--warning-soft); color: #92400e; }
.status-pill--follow_up { background: #ede9fe; color: #5b21b6; }
.status-pill--invalid, .badge--invalid, .status-pill--not-reached { background: var(--danger-soft); color: #991b1b; }
.status-pill--converted, .badge--contacted_opened { background: var(--success-soft); color: #065f46; }
.status-pill--info, .status-pill--submitted, .status-pill--in_progress { background: var(--info-soft); color: #075985; }
.status-pill--done, .status-pill--resolved { background: var(--success-soft); color: #065f46; }
.status-pill--pending_customer { background: var(--warning-soft); color: #92400e; }
.status-pill--closed { background: var(--surface-3); color: var(--muted); }
.badge--high, .badge--urgent { background: var(--danger-soft); color: #991b1b; }
.badge--normal { background: var(--surface-3); color: var(--text-2); }
.badge--low { background: var(--info-soft); color: #075985; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex: 0 0 auto; }
.dot--online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }
.dot--warn { background: #f59e0b; }
.dot--off { background: #ef4444; }
.dot--idle { background: #94a3b8; }

/* 提示 / 通知 */
.notice {
  padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); font-size: 0.9rem;
}
.notice.success { background: var(--success-soft); border-color: #a7f3d0; color: #065f46; }
.notice.error { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.notice.warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.notice.info { background: var(--info-soft); border-color: #bae6fd; color: #075985; }
.toast-stack { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  min-width: 220px; max-width: 360px; padding: 11px 14px; border-radius: 10px;
  background: #0f172a; color: #fff; font-size: 0.88rem; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: auto;
}
.toast.is-visible { opacity: 1; transform: none; }
.toast--success { background: #065f46; }
.toast--error { background: #991b1b; }
.toast--warning { background: #92400e; }

/* 空状态 */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state__icon { width: 44px; height: 44px; margin: 0 auto 10px; color: var(--muted-2); }
.empty-state h3 { color: var(--text-2); margin-bottom: 4px; }

/* 详情 */
.detail-grid, .detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 18px; margin: 0; }
.detail-list dt, .detail-item__label { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.detail-list dd, .detail-item__value { margin: 2px 0 0; font-size: 0.94rem; word-break: break-word; }
.detail-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.detail-box h3, .detail-box h4 { margin-bottom: 8px; }
.rich-answer { line-height: 1.75; white-space: pre-wrap; word-break: break-word; }

/* 时间线 */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline-item { position: relative; padding-inline-start: 22px; }
.timeline-item::before { content: ""; position: absolute; inset-inline-start: 4px; top: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.timeline-item::after { content: ""; position: absolute; inset-inline-start: 8px; top: 20px; bottom: -12px; width: 1px; background: var(--line); }
.timeline-item:last-child::after { display: none; }
.timeline-item__meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 2px; }
.timeline-item__body { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; white-space: pre-wrap; }
.timeline-item--internal .timeline-item__body { background: var(--warning-soft); border-color: #fde68a; }
.timeline-item--customer::before { background: var(--wa); }

/* 折叠面板 */
.collapsible-panel .collapsible-panel__body { margin-top: 6px; }
.collapsible-panel.is-collapsed .collapsible-panel__body { display: none; }
.collapsible-panel.is-collapsed .panel__head, .collapsible-panel.is-collapsed .card__header { margin-bottom: 0; }
.collapsible-panel__hint { display: none; }
.collapsible-panel.is-collapsed .collapsible-panel__hint { display: block; }

/* 标签页 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* 模态框 */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, 0.5); }
.modal.is-open { display: flex; }
.modal__dialog { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: modalIn 0.18s ease; }
.modal__dialog--lg { width: min(820px, 100%); }
.modal__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal__body { padding: 20px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* 键值提示条 */
.kv { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.86rem; color: var(--text-2); }
.kv span { color: var(--muted); }

/* 登录 */
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.login-card { width: min(440px, 100%); padding: 32px 30px; margin: 20px auto; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login-card .form-grid { grid-template-columns: 1fr; margin-top: 18px; }
.login-card .btn { width: 100%; }

/* 前台首页 */
.hero-card { padding: 34px 32px; margin-bottom: 24px; background: linear-gradient(135deg, #0f172a, #1e3a8a 60%, #2563eb); color: #fff; border: 0; }
.hero-card h1 { font-size: 1.7rem; margin-bottom: 8px; }
.hero-card .muted { color: rgba(255, 255, 255, 0.75); }
.hero-card .input { border-color: transparent; }
.search-form .search-grid { display: grid; grid-template-columns: 2fr 1fr auto; gap: 12px; align-items: end; margin-top: 18px; }
.search-form .label { color: rgba(255, 255, 255, 0.85); }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.category-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); transition: transform 0.15s ease, border-color 0.15s ease; }
.category-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.category-card__title { font-weight: 800; margin-bottom: 6px; }
.category-card__desc { color: var(--muted); line-height: 1.55; font-size: 0.9rem; }
.faq-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.faq-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; }
.faq-card h3 { font-size: 1rem; line-height: 1.45; }
.answer-preview { color: var(--muted); line-height: 1.65; font-size: 0.9rem; }
.faq-meta, .ticket-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.success-card { text-align: center; padding: 40px 28px; }
.success-card h1 { margin-bottom: 8px; }
@media (max-width: 720px) { .search-form .search-grid { grid-template-columns: 1fr; } .hero-card { padding: 24px 20px; } }

/* 权限编辑器 */
.permission-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.permission-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface-2); }
.permission-card h3 { margin-bottom: 10px; font-size: 0.9rem; }
.permission-card .checkbox-row { min-height: 32px; }

/* 设置页 */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.settings-card { margin-bottom: 0; display: flex; flex-direction: column; gap: 12px; }
.settings-card h2 { font-size: 1rem; }

/* 分页 */
.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.pagination a, .pagination span { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 0.85rem; }
.pagination .is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 二维码 */
.qr-box { display: grid; place-items: center; gap: 10px; padding: 16px; background: #fff; border: 1px dashed var(--line-strong); border-radius: var(--radius); min-height: 280px; }
.qr-box img { width: 260px; height: 260px; image-rendering: pixelated; border-radius: 8px; }
.pairing-code { font-family: var(--font-mono); font-size: 2rem; letter-spacing: 0.16em; font-weight: 800; color: var(--primary-ink); padding: 12px 18px; background: var(--primary-soft); border-radius: 12px; }
.steps { margin: 0; padding-inline-start: 20px; color: var(--text-2); font-size: 0.9rem; line-height: 1.7; }

/* =============================================================================
   WhatsApp 账号 / 设备卡片
   ============================================================================= */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.device-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; position: relative; }
.device-card.is-online { border-color: #bbf7d0; }
.device-card.is-problem { border-color: #fecaca; }
.device-card__head { display: flex; align-items: flex-start; gap: 12px; }
.device-card__title { font-weight: 800; font-size: 1rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.device-card__phone { color: var(--muted); font-family: var(--font-mono); font-size: 0.85rem; }
.device-card__meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; font-size: 0.82rem; color: var(--text-2); }
.device-card__meta span { color: var(--muted); }
.device-card__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.device-card__unread { position: absolute; top: 14px; inset-inline-end: 14px; }
.conn-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.conn-pill--connected { background: var(--wa-soft); color: var(--wa-600); }
.conn-pill--connecting, .conn-pill--qr_pending, .conn-pill--pairing { background: var(--info-soft); color: #075985; }
.conn-pill--disconnected, .conn-pill--error { background: var(--warning-soft); color: #92400e; }
.conn-pill--logged_out, .conn-pill--banned { background: var(--danger-soft); color: #991b1b; }
.conn-pill--not_linked { background: var(--surface-3); color: var(--muted); }
.gateway-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); font-size: 0.86rem; margin-bottom: 16px; }
.gateway-bar.is-ok { background: var(--wa-soft); border-color: #bbf7d0; color: #14532d; }
.gateway-bar.is-bad { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }

/* =============================================================================
   WhatsApp 收件箱
   ============================================================================= */
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; height: calc(100vh - var(--topbar-h) - 32px); min-height: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.inbox--no-side { grid-template-columns: 320px minmax(0, 1fr); }
.inbox__list { display: flex; flex-direction: column; border-inline-end: 1px solid var(--line); min-height: 0; }
.inbox__list-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.inbox__list-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inbox__list-title h2 { font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.inbox__search { position: relative; }
.inbox__search .input { padding-inline-start: 34px; min-height: 36px; }
.inbox__search .ico { position: absolute; top: 50%; inset-inline-start: 10px; transform: translateY(-50%); color: var(--muted); }
.inbox__filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 0.78rem; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--line-strong); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip__count { background: rgba(0, 0, 0, 0.08); border-radius: 999px; padding: 0 6px; font-size: 0.72rem; }
.chip.is-active .chip__count { background: rgba(255, 255, 255, 0.25); }
.inbox__accounts { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.inbox__items { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.chat-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; transition: background 0.12s ease; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.is-active { background: var(--primary-soft); }
.chat-item__name { font-weight: 700; font-size: 0.92rem; display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-item__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item__preview { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.chat-item__preview .dir { color: var(--muted-2); }
.chat-item__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 0.72rem; color: var(--muted-2); white-space: nowrap; }
.chat-item__account { font-size: 0.7rem; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }
.unread-pill { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--wa); color: #fff; font-size: 0.72rem; font-weight: 700; display: inline-grid; place-items: center; }
.inbox__loadmore { padding: 10px; text-align: center; }

.inbox__chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #f0f2f5; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.chat-head__who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-head__name { font-weight: 800; font-size: 0.98rem; display: flex; align-items: center; gap: 6px; }
.chat-head__sub { font-size: 0.78rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.chat-head__actions { display: flex; gap: 4px; }
.chat-scroll { flex: 1 1 auto; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-height: 0; background-image: radial-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px); background-size: 18px 18px; }
.chat-day { align-self: center; font-size: 0.72rem; font-weight: 700; color: var(--muted); background: rgba(255, 255, 255, 0.85); padding: 3px 10px; border-radius: 999px; margin: 8px 0; box-shadow: var(--shadow-sm); }
.bubble { max-width: min(72%, 560px); padding: 8px 12px 6px; border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); position: relative; font-size: 0.92rem; line-height: 1.5; word-break: break-word; white-space: pre-wrap; align-self: flex-start; }
.bubble--out { align-self: flex-end; background: var(--wa-bubble); }
.bubble--history { opacity: 0.85; }
.bubble__quote { border-inline-start: 3px solid var(--wa); background: rgba(0, 0, 0, 0.04); border-radius: 6px; padding: 4px 8px; margin-bottom: 6px; font-size: 0.8rem; color: var(--text-2); }
.bubble__meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 4px; font-size: 0.68rem; color: var(--muted-2); }
.bubble__sender { font-size: 0.72rem; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.bubble__media img, .bubble__media video { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; margin-bottom: 4px; }
.bubble__media audio { width: 260px; max-width: 100%; display: block; margin-bottom: 4px; }
.bubble__file { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(0, 0, 0, 0.04); border-radius: 8px; font-weight: 600; color: var(--primary-ink); margin-bottom: 4px; }
.bubble__status--read { color: #2563eb; }
.bubble__status--failed { color: var(--danger); }
.bubble--system { align-self: center; background: var(--warning-soft); color: #92400e; font-size: 0.8rem; max-width: 80%; text-align: center; }
.chat-empty { flex: 1 1 auto; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.composer__tools { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; position: relative; }
.composer__row { display: flex; align-items: flex-end; gap: 8px; }
.composer__input { flex: 1 1 auto; min-height: 44px; max-height: 160px; resize: none; }
.composer__attach { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--line-strong); padding: 6px 10px; border-radius: 8px; }
.composer__attach img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.composer__quote { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.8rem; color: var(--text-2); background: var(--surface-2); border-inline-start: 3px solid var(--wa); padding: 6px 10px; border-radius: 6px; }
.composer__offline { background: var(--warning-soft); color: #92400e; padding: 8px 12px; border-radius: 8px; font-size: 0.84rem; }
.quick-pop { position: absolute; bottom: 100%; inset-inline-start: 0; z-index: 20; width: min(420px, 90vw); max-height: 300px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; }
.quick-pop__item { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 0.86rem; }
.quick-pop__item:hover { background: var(--surface-3); }
.quick-pop__item strong { display: block; font-size: 0.8rem; color: var(--text-2); }
.emoji-pop { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-pop button { border: 0; background: none; font-size: 1.3rem; padding: 4px; cursor: pointer; border-radius: 6px; }
.emoji-pop button:hover { background: var(--surface-3); }

.inbox__side { border-inline-start: 1px solid var(--line); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); min-height: 0; }
.side-block { display: flex; flex-direction: column; gap: 8px; }
.side-block h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.side-profile { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.side-profile .avatar { width: 60px; height: 60px; font-size: 1.3rem; }
.side-profile__name { font-weight: 800; font-size: 1rem; }
.side-profile__phone { font-family: var(--font-mono); color: var(--muted); font-size: 0.86rem; }
.side-list { display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; }
.side-list div { display: flex; justify-content: space-between; gap: 8px; }
.side-list span:first-child { color: var(--muted); }
.side-actions { display: flex; flex-direction: column; gap: 6px; }
.inbox__side-toggle { display: none; }
.inbox__mobile-back { display: none; }

@media (max-width: 1240px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox__side { position: absolute; inset-block: 0; inset-inline-end: 0; width: 320px; z-index: 5; box-shadow: var(--shadow-lg); transform: translateX(110%); transition: transform 0.2s ease; }
  [dir="rtl"] .inbox__side { transform: translateX(-110%); }
  .inbox.side-open .inbox__side { transform: none; }
  .inbox__side-toggle { display: inline-flex; }
  .inbox { position: relative; }
}
@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 20px); }
  .inbox__list, .inbox__chat { grid-column: 1; grid-row: 1; }
  .inbox__chat { display: none; }
  .inbox.chat-open .inbox__chat { display: flex; }
  .inbox.chat-open .inbox__list { display: none; }
  .inbox__mobile-back { display: inline-flex; }
  .bubble { max-width: 88%; }
}

/* =============================================================================
   打印 / 辅助
   ============================================================================= */
@media print {
  .sidebar, .topbar, .public-topbar, .toast-stack, .composer { display: none !important; }
  .shell__main { margin: 0 !important; }
  .page { padding: 0; }
}

/* v6.58 页面专用样式（legacy.css）用到的品牌令牌：映射到 V7 浅色主题，避免出现未定义变量导致透明/白字。 */
:root {
  --xh-app-bg: #f5f7fa;
  --xh-app-danger: #d92d20;
  --xh-app-line: #e5e6eb;
  --xh-app-muted: #646a73;
  --xh-app-primary: #2f6fed;
  --xh-app-radius: 8px;
  --xh-app-surface: #ffffff;
  --xh-app-surface-soft: #f7f8fa;
  --xh-app-text: #1f2329;
  --xh-chat-bg: radial-gradient(circle at 14% 2%, rgba(37, 99, 235, .08), transparent 22rem), linear-gradient(180deg, #edf5fb, #f4faf7);
  --xh-control-bg: linear-gradient(180deg, #fbfdff, #eef6fb);
  --xh-danger-bg: linear-gradient(180deg, #fb7185 0%, #ef4444 46%, #b91c1c 100%);
  --xh-danger-bg-hover: linear-gradient(180deg, #f43f5e 0%, #dc2626 48%, #991b1b 100%);
  --xh-danger-line: rgba(185, 28, 28, .94);
  --xh-danger-shadow: 0 14px 30px rgba(220, 38, 38, .24);
  --xh-danger-soft-bg: linear-gradient(180deg,
      color-mix(in srgb, var(--danger-soft, rgba(254, 226, 226, .9)) 84%, var(--surface) 16%),
      color-mix(in srgb, var(--surface) 82%, var(--danger-soft, rgba(254, 226, 226, .9)) 18%));
  --xh-enterprise-line: #e5e7eb;
  --xh-enterprise-radius: 10px;
  --xh-enterprise-shadow-pop: 0 12px 32px rgba(16, 24, 40, .14);
  --xh-enterprise-soft: #f7f9fc;
  --xh-enterprise-surface: #ffffff;
  --xh-menu-w: 184px;
  --xh-page-pad-x: 24px;
  --xh-soft-bg: linear-gradient(135deg, rgba(37, 99, 235, .055), transparent 42%), linear-gradient(180deg, #ffffff, #f1f8fb);
  --xh-surface-bg: linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(247, 252, 255, .92)), linear-gradient(135deg, rgba(37, 99, 235, .045), rgba(20, 184, 166, .035));
}
