/* ==========================================================
   设计 token：统一在 :root 定义，页面与组件只引用变量，不写死颜色。
   色板来自审核控制台方案：冷灰绿底 + 深松石墨正文 + 绿色信号色。
   ========================================================== */
:root {
  --mist: #f2f5f4; /* 页面底色，偏冷灰绿，避开奶油色 */
  --paper: #ffffff; /* 面板、输入框 */
  --ink: #12302b; /* 正文与深色强调 */
  --ink-2: #4a625d; /* 次要文字 */
  --ink-3: #5b716c; /* 辅助说明，对比度不低于 4.5:1 */
  --rule: #d3dcd9; /* 分割线与边框 */
  --rule-soft: #e3eae8;
  --signal: #1fa463; /* 状态指示点、已送达 */
  --signal-strong: #13804b; /* 按钮底色，保证白字对比度 */
  --signal-soft: #e6f5ec;
  --mint: #dcf3e3; /* 出站消息气泡 */
  --amber: #c98a1b; /* 待处理 */
  --amber-ink: #8a5c0b;
  --amber-soft: #fbf0db;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --chat-bg: #e9efec;

  --radius-input: 6px;
  --radius-panel: 10px;
  --radius-bubble: 14px;

  --font-ui: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 224px;
  --focus-ring: 0 0 0 3px rgba(31, 164, 99, 0.35);
}

/* ---------- 基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--signal-strong);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-input);
}

.skip-link:focus {
  top: 12px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---------- 布局：侧边导航 + 主区 ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 16px;
  border-right: 1px solid var(--rule);
  background: var(--mist);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: inset 0 0 0 5px var(--mist);
}

.brand-name {
  font-weight: 650;
  font-size: 15px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-3);
}

.nav-toggle {
  display: none;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-input);
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link:hover {
  color: var(--ink);
  background: rgba(18, 48, 43, 0.05);
}

.nav-link[aria-current="page"] {
  color: var(--ink);
  background: var(--paper);
  box-shadow: inset 2px 0 0 var(--signal);
}

.sidebar-foot {
  margin-top: auto;
  padding: 0 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 56px;
  padding: 0 32px;
  border-bottom: 1px solid var(--rule);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
}

.dot-ok {
  background: var(--signal);
}

.dot-pending {
  background: var(--amber);
}

.view {
  width: 100%;
  max-width: 1180px;
  padding: 32px;
  outline: none;
}

/* ---------- 页头与分区 ---------- */
.page-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 28px;
}

.page-title {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.lede {
  max-width: 64ch;
  color: var(--ink-2);
}

.perm {
  display: inline-block;
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--paper);
  border: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}

.section {
  margin-top: 36px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.section-title {
  font-size: 17px;
  font-weight: 600;
}

.muted {
  color: var(--ink-3);
  font-size: 13px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

/* 定义列表：用于连接信息，靠留白与分割线区分，不做卡片 */
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  margin: 0;
}

.facts dt,
.facts dd {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule-soft);
  margin: 0;
}

.facts dt {
  padding-right: 32px;
  color: var(--ink-3);
  font-size: 14px;
}

.facts dd {
  font-size: 14px;
  word-break: break-all;
}

/* 说明性引用：仅用左侧色条，不做通用卡片 */
.note {
  padding: 14px 16px;
  border-left: 3px solid var(--signal);
  background: var(--paper);
  border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
  color: var(--ink-2);
  font-size: 14px;
}

.note strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-panel);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule-soft);
}

.table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  background: #f8fafa;
}

.table tr:last-child td {
  border-bottom: none;
}

.table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 时间、数值列不换行，避免表格被挤成多行 */
.table td.nowrap {
  white-space: nowrap;
}

.narrow {
  max-width: 640px;
}

/* 登录页：内容居中，宽度沿用 .narrow 的版心 */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

/* 状态标签：颜色之外还有文字，满足非颜色依赖 */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--rule-soft);
  color: var(--ink-2);
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-ok {
  background: var(--signal-soft);
  color: var(--signal-strong);
}

.pill-pending {
  background: var(--amber-soft);
  color: var(--amber-ink);
}

.pill-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- 表单 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.hint {
  font-size: 12px;
  color: var(--ink-3);
}

.field-error {
  font-size: 12px;
  color: var(--danger);
  min-height: 0;
}

.input,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-input);
  background: var(--paper);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.input:hover,
.textarea:hover {
  border-color: #b4c3bf;
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--signal-strong);
  box-shadow: var(--focus-ring);
}

.field[data-invalid="true"] .input,
.field[data-invalid="true"] .textarea {
  border-color: var(--danger);
}

.field[data-invalid="true"] .input:focus,
.field[data-invalid="true"] .textarea:focus {
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.18);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 16px;
}

.form-grid .span-2 {
  grid-column: span 2;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-input);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--signal-strong);
  color: #ffffff;
}

.btn-primary:hover {
  background: #0f6a3e;
}

.btn-secondary {
  background: var(--paper);
  border-color: var(--rule);
  color: var(--ink);
}

.btn-secondary:hover {
  border-color: #b4c3bf;
  background: #f8fafa;
}

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
  padding: 0 10px;
}

.btn-quiet:hover {
  color: var(--ink);
  background: rgba(18, 48, 43, 0.06);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

/* 分段切换（消息类型等），用于替代原生 radio */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-input);
  background: var(--rule-soft);
  align-self: flex-start;
}

.segmented button {
  min-height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.segmented button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(18, 48, 43, 0.12);
}

/* 窗口关闭时的自由消息类型：不可点击，视觉上与 .btn:disabled 保持一致 */
.segmented button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 开关：替代原生 checkbox，role=switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: #b4c3bf;
  transition: background-color 0.18s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.18s ease;
}

.switch[aria-checked="true"] {
  background: var(--signal-strong);
}

.switch[aria-checked="true"]::after {
  transform: translateX(18px);
}

/* 自定义下拉：替代原生 select */
.select {
  position: relative;
  min-width: 0;
}

.select-trigger {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-input);
  background: var(--paper);
  text-align: left;
  font-size: 15px;
}

.select-trigger:hover {
  border-color: #b4c3bf;
}

.select-trigger[aria-expanded="true"] {
  border-color: var(--signal-strong);
  box-shadow: var(--focus-ring);
}

.select-trigger::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg) translate(-2px, -2px);
}

.select-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-panel);
  box-shadow: 0 12px 28px rgba(18, 48, 43, 0.12);
}

.select-option {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  outline: none;
}

.select-option:hover,
.select-option:focus {
  background: #f2f5f4;
}

.select-option[aria-selected="true"] {
  color: var(--signal-strong);
  font-weight: 600;
}

/* 文件选择：自定义按钮 + 隐藏的 input[type=file] */
.file-drop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px dashed #a9bab5;
  border-radius: var(--radius-panel);
  background: #fbfcfc;
  font-size: 14px;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- 手机预览：整个控制台唯一的视觉记忆点 ---------- */
.phone-stage {
  display: flex;
  justify-content: center;
}

.phone {
  width: 300px;
  padding: 10px;
  border-radius: 38px;
  background: var(--ink);
  box-shadow: 0 24px 48px rgba(18, 48, 43, 0.22);
}

.phone-screen {
  display: flex;
  flex-direction: column;
  height: 560px;
  border-radius: 29px;
  overflow: hidden;
  background: var(--chat-bg);
}

.phone-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-soft);
}

.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--mint);
  color: var(--signal-strong);
  font-weight: 700;
  font-size: 13px;
}

.phone-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

.phone-sub {
  font-size: 12px;
  color: var(--ink-3);
}

.phone-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px;
  overflow-y: auto;
}

.phone-body .day {
  align-self: center;
  margin: 4px 0;
  padding: 2px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  color: var(--ink-3);
}

.bubble {
  max-width: 84%;
  padding: 8px 10px 6px;
  border-radius: var(--radius-bubble);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(18, 48, 43, 0.06);
}

.bubble-out {
  align-self: flex-end;
  background: var(--mint);
  border-bottom-right-radius: 4px;
}

.bubble-in {
  align-self: flex-start;
  background: var(--paper);
  border-bottom-left-radius: 4px;
}

/* 发送方标签：入站显示客户号码，出站显示商户名，颜色跟随气泡方向 */
.bubble-sender {
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 600;
}

.bubble-sender-in {
  color: var(--ink-2);
}

.bubble-sender-out {
  color: var(--signal-strong);
}

.bubble-draft {
  opacity: 0.55;
  box-shadow: none;
  border: 1px dashed #8fa39e;
}

.bubble-meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-3);
}

.bubble-template .bubble-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.bubble-template .bubble-foot {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-3);
}

.bubble-buttons {
  margin: 8px -10px -6px;
  border-top: 1px solid var(--rule-soft);
}

.bubble-buttons span {
  display: block;
  padding: 7px 10px;
  text-align: center;
  color: #1668a8;
  font-size: 13px;
  font-weight: 600;
  border-top: 1px solid var(--rule-soft);
}

.bubble-buttons span:first-child {
  border-top: none;
}

.bubble-media {
  margin: -4px -6px 4px;
  height: 110px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(18, 48, 43, 0.12) 46% 54%, transparent 54%),
    #cfdcd8;
}

/* ---------- 消息页工作台：会话列表 | 手机预览 | 发送表单 ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* 1280px 以上三栏并排；更窄时堆叠，保证发送表单有足够宽度 */
@media (min-width: 1280px) {
  .workspace {
    grid-template-columns: 248px 300px minmax(0, 1fr);
    gap: 24px;
  }
}

.ws-col {
  min-width: 0;
}

.ws-hint {
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--ink-3);
}

/* 会话列表容器：滚动放在外层，轮询每 2 秒重绘列表时滚动位置不会丢失 */
.conv-scroll {
  max-height: 580px; /* 与手机预览的高度对齐 */
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-panel);
}

.conv-list {
  margin: 0;
  padding: 4px;
  list-style: none;
}

.conv-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-input);
  background: transparent;
  text-align: left;
  color: var(--ink);
}

.conv-item:hover {
  background: var(--mist);
}

/* 当前预览的会话：浅绿底 + 左侧色条，与导航的当前页样式一致 */
.conv-item[aria-pressed="true"] {
  background: var(--signal-soft);
  box-shadow: inset 2px 0 0 var(--signal-strong);
}

.conv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.conv-peer {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.conv-time {
  flex: none;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

.conv-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--ink-2);
}

.conv-foot {
  display: flex;
}

/* 模板预览与消息预览复用同一气泡 */
.preview-caption {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}

/* ---------- 代码块：JSON payload 与 ID 使用等宽字体 ---------- */
.code {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-input);
  background: #f8fafa;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: pre;
}

/* ---------- 图表 ---------- */
.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart .grid-line {
  stroke: var(--rule-soft);
  stroke-width: 1;
}

.chart .axis-text {
  fill: var(--ink-3);
  font-size: 11px;
  font-family: var(--font-ui);
}

.chart .bar-sent {
  fill: #9fd8b8;
}

.chart .bar-delivered {
  fill: var(--signal-strong);
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.summary {
  display: grid;
  /* 指标数量可变（当前为 3 项），按可用宽度自动分列 */
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.summary > div {
  padding: 16px 16px 16px 0;
}

.summary > div + div {
  padding-left: 16px;
  border-left: 1px solid var(--rule-soft);
}

.summary dt {
  font-size: 13px;
  color: var(--ink-3);
}

.summary dd {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Webhook 事件流 ---------- */
.event-type {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-2);
}

.fields-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fields-list li {
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* ---------- 弹窗与提示 ---------- */
.modal {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: none;
  border-radius: var(--radius-panel);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(18, 48, 43, 0.2);
}

.modal::backdrop {
  background: rgba(18, 48, 43, 0.32);
}

.modal-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 22px 18px;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}

.toast {
  max-width: 360px;
  padding: 10px 14px;
  border-radius: var(--radius-input);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  box-shadow: 0 8px 20px rgba(18, 48, 43, 0.2);
  animation: toast-in 0.18s ease-out;
}

.toast-error {
  background: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 工具类 ---------- */
.row-end {
  justify-content: flex-end;
}

.section-gap {
  margin-top: 32px;
}

.gap-top {
  margin-top: 16px;
}

.gap-top-lg {
  margin-top: 24px;
}

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--ink-2);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.w-select-sm {
  width: 180px;
  max-width: 100%;
}

.w-select-md {
  width: 300px;
  max-width: 60vw;
}

.legend .sw-sent {
  background: #9fd8b8;
}

.legend .sw-delivered {
  background: var(--signal-strong);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 14px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .phone-stage {
    justify-content: flex-start;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary > div:nth-child(3) {
    padding-left: 0;
    border-left: none;
  }

  .summary > div:nth-child(n + 3) {
    border-top: 1px solid var(--rule-soft);
  }
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }

  .brand-sub {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
    margin-left: auto;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-input);
    background: var(--paper);
    font-size: 13px;
    font-weight: 600;
  }

  .nav {
    display: none;
    width: 100%;
    padding-bottom: 8px;
  }

  .nav.is-open {
    display: flex;
  }

  .sidebar-foot {
    display: none;
  }

  .topbar {
    padding: 0 16px;
  }

  .view {
    padding: 24px 16px 48px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid .span-2 {
    grid-column: span 1;
  }

  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-title {
    font-size: 24px;
  }
}

@media (max-width: 520px) {
  .summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary > div,
  .summary > div + div {
    padding: 12px 0;
    border-left: none;
  }

  .summary > div + div,
  .summary > div:nth-child(n + 2) {
    border-top: 1px solid var(--rule-soft);
  }

  .facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .facts dt {
    padding-bottom: 0;
    border-bottom: none;
  }

  .facts dd {
    padding-top: 2px;
  }
}

/* 减少动态效果：尊重系统设置 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
