/* GridMail 网页邮箱 —— 界面按《GridMail 界面原型（2026-12-01）》重做。
   四条布局约束（来自原型）：
     1. 根节点锁定 100dvh，整页不产生滚动条
     2. 导航 / 列表 / 正文 各自独立滚动，互不影响
     3. 分页条固定，不随内容滚动而移动
     4. 任一区内容增减，只影响该区，不改变整体高度
   亮/暗色沿用 color-scheme 自动切换。 */

:root {
  --bg: #f5f5f7;
  --bg-list: #ffffff;
  --bg-read: #ffffff;
  --bg-sidebar: #f6f6f8;
  --bg-hover: rgba(0, 0, 0, 0.045);
  --bg-sel: rgba(0, 122, 255, 0.1);
  --bg-bar: #fbfbfd;
  --border: #e3e3e8;
  --border-2: #ececf0;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #98989d;
  --accent: #007aff;
  --danger: #d70015;
  --ok: #1a8f4c;
  --warn: #b25e00;
  --badge: #ff3b30;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  --side-w: 208px;
  --list-w: 336px;
  --nav-w: 216px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e20;
    --bg-list: #262629;
    --bg-read: #262629;
    --bg-sidebar: #232326;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-sel: rgba(10, 132, 255, 0.18);
    --bg-bar: #232326;
    --border: #3a3a3e;
    --border-2: #303034;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --accent: #0a84ff;
    --danger: #ff6961;
    --ok: #3ddc84;
    --warn: #e0a33a;
    --badge: #ff453a;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.grow { flex: 1 1 auto; }
.mono { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.error { color: var(--danger); font-size: 12.5px; min-height: 16px; }
.note {
  margin-top: 8px; font-size: 12px; color: var(--text-2);
  background: var(--bg-hover); border-radius: 6px; padding: 4px 8px;
}

/* ---------- 按钮 ---------- */
.btn {
  font: inherit; font-size: 12.5px; color: var(--text); background: var(--bg-list);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 11px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.wide { width: 100%; padding: 9px 13px; font-weight: 600; justify-content: center; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.icon-btn {
  width: 28px; height: 28px; flex: 0 0 28px;
  font: inherit; font-size: 15px; line-height: 1; color: var(--text-2);
  background: none; border: none; cursor: pointer; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link-btn { font: inherit; font-size: 12.5px; color: var(--accent); background: none; border: none; cursor: pointer; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }
.move-select {
  font: inherit; font-size: 12px; color: var(--text-2);
  background: var(--bg-list); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 8px; cursor: pointer; max-width: 140px;
}
.move-select:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- 登录 ---------- */
.login {
  height: 100dvh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1000px 500px at 20% -10%, rgba(0, 122, 255, 0.16), transparent),
    radial-gradient(800px 420px at 90% 110%, rgba(88, 86, 214, 0.14), transparent),
    var(--bg);
}
.login-card {
  width: 320px; background: var(--bg-list); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px 26px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.login-brand {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 19px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 6px;
}
.login-card input {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--bg); color: var(--text); outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12); }

/* ---------- 品牌 ---------- */
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
  background: var(--accent); flex: 0 0 auto;
}
.brand-dot.mono-dot { background: var(--text); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }

/* ================= 主框架：三栏 ================= */
.app {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--side-w) var(--list-w) minmax(0, 1fr);
}

/* ---------- 侧栏 ---------- */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
}
.brand {
  padding: 14px 14px 10px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.compose-btn {
  margin: 0 12px 10px; height: 32px; flex: 0 0 32px;
  font: inherit; font-size: 13px; font-weight: 600; color: #fff;
  background: var(--accent); border: none; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.compose-btn:hover { filter: brightness(1.06); }
.boxes {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px;
  padding: 2px 8px 8px; overscroll-behavior: contain;
}
.box-item {
  display: flex; align-items: center; gap: 8px; height: 30px; flex: 0 0 30px;
  font: inherit; font-size: 13px; text-align: left; color: var(--text);
  background: none; border: none; border-radius: 7px; padding: 0 8px;
  cursor: pointer; white-space: nowrap; width: 100%;
}
.box-item:hover { background: var(--bg-hover); }
.box-item.active { background: var(--bg-sel); color: var(--accent); font-weight: 600; }
.box-item svg { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.box-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box-badge {
  margin-left: auto; min-width: 18px; padding: 0 5px; height: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; font-size: 11px; font-weight: 700;
  background: var(--accent); color: #fff;
}
.box-count { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.box-item.active .box-count { color: var(--accent); }
.sidebar-foot {
  flex: 0 0 auto; padding: 10px 12px 12px; border-top: 1px solid var(--border-2);
  font-size: 11.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 7px;
}
.quota { font-size: 11.5px; color: var(--text-2); }
.quota-bar { height: 5px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.quota-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.foot-row { display: flex; gap: 4px; }
.foot-btn {
  flex: 1; font: inherit; font-size: 11.5px; color: var(--text-2);
  background: none; border: 1px solid var(--border-2); border-radius: 6px;
  padding: 4px 2px; cursor: pointer; white-space: nowrap; overflow: hidden;
}
.foot-btn:hover { background: var(--bg-hover); color: var(--text); }
.me-email { color: var(--text-3); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 列表栏 ---------- */
.list-pane {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--bg-list); border-right: 1px solid var(--border);
}
.lhead { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.lhead h1 { margin: 0; font-size: 16px; letter-spacing: -0.2px; white-space: nowrap; }
.count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.lsearch { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding: 0 12px 8px; }
.lsearch input {
  flex: 1; min-width: 0; height: 30px; font: inherit; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 8px; padding: 0 10px;
  background: var(--bg-sidebar); color: var(--text); outline: none;
}
.lsearch input:focus { border-color: var(--accent); background: var(--bg-list); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12); }
.lsearch input::-webkit-search-cancel-button { display: none; }
.ltools {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 0 12px 8px; border-bottom: 1px solid var(--border-2);
  font-size: 11.5px; color: var(--text-2); min-height: 26px;
}
.lnk {
  font: inherit; font-size: 11.5px; color: var(--text-2); background: none;
  border: none; border-radius: 6px; padding: 2px 6px; cursor: pointer; white-space: nowrap;
}
.lnk:hover { background: var(--bg-hover); color: var(--text); }
.lnk.danger { color: var(--danger); }
.hint { color: var(--text-3); font-size: 11.5px; white-space: nowrap; }
.hint b { font-weight: 600; font-variant-numeric: tabular-nums; }
.search-note { color: var(--accent); font-size: 11.5px; white-space: nowrap; }

.bulk-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg-sel); font-size: 12px;
}
.bulk-bar #bulk-count { color: var(--text-2); margin-right: 2px; white-space: nowrap; }
.bulk-bar .btn { padding: 3px 8px; font-size: 11.5px; }
.advanced-panel { flex: 0 0 auto; padding: 8px 12px; border-bottom: 1px solid var(--border-2); background: var(--bg-bar); }
.advanced-panel .form-input { width: auto; min-width: 120px; margin-bottom: 0; }

/* 列表本身：唯一的滚动区（除分页外） */
.list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.list-empty { padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 12.5px; }

.row {
  position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px; padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border-2);
}
.row:hover { background: var(--bg-hover); }
.row.selected { background: var(--bg-sel); }
.row.selected::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2.5px; background: var(--accent);
}
.row-main { min-width: 0; }
.row-line1 { display: flex; align-items: baseline; gap: 6px; }
.row-from {
  font-size: 12.5px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; min-width: 0;
}
.row.unread .row-from { font-weight: 700; }
.row-tag {
  font-size: 10.5px; color: var(--accent); flex-shrink: 0;
  background: var(--bg-sel); padding: 0 5px; border-radius: 8px; white-space: nowrap;
}
.row-date { margin-left: auto; font-size: 11px; color: var(--text-3); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.row-subject {
  font-size: 12.5px; margin-top: 2px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.row.unread .row-subject { font-weight: 600; }
.row-preview {
  font-size: 11.5px; color: var(--text-3); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-star { position: absolute; right: 10px; bottom: 7px; color: #f5a623; font-size: 11px; pointer-events: none; }
.row-unread-dot {
  position: absolute; left: 4px; top: 15px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.row-thread-count {
  min-width: 20px; height: 18px; border-radius: 9px; background: var(--bg-hover);
  color: var(--text-2); font-size: 11px; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 600;
}
.thread-row { grid-template-columns: 20px 30px minmax(0, 1fr); }
.thread-children { margin-left: 26px; border-left: 1px solid var(--border); }

/* 头像 */
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 12px;
  font-weight: 600; color: var(--text-2); background: var(--bg-hover);
  user-select: none; flex-shrink: 0;
}
.row.unread .avatar { color: var(--accent); background: var(--bg-sel); }
.avatar.lg { width: 26px; height: 26px; font-size: 11.5px; color: var(--accent); background: var(--bg-sel); }

/* 分页条：固定在列表底部，不随内容滚动 */
.pager {
  flex: 0 0 auto; display: flex; align-items: center; gap: 5px;
  height: 38px; padding: 0 10px;
  border-top: 1px solid var(--border); background: var(--bg-bar);
}
.pg-pages { display: flex; gap: 4px; }
.pg {
  min-width: 25px; height: 25px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 11.5px; color: var(--text-2);
  background: var(--bg-list); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.pg:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.pg.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pg:disabled { opacity: 0.4; cursor: default; }
.pager-info {
  margin-left: auto; font-size: 11.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ---------- 阅读栏 ---------- */
.read-pane {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--bg-read); overflow: hidden;
}
.read-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--text-3); gap: 6px;
}
.read-empty-mark {
  font-size: 26px; font-weight: 800; letter-spacing: -0.6px;
  color: color-mix(in srgb, var(--text-3) 35%, transparent);
}
.read {
  flex: 1; min-height: 0; display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.read-head {
  padding: 14px 20px 10px; border-bottom: 1px solid var(--border-2);
  max-height: 42vh; overflow-y: auto;
}
.read-top { display: flex; align-items: center; gap: 8px; }
.read-who { min-width: 0; flex: 1; }
.read-from { font-weight: 600; font-size: 12.5px; }
.read-from .addr { font-weight: 400; color: var(--text-3); font-size: 12px; }
.read-to { color: var(--text-3); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-date { color: var(--text-3); font-size: 11.5px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.read h1 { font-size: 17px; letter-spacing: -0.2px; margin: 8px 0 10px; line-height: 1.35; }
.read-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.read-actions .btn { padding: 3px 9px; font-size: 11.5px; }
.read-actions .move-select { padding: 3px 8px; font-size: 11.5px; }
.atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.att {
  display: inline-flex; align-items: center; gap: 6px; font: inherit;
  font-size: 11.5px; color: var(--accent); background: var(--bg-sel);
  border: 1px solid transparent; border-radius: 14px; padding: 3px 10px; cursor: pointer;
}
.att:hover { border-color: var(--accent); }
.att .att-size { color: var(--text-3); }
.read-body {
  overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 20px 40px; font-size: 13.5px; line-height: 1.68;
  overflow-wrap: break-word;
}
.read-body.pre { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.read-body img { max-width: 100%; height: auto; }
.read-body blockquote { margin: 10px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--border); color: var(--text-2); }
.read-body table { max-width: 100%; border-collapse: collapse; }
.read-body pre { white-space: pre-wrap; overflow-wrap: break-word; }

/* ---------- 弹层：写信 / 设置 / 日历 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.32);
  display: flex; z-index: 40; backdrop-filter: blur(2px);
}
.overlay .compose { margin: auto 24px 24px auto; }
.overlay.center { align-items: center; justify-content: center; }
.compose {
  width: 580px; max-width: calc(100vw - 48px); max-height: calc(100dvh - 48px);
  background: var(--bg-list); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.compose-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; font-weight: 600; border-bottom: 1px solid var(--border);
  background: var(--bg-bar); flex: 0 0 auto;
}
.compose-fields { padding: 6px 14px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.field-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.field-row + .field-row { border-top: 1px solid var(--border-2); }
.field-label { width: 50px; color: var(--text-2); font-size: 12.5px; flex: 0 0 auto; }
.field-row input { flex: 1; font: inherit; font-size: 13px; border: none; outline: none; background: none; color: var(--text); padding: 3px 0; }
.compose-toolbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 3px;
  padding: 6px 10px; border-bottom: 1px solid var(--border-2); flex-wrap: wrap;
}
.fmt-btn {
  width: 28px; height: 26px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; cursor: pointer; font-size: 13px; color: var(--text-2);
}
.fmt-btn:hover { background: var(--bg-hover); color: var(--text); }
.compose-rich {
  flex: 1 1 auto; min-height: 200px; overflow: auto; padding: 12px 14px;
  outline: none; white-space: pre-wrap; font-size: 13.5px; line-height: 1.6;
}
.compose-rich:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.compose-atts { flex: 0 0 auto; padding: 0 14px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: 12px; background: var(--bg-sel); color: var(--accent); font-size: 11.5px;
}
.att-x { border: none; background: transparent; cursor: pointer; font-size: 13px; line-height: 1; color: var(--text-3); }
.compose-foot { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.compose-foot .error { flex: 1; }

.modal {
  width: 900px; max-width: calc(100vw - 48px); max-height: calc(100dvh - 60px);
  background: var(--bg-list); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--border); background: var(--bg-bar);
}
.modal-body { flex: 1; min-height: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.modal-body h2 {
  font-size: 12px; margin: 18px 0 8px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border-2); padding-bottom: 8px; flex-wrap: wrap; }
.tab { border: none; background: transparent; padding: 5px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text-2); }
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.active { background: var(--bg-sel); color: var(--accent); font-weight: 600; }

.form-label { display: block; margin: 10px 0 4px; font-size: 12px; color: var(--text-2); }
.form-input, .form-textarea {
  width: 100%; padding: 7px 10px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 12.5px;
  background: var(--bg-list); color: var(--text); outline: none;
}
.form-input:focus, .form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12); }
.form-textarea { resize: vertical; }
.form-row { display: flex; align-items: center; gap: 6px; margin: 8px 0; font-size: 12.5px; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
/* 全局策略：数值框统一窄宽、长文本限宽。否则一页里 92px 的数值框和
   1188px 的整行输入框并排，右侧又留一大片空白，看上去像没做完。 */
#admin-settings-sec .inline-form { gap: 8px 12px; margin: 0 0 10px; }
#admin-settings-sec .inline-form label { gap: 7px; }
#admin-settings-sec .inline-form input[type="number"] { width: 104px; }
#admin-settings-sec .form-label { display: block; margin: 6px 0 6px; font-size: 12.5px; color: var(--text-2); }
#admin-settings-sec #gs-blocked { max-width: 620px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.inline-form label { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); }
.inline-form .form-input { width: auto; min-width: 120px; margin-bottom: 0; }
/* 行内表单里的文本框默认没有 class，统一成与 .form-input 一致的外观 */
.inline-form input:not([type="checkbox"]):not([type="radio"]),
.inline-form select {
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 12.5px; background: var(--bg-list); color: var(--text);
  outline: none;
}
.inline-form input:not([type="checkbox"]):not([type="radio"]):focus,
.inline-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12); }
.inline-form input[type="number"] { width: 92px; }
.inline-form input[type="datetime-local"] { min-width: 168px; }
/* 搜索/过滤类文本框给足宽度，避免 placeholder 被截断 */
.inline-form input[type="text"], .inline-form input:not([type]) { min-width: 220px; }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; font-size: 11.5px; color: var(--text-2); font-weight: 600;
  letter-spacing: 0.2px; padding: 7px 10px; border-bottom: 1px solid var(--border);
  background: var(--bg-bar); white-space: nowrap;
}
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border-2); white-space: nowrap; }
.tbl tr:hover td { background: var(--bg-hover); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.empty-row:hover td { background: transparent; }
.tbl td.empty-cell { text-align: center; color: var(--text-3); font-size: 12px; padding: 18px 10px; }
.tbl td.num { font-variant-numeric: tabular-nums; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 16px; padding: 0 5px; margin-left: 6px;
  border-radius: 9px; font-size: 10.5px; font-weight: 700;
  background: var(--border-2); color: var(--text-2); vertical-align: 1px;
}
.badge.unread { background: var(--accent); color: #fff; }
.usage-cell { display: flex; align-items: center; gap: 6px; }
.usage-bar { width: 70px; height: 5px; background: var(--border-2); border-radius: 99px; overflow: hidden; flex-shrink: 0; }
.usage-fill { height: 100%; background: var(--accent); }
.usage-fill.hot { background: var(--danger); }
.usage-num { color: var(--text-3); font-size: 11.5px; }
.cell-err { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--danger); }

.selfcheck { display: grid; gap: 5px; }
.selfcheck-row { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; }
.selfcheck-row .ok { color: var(--ok); font-weight: 700; }
.selfcheck-row .bad { color: var(--danger); font-weight: 700; }
.selfcheck-name { min-width: 110px; font-weight: 600; }
.selfcheck-detail { color: var(--text-2); font-size: 11.5px; word-break: break-all; }
/* 自检只有几行文字，直接贴左上角会显得整页空；包一层卡片并给行高，
   让它和概览的 KPI 卡、隔离区的表格卡同一套视觉语言。 */
#admin-selfcheck-sec .selfcheck {
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-list);
  padding: 6px 4px; max-width: 720px;
}
#admin-selfcheck-sec .selfcheck-row {
  padding: 7px 12px; border-bottom: 1px solid var(--border-2); align-items: center;
}
#admin-selfcheck-sec .selfcheck-row:last-child { border-bottom: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(30, 30, 32, 0.94); color: #fff; font-size: 12.5px;
  padding: 8px 16px; border-radius: 99px; z-index: 60;
  box-shadow: var(--shadow); max-width: 70vw;
}
.toast.err { background: var(--danger); }

/* ---------- 联想 ---------- */
.suggest {
  position: absolute; z-index: 50; background: var(--bg-list);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  max-height: 220px; overflow: auto; min-width: 260px;
}
.suggest-item { padding: 7px 10px; cursor: pointer; font-size: 12.5px; }
.suggest-item:hover { background: var(--bg-sel); }

/* ---------- 日历 ---------- */
.cal-modal { width: min(1000px, 96vw); }
.cal-nav { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.cal-nav .form-input { width: auto; min-width: 130px; max-width: 180px; margin-bottom: 0; padding: 4px 8px; }
/* 日历弹窗自带纵向布局：月份网格吃剩余高度并可独立滚动，日程表单钉在底部。
   否则窗口一矮（≤1080p）整块内容超出 modal 高度，「保存日程」被挤出可视区。 */
.cal-modal > .modal-body {
  display: flex; flex-direction: column; min-height: 0;
  overflow: hidden; padding: 12px 16px; gap: 10px;
}
.cal-grid {
  flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  align-content: start; margin-bottom: 0; padding-right: 2px;
}
.cal-dow { text-align: center; font-size: 11.5px; color: var(--text-3); padding: 2px 0; }
.cal-day {
  min-height: clamp(44px, 6.2dvh, 78px); border: 1px solid var(--border-2); border-radius: 8px;
  padding: 3px 4px; cursor: pointer; overflow: hidden;
}
.cal-day:hover { background: var(--bg-hover); }
.cal-day.other { opacity: 0.45; }
.cal-day.today { border-color: var(--accent); background: var(--bg-sel); }
.cal-day-num { font-size: 11.5px; color: var(--text-2); margin-bottom: 2px; }
.cal-event {
  font-size: 10.5px; line-height: 1.3; background: var(--bg-sel); color: var(--accent);
  border-radius: 4px; padding: 2px 4px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-form { flex: 0 0 auto; border-top: 1px solid var(--border-2); padding-top: 8px; }
.cal-form h3 { margin: 0 0 6px; font-size: 13.5px; }
.cal-form .form-input { margin-bottom: 6px; }
.cal-form .form-textarea { margin-bottom: 4px; min-height: 52px; }
.cal-form .inline-form { margin: 0 0 6px; }
.cal-form .form-actions { margin-top: 2px; }

/* ================= 管理台（独立视图，不是弹层） ================= */
.admin-view {
  position: fixed; inset: 0; z-index: 45;
  display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr);
  background: var(--bg);
}
.admin-view.hidden { display: none; }
.anav {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
}
.atop {
  flex: 0 0 auto; padding: 14px 14px 10px; font-weight: 600; font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
}
.anav-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 8px 10px; overscroll-behavior: contain; }
.anav-foot {
  flex: 0 0 auto; padding: 10px 14px; border-top: 1px solid var(--border-2);
  font-size: 11px; color: var(--text-3);
}
.admin-nav-item {
  display: flex; align-items: center; gap: 8px; height: 30px; width: 100%;
  font: inherit; font-size: 13px; text-align: left; color: var(--text);
  background: none; border: none; border-radius: 7px; padding: 0 8px;
  cursor: pointer; white-space: nowrap;
}
.admin-nav-item:hover { background: var(--bg-hover); }
.admin-nav-item.on { background: var(--bg-sel); color: var(--accent); font-weight: 600; }
.admin-nav-item svg { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.admin-nav-item .an { margin-left: auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.admin-nav-item.on .an { color: var(--accent); }
.anav-group { padding: 10px 8px 4px; font-size: 10.5px; letter-spacing: 0.4px; color: var(--text-3); text-transform: uppercase; }

.admin-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ahead { flex: 0 0 auto; padding: 12px 18px 8px; border-bottom: 1px solid var(--border-2); }
.ahead-row { display: flex; align-items: center; gap: 8px; }
.ahead h1 { margin: 0; font-size: 17px; letter-spacing: -0.2px; white-space: nowrap; }
.ahead .error { margin-top: 4px; }
.ahead .tok {
  width: 190px; height: 28px; font: inherit; font-size: 12px;
  border: 1px solid var(--border); border-radius: 7px; padding: 0 9px;
  background: var(--bg-list); color: var(--text); outline: none;
}
.ahead .tok:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12); }

.apages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 18px 24px; overscroll-behavior: contain; }
.apages > .apage { display: none; }
.apages > .apage.on { display: block; }
/* 窄屏下表格会超出内容区：让分区自身横向滚动，避免整页出现滚动条 */
.apage.on { overflow-x: auto; }
/* 页面标题由 .ahead h1 承担，分区内的旧 h2 不再重复显示 */
.apages > .apage > h2 { display: none; }
.atools { display: flex; align-items: center; gap: 8px; padding: 10px 0 8px; flex-wrap: wrap; }
.ascroll { background: var(--bg-list); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: 60vh; }

/* 概览：KPI 卡 + 内嵌投递队列。分区本身是块级（.apage.on 已给 display:block），
   KPI 的网格放在 .stat-grid 里，避免整块分区变成 grid 后队列无处安放。 */
.admin-stats { padding: 12px 0 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.stat-card {
  background: var(--bg-list); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; transition: border-color 0.12s ease, background 0.12s ease;
}
/* 前三张是队列状态卡：点一下 = 把下面的表格筛到对应状态 */
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { border-color: var(--text-3); background: var(--bg-hover); }
.stat-card.clickable.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stat-card.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stat-num { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.stat-label { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* 投递队列卡片：头固定、表格横向可滚、纵向跟随 .apages */
.ovq { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-list); overflow: hidden; }
.ovq-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--bg-bar);
}
.ovq-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.ovq-sum { font-size: 11.5px; color: var(--text-3); }
.ovq-head .form-input { width: auto; margin-bottom: 0; }
.ovq-sel { min-width: 96px; }
.ovq-search { min-width: 190px; }
.ovq-wrap { overflow-x: auto; }
.ovq-wrap .tbl { min-width: 860px; }
.ovq-note {
  padding: 8px 12px; border-top: 1px solid var(--border-2);
  font-size: 11.5px; color: var(--text-3);
}
/* 队列状态徽标 / 错误摘要 / 操作列 */
.q-badge { display: inline-block; padding: 0 7px; border-radius: 99px; font-size: 11px; line-height: 1.7; white-space: nowrap; }
.q-badge.pending { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.q-badge.held { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.q-badge.failed { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.q-badge.delivered { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.q-err {
  max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--danger); font-size: 11.5px; cursor: help;
}
.q-ops { display: flex; gap: 4px; }
.q-ops .btn { white-space: nowrap; }
/* 已放弃的行标出发件人是否已被通知：同样写「失败」的两行，含义可能完全不同。 */
.q-status { white-space: nowrap; }
.q-dsn {
  display: inline-block; margin-left: 5px; padding: 0 6px; border-radius: 4px;
  font-size: 10.5px; line-height: 1.7; vertical-align: 1px; cursor: help;
  color: var(--text-3); background: var(--bg-sidebar); border: 1px solid var(--border-2);
}
.q-dsn.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: transparent; }

/* ---------- 滚动条 ---------- */
.boxes::-webkit-scrollbar, .list::-webkit-scrollbar, .read-body::-webkit-scrollbar,
.read-head::-webkit-scrollbar, .modal-body::-webkit-scrollbar,
.anav-scroll::-webkit-scrollbar, .apages::-webkit-scrollbar, .ascroll::-webkit-scrollbar,
.compose-rich::-webkit-scrollbar { width: 10px; height: 10px; }
.boxes::-webkit-scrollbar-thumb, .list::-webkit-scrollbar-thumb, .read-body::-webkit-scrollbar-thumb,
.read-head::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb,
.anav-scroll::-webkit-scrollbar-thumb, .apages::-webkit-scrollbar-thumb, .ascroll::-webkit-scrollbar-thumb,
.compose-rich::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-3) 40%, transparent);
  border-radius: 99px; border: 3px solid transparent; background-clip: content-box;
}

/* ---------- 断点（与原型一致的三档收缩） ---------- */
@media (max-width: 1439px) {
  :root { --side-w: 196px; --list-w: 318px; --nav-w: 200px; }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1279px) {
  :root { --side-w: 180px; --list-w: 300px; --nav-w: 188px; }
  .read h1 { font-size: 16px; }
}
@media (max-width: 1099px) {
  :root { --side-w: 64px; --list-w: 286px; --nav-w: 60px; }
  .brand { justify-content: center; padding: 14px 0 10px; }
  .brand span:not(.brand-dot) { display: none; }
  .compose-btn { margin: 0 10px 10px; font-size: 0; }
  .compose-btn::before { content: "+"; font-size: 18px; }
  .box-item { justify-content: center; padding: 0; }
  .box-item .box-name, .box-item .box-count, .box-item .box-badge { display: none; }
  .sidebar-foot .quota, .sidebar-foot .me-email { display: none; }
  .foot-row { flex-direction: column; }
  /* 侧栏收窄到 64/56px 后，「退出登录」4 个字会被裁掉，缩小字号并允许换行 */
  .foot-btn { font-size: 10px; padding: 5px 2px; white-space: normal; line-height: 1.2; word-break: break-all; }
  .atop span.t { display: none; }
  .atop { justify-content: center; }
  .admin-nav-item { justify-content: center; padding: 0; }
  .admin-nav-item span.t, .admin-nav-item .an, .anav-group { display: none; }
}
@media (max-width: 900px) {
  /* 窄屏保留三栏（原型不隐藏阅读区）：列表保持可读宽度，阅读区吃剩余空间。 */
  :root { --side-w: 56px; --list-w: 280px; --nav-w: 56px; }
  .app { grid-template-columns: var(--side-w) var(--list-w) minmax(180px, 1fr); }
  .compose, .modal { width: 96vw !important; max-width: 96vw !important; }
  .admin-view { grid-template-columns: 56px minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 隔离邮件详情：头部固定 / 中部滚动 / 底部按钮固定（与日历弹窗同一套三段式） */
/* 管理台是 .admin-view（z-index 45）整屏覆盖层，详情弹窗必须压在它上面，
   否则遮罩与弹窗被管理台盖住，按钮点不到。 */
#quar-wrap { z-index: 50; }
/* 删除确认弹窗同样是压在管理台之上的一层。 */
#qdel-wrap { z-index: 50; }
.qdel-modal { width: min(460px, 92vw); }
.qdel-text { margin: 0 0 10px; font-size: 13px; line-height: 1.7; color: var(--text-2); }
.qdel-opt {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--border-2); border-radius: 8px; background: var(--bg-sidebar);
  font-size: 12.5px; line-height: 1.6; cursor: pointer;
}
.qdel-opt input { margin: 2px 0 0; flex: 0 0 auto; }
.qdel-opt b { font-weight: 600; word-break: break-all; }
.qdel-hint { margin: 10px 0 0; font-size: 12px; line-height: 1.6; color: var(--text-3); }
.quar-modal { width: min(820px, 94vw); }
.modal-foot {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-bar);
}
.quar-meta { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 7px 14px; margin: 0; font-size: 13px; }
.quar-meta dt { color: var(--text-3); }
.quar-meta dd { margin: 0; word-break: break-all; color: var(--text); }
.quar-meta dd.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.quar-sig { color: var(--danger); font-weight: 600; }
.quar-preview {
  margin: 0; padding: 12px; border: 1px solid var(--border-2); border-radius: 8px;
  background: var(--bg-sidebar); color: var(--text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow: auto; overscroll-behavior: contain;
}
.quar-empty { color: var(--text-3); font-size: 12.5px; padding: 10px 2px; }
.quar-warn { color: var(--warn); font-size: 12px; }
.quar-risk {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 1.5; vertical-align: 1px;
}
/* 已投递但留有上次失败记录：降级成次要色，别让红色和「已投递」打架 */
.q-err.done { color: var(--text-3); }

/* 运行日志：表头吸顶 + 内容可换行。日志行天然比表格其他页长，
   .tbl 的 nowrap 会把整条 msg 挤成一行然后横向溢出。 */
.log-head { display: flex; align-items: center; gap: 10px; padding: 12px 0 2px; flex-wrap: wrap; }
.log-src { font-size: 11.5px; color: var(--text-3); word-break: break-all; }
.log-follow { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.log-wrap {
  margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-list); overflow: auto; max-height: calc(100dvh - 286px);
}
.log-tbl td { white-space: normal; vertical-align: top; }
.log-tbl .c-time { width: 104px; }
.log-tbl .c-lv { width: 60px; }
.log-tbl .c-cp { width: 88px; }
.log-time { color: var(--text-3); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-comp { color: var(--text-2); font-size: 11.5px; white-space: nowrap; }
.log-lv {
  display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px;
  line-height: 1.6; background: var(--border-2); color: var(--text-2);
}
.log-lv.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.log-lv.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.log-msg { display: block; color: var(--text); font-size: 12.5px; line-height: 1.55; }
/* 只有错误整行标红：警告一多（每次启动 3 条明文 HTTP 提醒）整片橙色反而看不清，
   级别交给左侧徽标表达就已经够了。 */
.log-row.lv-error .log-msg { color: var(--danger); font-weight: 600; }
.log-row.lv-error .log-time { color: var(--danger); }
.log-extra { display: block; margin-top: 2px; color: var(--text-3); font-size: 11.5px; word-break: break-word; }
.log-foot { display: flex; align-items: center; gap: 10px; padding: 10px 0 0; }
.log-stat { font-size: 11.5px; color: var(--text-3); }
