:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --muted: #7a818b;
  --accent: #3b6ef5;
  --accent-dark: #2e57c8;
  --danger: #d93a3a;
  --ok: #18a058;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 8px;
}
.nav .brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.nav .brand a { color: var(--text); }
.nav .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-right a { color: var(--text); font-size: 14px; }
.badge {
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 0 7px;
  font-size: 12px;
  margin-left: 4px;
}
button.link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
button.link:hover { color: var(--danger); }

.container { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.panel h1 { font-size: 20px; margin-bottom: 6px; }
.panel .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 220px; resize: vertical; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #eef1f5; color: var(--text); }
.btn.secondary:hover { background: #e2e6ec; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b83030; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.msg-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.msg-item:hover { background: #f7f9fc; }
.msg-item .who {
  width: 240px;
  min-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.msg-item.unread .who, .msg-item.unread .subject { font-weight: 700; }
.msg-item.unread .unread-dot { display: inline-block; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; margin-right: 6px; }
.msg-item .subject { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--text); }
.msg-item .meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.msg-item .tag { font-size: 11px; background: #eef1f5; color: var(--muted); border-radius: 4px; padding: 1px 6px; }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.read-head { margin-bottom: 8px; }
.read-subject { font-size: 20px; font-weight: 700; margin-bottom: 12px; word-break: break-word; }
.read-meta { color: var(--muted); font-size: 13px; margin-bottom: 4px; word-break: break-word; }
.read-actions { display: flex; gap: 10px; margin: 16px 0 20px; }
.read-body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 200px;
  white-space: pre-wrap;
  word-break: break-word;
}
.read-body iframe { width: 100%; min-height: 300px; border: none; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #2c3138;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.25s;
  z-index: 100;
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.ok { background: var(--ok); }

@media (max-width: 640px) {
  .msg-item { flex-wrap: wrap; }
  .msg-item .who { width: 100%; }
  .nav-right { gap: 10px; }
}