/* ============================================================
   邮件运营控制台 — 设计系统（零依赖，单文件）
   默认浅色（柔和、清爽），深色主题一键切换（localStorage 记忆）。
   对比度：正文 ≥ 7:1，次要文本 ≥ 4.5:1，状态不只用颜色表达。
   ============================================================ */

[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --bg-soft: #fafbfc;
  --panel: #ffffff;
  --panel-2: #f4f6f8;
  --line: #e4e7ec;
  --line-strong: #cdd3dd;
  --fg: #18212c;
  --fg-dim: #424d5e;
  --muted: #626e80;
  --accent: #4859d7;
  --accent-strong: #3545b4;
  --accent-ink: #ffffff;
  --accent-soft: rgba(72, 89, 215, .08);
  --ok: #0c8f5b;
  --ok-soft: rgba(12, 143, 91, .11);
  --warn: #a9690a;
  --warn-soft: rgba(214, 144, 0, .07);
  --bad: #cf3d55;
  --bad-soft: rgba(207, 61, 85, .10);
  --info: #1f6fd0;
  --info-soft: rgba(31, 111, 208, .10);
  --radius: 8px;
  --radius-sm: 8px;
  --shadow-sm: none;
  --shadow: none;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
          "Microsoft YaHei", "Noto Sans CJK SC", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 208px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1119;
  --bg-soft: #121722;
  --panel: #171d29;
  --panel-2: #1b2230;
  --line: #26303f;
  --line-strong: #384456;
  --fg: #eef2f8;
  --fg-dim: #c2cbd9;
  --muted: #94a0b4;
  --accent: #6b9bff;
  --accent-strong: #8cb2ff;
  --accent-ink: #0a1224;
  --accent-soft: rgba(107, 155, 255, .14);
  --ok: #45d18b;
  --ok-soft: rgba(69, 209, 139, .12);
  --warn: #f5c451;
  --warn-soft: rgba(245, 196, 81, .12);
  --bad: #ff7a7a;
  --bad-soft: rgba(255, 122, 122, .12);
  --info: #7cc4ff;
  --info-soft: rgba(124, 196, 255, .12);
  --shadow-sm: none;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  color: var(--fg);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
}

::selection { background: var(--accent-soft); }

/* ---------- 骨架布局 ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100%; min-width: 0; }

.sidebar {
  position: sticky; top: 0; height: 100vh; min-width: 0; max-width: 100vw;
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; color: var(--accent);
  background: var(--accent-soft);
}
.brand-text { font-size: 15px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand-text em { font-style: normal; color: var(--muted); font-weight: 500; margin-left: 3px; font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 11px; border-radius: 8px;
  color: var(--fg-dim); text-decoration: none; font-size: 14px;
  border: 1px solid transparent;
  transition: background .14s ease, color .14s ease;
}
.nav-item:hover { background: var(--panel-2); color: var(--fg); }
.nav-item.on {
  background: var(--accent-soft); color: var(--accent-strong);
  border-color: transparent; font-weight: 650;
}
.nav-ico { width: 18px; height: 18px; flex: none; display: inline-grid; place-items: center; color: var(--muted); }
.nav-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.on .nav-ico { color: var(--accent); }
.nav-badge {
  margin-left: auto; min-width: 20px; text-align: center;
  background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 999px; font-size: 11px; line-height: 18px; padding: 0 6px; font-weight: 700;
}
.nav-badge.danger { background: var(--bad-soft); color: var(--bad); }

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 10px 6px 2px; border-top: 1px solid var(--line); }

.hb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-dim); }
.hb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.hb.ok .hb-dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.hb.warn .hb-dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.hb.bad .hb-dot { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.hb.bad .hb-text { color: var(--bad); font-weight: 650; }
.day-note { font-size: 11.5px; color: var(--muted); }

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

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.page-title { font-size: 17px; margin: 0; font-weight: 720; letter-spacing: .2px; }
.hb-inline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-dim); }
.hb-inline.bad { color: var(--bad); }

.main { padding: 28px 32px 60px; max-width: 1440px; width: 100%; outline: none; }
.main:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- 通用 ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }

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

.muted { color: var(--muted); }
.dim { color: var(--fg-dim); }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.right { margin-left: auto; }

a { color: var(--accent-strong); }
a:hover { text-decoration: none; }

h2 { font-size: 15px; margin: 0; font-weight: 700; }
h3 { font-size: 14px; margin: 0; font-weight: 700; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--panel); color: var(--fg);
  border-radius: var(--radius-sm); padding: 7px 13px; font-size: 13px; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.25; min-height: 36px;
  box-shadow: var(--shadow-sm); text-decoration: none;
  transition: border-color .14s ease, box-shadow .14s ease, transform .1s ease, background .14s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink); font-weight: 650;
  box-shadow: none;
}
.btn.primary:hover { color: var(--accent-ink); background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { background: var(--panel); border-color: rgba(207, 61, 85, .45); color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-dim); box-shadow: none; }
.btn.ghost:hover { background: var(--panel-2); color: var(--fg); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 6px 10px; }
.btn.link { border: none; background: none; color: var(--accent-strong); padding: 2px 4px; min-height: 0; box-shadow: none; }
.btn.link:hover { text-decoration: underline; }

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 卡片 / 面板 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.card.pad-sm { padding: 12px 14px; box-shadow: var(--shadow-sm); }
.card > .card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; min-width: 0; }
.grid.cards-4 { grid-template-columns: repeat(auto-fit, minmax(228px, 1fr)); }
.grid.cards-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cards-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.main-2 { grid-template-columns: 1.15fr .85fr; }
.grid.main-side { grid-template-columns: 1.4fr 1fr; }

.kpi .k { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.kpi .v {
  font-size: 27px; font-weight: 730; margin-top: 6px; letter-spacing: .2px;
  font-variant-numeric: tabular-nums;
}
.kpi .s { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.kpi.clickable { cursor: pointer; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.kpi.clickable:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: 0 10px 26px rgba(23, 35, 64, .10); }
.kpi.alert-on .v { color: var(--bad); }
.kpi.warn-on .v { color: var(--warn); }
.kpi.ok-on .v { color: var(--ok); }

/* 值班横幅 */
.hero {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0;
  border-radius: var(--radius); padding: 14px 18px;
  border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow);
}
.hero .hero-ico {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 19px;
}
.hero.ok { border-color: rgba(12, 143, 91, .3); background: linear-gradient(120deg, var(--ok-soft), var(--panel) 62%); }
.hero.ok .hero-ico { background: var(--ok-soft); color: var(--ok); }
.hero.warn { border-color: rgba(169, 105, 10, .32); background: linear-gradient(120deg, var(--warn-soft), var(--panel) 62%); }
.hero.warn .hero-ico { background: var(--warn-soft); color: var(--warn); }
.hero.bad { border-color: rgba(207, 61, 85, .34); background: linear-gradient(120deg, var(--bad-soft), var(--panel) 62%); }
.hero.bad .hero-ico { background: var(--bad-soft); color: var(--bad); }
.hero > div { min-width: 0; }
.hero .hero-title { font-size: 15px; font-weight: 700; }
.hero .hero-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- 状态 pill ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  border: 1px solid var(--line-strong); color: var(--fg-dim); background: var(--panel-2); white-space: nowrap;
}
.pill.active { color: var(--ok); border-color: rgba(12, 143, 91, .35); background: var(--ok-soft); }
.pill.warming { color: var(--info); border-color: rgba(31, 111, 208, .32); background: var(--info-soft); }
.pill.limited { color: var(--warn); border-color: rgba(169, 105, 10, .34); background: var(--warn-soft); }
.pill.dead { color: var(--bad); border-color: rgba(207, 61, 85, .34); background: var(--bad-soft); }
.pill.ok { color: var(--ok); border-color: rgba(12, 143, 91, .35); background: var(--ok-soft); }
.pill.warn { color: var(--warn); border-color: rgba(169, 105, 10, .34); background: var(--warn-soft); }
.pill.bad { color: var(--bad); border-color: rgba(207, 61, 85, .34); background: var(--bad-soft); }
.pill.info { color: var(--info); border-color: rgba(31, 111, 208, .32); background: var(--info-soft); }
.pill.plain { color: var(--muted); }

/* ---------- 进度条 ---------- */
.bar { height: 7px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; min-width: 64px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #6f9bff, var(--accent)); border-radius: 5px; }
.bar.warn > i { background: linear-gradient(90deg, #f0b95a, var(--warn)); }
.bar.bad > i { background: linear-gradient(90deg, #ef7f92, var(--bad)); }
.bar.ok > i { background: linear-gradient(90deg, #4fc593, var(--ok)); }
.bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 130px; max-width: 240px; }
.bar-wrap .bar { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  overflow: auto; box-shadow: var(--shadow);
}
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
table.data thead th {
  color: var(--muted); font-weight: 650; font-size: 12px; letter-spacing: .2px;
  white-space: nowrap; background: var(--panel-2); position: sticky; top: 0; z-index: 2;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: var(--panel-2); }
table.data tr.clickable { cursor: pointer; }
table.data td.actions { white-space: nowrap; }
table.data .cell-main { font-weight: 650; }
table.data .cell-sub { color: var(--muted); font-size: 12px; }
.col-check { width: 34px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; }
.field > label { font-size: 12.5px; color: var(--fg-dim); font-weight: 650; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--bad); font-weight: 650; }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], input[type="file"], select, textarea {
  width: 100%; background: var(--panel); color: var(--fg);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 11px; font: inherit; font-size: 13px; min-height: 38px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
input[type="date"] { width: auto; min-width: 164px; min-height: 40px; font-variant-numeric: tabular-nums; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .65; }
input[type="file"] { padding: 6px; font-size: 12px; }
input[type="file"]::file-selector-button {
  border: 0; border-right: 1px solid var(--line); margin-right: 12px; padding: 4px 12px;
  background: var(--panel-2); color: var(--fg-dim); border-radius: 4px; font: inherit; cursor: pointer;
}
textarea { resize: vertical; min-height: 96px; font-family: inherit; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 78%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong)); }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible,
.nav-item:focus-visible, summary:focus-visible, input[type="checkbox"]:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.nav-item:focus-visible, .btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-row label { cursor: pointer; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; cursor: pointer; }
.check input { flex: none; margin: 3px 0 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin: 0; background: var(--panel-2); }
legend { color: var(--fg-dim); font-size: 12.5px; font-weight: 700; padding: 0 6px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--fg-dim);
  padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.search { flex: 1 1 240px; max-width: 420px; min-width: 0; position: relative; }
.search input { padding-left: 32px; border-radius: 999px; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 8px; color: var(--muted); font-size: 15px; pointer-events: none; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--fg-dim);
  border-radius: 999px; padding: 5px 13px; font: inherit; font-size: 12.5px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: all .14s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
  color: var(--accent-strong); font-weight: 700;
}

/* ---------- 空态 / 加载 / 错误 ---------- */
.empty { color: var(--muted); text-align: center; padding: 48px 22px; }
.empty .empty-title { color: var(--fg); font-weight: 700; font-size: 14.5px; margin-bottom: 5px; }
.empty .btn-row { justify-content: center; margin-top: 14px; }

.skel {
  background: linear-gradient(90deg, var(--panel-2) 25%, color-mix(in srgb, var(--line) 55%, var(--panel-2)) 50%, var(--panel-2) 75%);
  background-size: 200% 100%; animation: skel 1.3s infinite; border-radius: 8px; height: 14px;
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-row { display: flex; gap: 12px; margin: 12px 0; }

.error-panel {
  border: 1px solid rgba(207, 61, 85, .34); background: var(--bad-soft);
  border-radius: var(--radius); padding: 18px; display: grid; gap: 8px;
}
.error-panel .title { font-weight: 700; color: var(--bad); }
.error-panel .detail { font-family: var(--mono); font-size: 12px; color: var(--fg-dim); word-break: break-word; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line-strong);
  border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow);
  animation: toast-in .18s ease-out;
}
.toast .t-title { font-weight: 700; font-size: 13px; }
.toast .t-detail { color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-word; }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast.info { border-left-color: var(--info); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- dialog ---------- */
.dialog {
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
  border-radius: 20px; padding: 0; width: min(580px, calc(100vw - 32px)); box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}
.dialog.wide { width: min(880px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(20, 28, 48, .45); backdrop-filter: blur(3px); }
.dialog .dlg-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog .dlg-title { font-size: 16px; font-weight: 720; margin: 0; }
.dialog .dlg-body { padding: 18px 20px; max-height: min(66vh, 660px); overflow: auto; }
.dialog .dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 19px 19px; }
.dialog .dlg-close { margin-left: auto; }

.callout { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 11px 13px; font-size: 13px; background: var(--panel-2); }
.callout.warn { border-color: rgba(169, 105, 10, .34); background: var(--warn-soft); }
.callout.bad { border-color: rgba(207, 61, 85, .34); background: var(--bad-soft); }
.callout.info { border-color: rgba(31, 111, 208, .28); background: var(--info-soft); }
.callout ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- 收件箱 ---------- */
.inbox-layout { display: grid; grid-template-columns: minmax(330px, 430px) 1fr; gap: 16px; align-items: start; }
.conv-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; box-shadow: var(--shadow); }
.conv-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s ease; }
.conv-item:last-child { border-bottom: none; }
.conv-item:hover { background: var(--panel-2); }
.conv-item.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.conv-item .unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.conv-item .unread-dot.read { background: transparent; box-shadow: none; }
.conv-main { min-width: 0; flex: 1; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-who { font-weight: 700; font-size: 13.5px; }
.conv-time { margin-left: auto; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.conv-subject { font-size: 13px; margin-top: 2px; color: var(--fg-dim); }
.conv-snippet { color: var(--muted); font-size: 12px; margin-top: 3px; }
.conv-meta { color: var(--muted); font-size: 11.5px; margin-top: 4px; display: flex; gap: 8px; align-items: center; }

.reader { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-height: 260px; box-shadow: var(--shadow); }
.reader-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.reader-body { padding: 14px 16px; display: grid; gap: 14px; }
.msg { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.msg-head { padding: 9px 13px; background: var(--panel-2); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.msg-head .from { color: var(--fg-dim); font-weight: 650; }
.msg-content { padding: 12px 14px; }
.msg pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.65 var(--font); }
.mail-frame { width: 100%; border: 0; background: #fff; min-height: 120px; display: block; border-radius: 8px; }
details.raw { border-top: 1px dashed var(--line); padding: 9px 13px; }
details.raw summary { cursor: pointer; color: var(--muted); font-size: 12px; }

/* ---------- 杂项 ---------- */
.sep { height: 1px; background: var(--line); margin: 4px 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.steps-mini { display: flex; gap: 6px; flex-wrap: wrap; }
.recip-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.recip-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.recip-item:last-child { border-bottom: none; }
.recip-item:hover { background: var(--panel-2); }
.recip-item .who { min-width: 0; }
.recip-item .who .email { font-weight: 650; }
.recip-item .who .note { color: var(--muted); font-size: 12px; }
.step-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 11px; background: var(--panel-2); }
.step-card + .step-card { margin-top: 12px; }
.step-head { display: flex; align-items: center; gap: 8px; }
.step-no { font-weight: 750; color: var(--accent-strong); font-size: 13px; }
.kbd { font-family: var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; font-size: 11px; color: var(--fg-dim); background: var(--panel); }
.vars { font-family: var(--mono); font-size: 12px; color: var(--info); background: var(--info-soft); border-radius: 5px; padding: 0 4px; }

/* ---------- 运营工作台 ---------- */
.ops-page { gap: 22px; }
.ops-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ops-title { font-size: 26px; line-height: 1.3; font-weight: 720; letter-spacing: -.4px; }
.ops-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.ops-heading .btn { min-height: 40px; padding: 9px 16px; flex: none; }
.ops-datebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ops-datebar .field { display: flex; align-items: center; gap: 12px; }
.ops-datebar label { white-space: nowrap; font-size: 13px; }
.ops-datebar .btn { min-height: 40px; }
.ops-date-note { font-size: 12px; }
.ops-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 20px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.ops-metric { min-width: 0; padding: 0 22px; }
.ops-metric + .ops-metric { border-left: 1px solid var(--line); }
.ops-metric .k { font-size: 13px; font-weight: 600; color: var(--fg-dim); }
.ops-metric .v { font-size: 30px; font-weight: 650; line-height: 1.4; margin: 8px 0 5px; font-variant-numeric: tabular-nums; }
.ops-metric .s { font-size: 12px; color: var(--muted); }
.ops-workflow { padding: 20px 22px; }
.ops-workflow h2, .ops-tasks h2 { font-size: 16px; }
.ops-steps { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; margin: 18px 0 0; }
.ops-step { display: flex; align-items: flex-start; gap: 12px; padding-right: 22px; min-width: 0; }
.ops-step + .ops-step { border-left: 1px solid var(--line); padding-left: 22px; }
.ops-step-no { width: 30px; height: 30px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-strong); border-radius: 50%; font-size: 13px; font-weight: 650; }
.ops-step p { margin: 5px 0 10px; font-size: 12px; color: var(--muted); }
.ops-step .btn.link { padding: 0; line-height: 1.6; }
.ops-workflow-foot { display: flex; gap: 16px; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; font-size: 12px; }
.ops-notices { display: grid; gap: 10px; }
.ops-status { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-size: 13px; }
.ops-status.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 24%, var(--line)); }
.ops-status-mark { width: 18px; height: 18px; display: inline-grid; place-items: center; flex: none; color: var(--warn); border: 1px solid currentColor; border-radius: 50%; font-size: 12px; font-weight: 700; }
.ops-status.info .ops-status-mark { color: var(--info); }
.ops-status-detail { padding: 0; display: block; }
.ops-status-detail summary { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 11px 14px; cursor: pointer; list-style: none; border-radius: var(--radius); }
.ops-status-detail summary::-webkit-details-marker { display: none; }
.ops-status-detail .ops-detail-toggle { margin-left: auto; color: var(--accent-strong); font-size: 12px; white-space: nowrap; }
.ops-detail-toggle::after { content: ' ›'; display: inline-block; margin-left: 4px; }
.ops-status-detail[open] .ops-detail-toggle::after { transform: rotate(90deg); }
.ops-status-body { border-top: 1px solid var(--line); padding: 12px 14px; color: var(--fg-dim); font-size: 12px; overflow-wrap: anywhere; }
.ops-status-body p { margin: 6px 0 0; }
.ops-tasks { min-width: 0; }
.ops-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ops-section-head .muted { font-size: 12px; }
.ops-tasks .table-wrap { border-radius: var(--radius); }
.ops-empty { padding: 30px 20px; }
.ops-empty-icon { display: block; margin: 0 auto 12px; color: var(--muted); opacity: .55; }

@media (max-width: 1100px) {
  .ops-metric { padding: 0 16px; }
  .ops-step { padding-right: 14px; }
  .ops-step + .ops-step { padding-left: 14px; }
}

@media (max-width: 640px) {
  .ops-page { gap: 18px; }
  .ops-heading { align-items: flex-start; flex-wrap: wrap; }
  .ops-title { font-size: 23px; }
  .ops-datebar { gap: 10px; }
  .ops-datebar .field { gap: 8px; }
  .ops-date-note { width: 100%; }
  .ops-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; }
  .ops-metric { padding: 16px; }
  .ops-metric:nth-child(3) { border-left: 0; }
  .ops-metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .ops-workflow { padding: 18px 16px; }
  .ops-steps { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .ops-step, .ops-step + .ops-step { padding: 0; border: 0; }
  .ops-workflow-foot { flex-wrap: wrap; gap: 8px; }
  .ops-status { font-size: 12px; }
  .ops-section-head { flex-wrap: wrap; }
}

/* ---------- 登录与用户权限 ---------- */
#auth-gate { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg); }
#auth-gate[hidden] { display: none; }
.auth-card { width: min(100%, 440px); padding: 36px; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 20px 60px rgba(18, 24, 40, .12); }
.auth-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--accent); color: var(--accent-ink); font-size: 22px; margin-bottom: 22px; }
.auth-card h1 { margin: 0 0 10px; font-size: 28px; letter-spacing: -.03em; }
.auth-lead { color: var(--muted); line-height: 1.65; margin: 0 0 24px; }
.auth-footnote { margin: 18px 0 0; font-size: 12px; }
.keeper-login { width: 100%; justify-content: center; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 16px; color: var(--muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.auth-user { display: flex; gap: 10px; align-items: center; max-width: 260px; color: var(--muted); font-size: 12px; }
.auth-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-cards { align-items: stretch; }
.role-card { min-height: 150px; }
.role-card-head { display: flex; gap: 10px; align-items: center; }
.role-card h3 { margin: 0; }
.role-card p { line-height: 1.55; }
.role-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.role-system_admin { background: #b7791f; }
.role-operator { background: var(--accent); }
.role-viewer { background: #718096; }
.role-perms { display: flex; gap: 6px; flex-wrap: wrap; }
.permission-yes { color: var(--ok); font-weight: 700; }
.permission-no { color: var(--muted); }
@media (max-width: 640px) { .auth-card { padding: 28px 22px; } .auth-user { max-width: 150px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto; z-index: 30; flex-direction: row; align-items: center;
    padding: 8px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0 8px 0 2px; flex: none; }
  .brand-text { display: none; }
  .nav { flex-direction: row; gap: 4px; flex: 0 0 auto; }
  .nav-item { padding: 8px 11px; white-space: nowrap; flex: none; }
  .nav-item span:not(.nav-ico):not(.nav-badge) { display: none; }
  .nav-item.on span:not(.nav-ico):not(.nav-badge) { display: inline; }
  /* 移动端顶栏空间有限：心跳状态已在页面顶栏显示，这里不再重复占用宽度 */
  .sidebar-foot { display: none; }
  .sidebar { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .sidebar::-webkit-scrollbar { display: none; }
  .topbar { padding: 10px 14px; gap: 8px; }
  #page-sub { display: none; }
  .page-title { white-space: nowrap; font-size: 16px; }
  .hb-inline { font-size: 11.5px; }
  td[data-label] .cell-sub, table.data.responsive tbody td .mono { word-break: break-word; }
  .main { padding: 14px 14px 68px; }
  .inbox-layout { grid-template-columns: minmax(0, 1fr); }
  .inbox-layout > section { min-width: 0; }
  .toolbar { min-width: 0; }
  .search { min-width: 0; max-width: 100%; }
  .toolbar select { max-width: 100%; min-width: 0; }
  .grid.main-2, .grid.main-side { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .bar-wrap { max-width: none; }
  .dialog, .dialog.wide { width: 100vw; max-width: none; border-radius: 18px 18px 0 0; margin: auto 0 0; }
  .dialog { max-height: 92vh; }
  .dialog .dlg-body { max-height: none; }
  .dialog .dlg-foot { border-radius: 0; }

  /* 表格 → 卡片 */
  table.data.responsive thead { display: none; }
  table.data.responsive tbody tr {
    display: grid; grid-template-columns: 1fr; gap: 5px;
    padding: 13px; border-bottom: 1px solid var(--line);
  }
  table.data.responsive tbody td { border: 0; padding: 0; display: flex; gap: 8px; align-items: baseline; }
  table.data.responsive tbody td::before {
    content: attr(data-label); color: var(--muted); font-size: 11.5px; min-width: 76px; flex: none;
  }
  table.data.responsive td.actions { padding-top: 9px; }
  table.data.responsive td.actions::before { content: ""; }
  table.data.responsive td .bar-wrap { min-width: 0; flex: 1; }
}

/* 移动端：打开会话时只显示阅读窗格 */
@media (max-width: 960px) {
  .inbox-layout.show-reader > section:first-child { display: none; }
}

/* 四入口运营界面：任务与表单沿用既有色板和扁平层级。 */
.task-toolbar { flex-wrap: wrap; gap: 14px; }
.task-toolbar form { max-width: 430px; }
.task-toolbar form input { min-width: 0; flex: 1; border-radius: var(--radius); }
.task-toolbar form button { flex: none; white-space: nowrap; }
.task-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.task-filters [aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.task-blocked { max-width: 230px; white-space: normal; }
.ops-page table.data td { overflow-wrap: anywhere; }
.ops-page table.data td:first-child { max-width: 320px; }
.ops-title { overflow-wrap: anywhere; }
.ops-heading > div { min-width: 0; }
.task-pagination { flex-wrap: wrap; gap: 12px; }
a.disabled, a[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.task-create { max-width: 980px; }
.task-create [data-task-form] { max-width: 820px; }
.task-stepper { padding: 0; margin: 8px 0 16px; display: grid; grid-template-columns: repeat(3,1fr); list-style: none; }
.task-stepper li { padding: 12px 0; display: flex; gap: 10px; align-items: center; border-bottom: 2px solid var(--line); color: var(--muted); }
.task-stepper li span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); font-size: 12px; flex: none; }
.task-stepper li.current, .task-stepper li.complete { border-color: var(--accent); color: var(--accent); }
.task-stepper li.current span { background: var(--accent); color: var(--accent-ink); }
.task-form-footer { border-top: 1px solid var(--line); padding-top: 20px; flex-wrap: wrap; }
.task-error { color: var(--bad); white-space: pre-wrap; }
.task-error:empty { display: none; }
.mail-preview { font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; margin: 18px 0 0; line-height: 1.8; }
.task-content summary, .settings-advanced summary { cursor: pointer; font-weight: 600; }
.task-content h3, .task-mail h3 { margin: 14px 0 0; }
.settings-values { display: grid; grid-template-columns: 140px 1fr; gap: 14px 20px; margin: 22px 0; }
.settings-values dt { color: var(--muted); }
.settings-values dd { margin: 0; overflow-wrap: anywhere; }
.settings-links { display: grid; gap: 0; margin-top: 12px; }
.settings-links a { padding: 16px 0; border-top: 1px solid var(--line); display: flex; gap: 24px; align-items: baseline; }
.settings-links a span { color: var(--muted); }
.inbox-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
.inbox-toolbar .search { flex: none; width: 100%; }
.inbox-quick-filters { flex-wrap: wrap; }
.inbox-more { margin-left: auto; position: relative; }
.inbox-more summary { cursor: pointer; padding: 7px 0; font-size: 13px; color: var(--muted); }
.inbox-more > div { position: absolute; z-index: 5; right: 0; top: 38px; width: 270px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 16px; }
.inbox-list-actions, .inbox-pages { flex-wrap: wrap; gap: 8px; }
.inbox-pages #inbox-page { font-size: 11px; }
.inbox-filter-note { font-size: 12px; }
@media (max-width: 640px) {
  .ops-page table.data.responsive tbody td { flex-wrap: wrap; max-width: none; }
  .ops-page table.data.responsive tbody td[data-label="任务"] { display: grid; grid-template-columns: 76px minmax(0,1fr); }
  .ops-page table.data.responsive tbody td[data-label="任务"] > .cell-sub { grid-column: 2; }
  .task-toolbar form { width: 100%; max-width: none; }
  .task-filters { margin-left: 0; }
  .task-stepper li { gap: 6px; font-size: 12px; flex-direction: column; align-items: flex-start; }
  .settings-values { grid-template-columns: 98px 1fr; gap: 14px; }
  .settings-links a { flex-direction: column; gap: 6px; }
  .task-pagination .right { margin-left: 0; }
  .inbox-more > div { width: 240px; }
  .task-mail { padding: 16px; }
}
