:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-hover: #f4f5f7;
  --line: #e8eaed;
  --line-strong: #dfe1e5;
  --text: #16181d;
  --text-2: #5f6368;
  --text-3: #8b8f96;
  --accent: #2563eb;
  --accent-soft: #eef3ff;
  --danger: #d93025;
  --warn: #b06000;
  --ok: #12805c;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 4px 16px rgba(16, 24, 40, .06);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* ---------------------------------------------------------- 通用组件 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
}
.btn-primary:hover { background: #1d4fd7; border-color: #1d4fd7; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { color: var(--danger); border-color: #f1cfcc; background: #fff; }
.btn-danger:hover { background: #fdf3f2; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.field .hint.err { color: var(--danger); }

input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.7; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
input::placeholder, textarea::placeholder { color: #b3b7bd; }

.banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}
.banner-ok { background: #f2fbf6; border-color: #cfeee0; color: var(--ok); }
.banner-err { background: #fdf4f3; border-color: #f6d9d6; color: var(--danger); }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-soft);
  color: var(--text-2);
  border: 1px solid var(--line);
}
.pill-accent { background: var(--accent-soft); color: var(--accent); border-color: #dbe6ff; }
.pill-ok { background: #f2fbf6; color: var(--ok); border-color: #cfeee0; }
.pill-off { background: #f7f7f8; color: var(--text-3); }

.empty {
  padding: 72px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty .big { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }

/* ------------------------------------------------------------- 登录页 */

.auth-body {
  min-height: 100vh;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .2px;
}
.auth-brand .mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: #111318;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
}
.auth-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 26px 24px;
  box-shadow: var(--shadow);
}
.auth-title { font-size: 20px; font-weight: 650; margin: 0 0 4px; letter-spacing: -.2px; }
.auth-sub { font-size: 13px; color: var(--text-3); margin: 0 0 22px; }
.auth-foot { margin-top: 18px; font-size: 13px; color: var(--text-3); text-align: center; }
.auth-foot a { font-weight: 500; }

.input-suffix { position: relative; }
.input-suffix input { padding-right: 132px; }
.input-suffix .suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-3);
  pointer-events: none;
}

.code-input {
  letter-spacing: 8px;
  font-size: 20px;
  text-align: center;
  font-weight: 600;
  height: 50px;
}

.rules {
  font-size: 12px;
  color: var(--text-3);
  margin: -6px 0 16px;
  padding-left: 16px;
}
.rules li { margin: 2px 0; }

/* --------------------------------------------------------- 应用骨架 */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px 16px;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: #111318;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.compose-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-size: 14px;
  font-weight: 550;
  border: none;
  cursor: pointer;
  justify-content: center;
}
.compose-btn:hover { background: #000; text-decoration: none; }

.nav { flex: 1; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 10px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
}
.nav-item:hover { background: #eceef1; color: var(--text); text-decoration: none; }
.nav-item.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.nav-item .ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: .8; }
.nav-item .count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0 7px;
  min-width: 20px;
  text-align: center;
}
.nav-sep { height: 1px; background: var(--line); margin: 10px 6px; }

.side-user {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 10px;
}
.side-user .who {
  font-size: 12px;
  color: var(--text-3);
  padding: 0 8px 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-user .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 0 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-links { display: flex; gap: 4px; padding: 0 4px; }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 16px; font-weight: 650; margin: 0; letter-spacing: -.2px; }
.search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  width: 100%;
}
.search input { height: 36px; background: var(--bg-soft); border-color: transparent; }
.search input:focus { background: #fff; border-color: var(--accent); }

.content { padding: 20px 24px 40px; flex: 1; }
.content-narrow { max-width: 820px; }

/* --------------------------------------------------------- 邮件列表 */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.muted { color: var(--text-3); font-size: 13px; }

.list { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: #fff; }
.list-head, .row {
  display: grid;
  grid-template-columns: 28px 200px 1fr 110px;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.list-head {
  height: 38px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .2px;
}
.row {
  height: 52px;
  border-bottom: 1px solid #f2f3f5;
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  position: relative;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-hover); text-decoration: none; }
.row.unread { background: #fff; color: var(--text); font-weight: 600; }
.row.unread:hover { background: var(--bg-hover); }
.row.unread .from::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  margin-top: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.row .from, .row .subject, .row .time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .from { padding-left: 8px; }
.row .subject .snippet { color: var(--text-3); font-weight: 400; margin-left: 8px; }
.row .time { text-align: right; color: var(--text-3); font-size: 12.5px; font-weight: 400; }
.row .star { color: #d0d3d8; font-size: 15px; }
.row .star.on { color: #f5a623; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}
.pager a, .pager span {
  display: inline-flex;
  min-width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-2);
  background: #fff;
}
.pager a:hover { background: var(--bg-hover); text-decoration: none; }
.pager .cur { background: var(--text); color: #fff; border-color: var(--text); }
.pager .off { opacity: .45; pointer-events: none; }

/* --------------------------------------------------------- 读信页 */

.msg-head { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 20px; }
.msg-subject { font-size: 21px; font-weight: 650; margin: 0 0 14px; line-height: 1.4; letter-spacing: -.3px; }
.msg-meta { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #f2f4f7;
  color: var(--text-2);
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 14px;
  flex: 0 0 38px;
  border: 1px solid var(--line);
}
.msg-from { font-weight: 600; }
.msg-addr { color: var(--text-3); font-size: 12.5px; word-break: break-all; }
.msg-date { margin-left: auto; color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.msg-body {
  font-size: 14.5px;
  line-height: 1.75;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-body img { max-width: 100%; height: auto; }
.msg-body table { max-width: 100%; }
.msg-body pre { background: var(--bg-soft); padding: 12px; border-radius: 8px; overflow-x: auto; }
.msg-body blockquote {
  margin: 12px 0;
  padding-left: 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--text-2);
}
.msg-text {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.8;
}

.attach-list { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.attach-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}
.attach-item:hover { background: var(--bg-hover); text-decoration: none; }
.attach-item .sz { color: var(--text-3); font-size: 12px; }

.msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.img-note {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffdf5;
  border: 1px solid #f4e6c2;
  color: var(--warn);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* ------------------------------------------------------------ 写信页 */

.compose-card { max-width: 860px; }
.compose-grid { display: grid; grid-template-columns: 64px 1fr; align-items: center; }
.compose-grid .lbl { font-size: 13px; color: var(--text-3); }
.compose-line { border-bottom: 1px solid var(--line); }
.compose-line input { border: none; box-shadow: none; height: 48px; padding: 0; font-size: 14px; border-radius: 0; }
.compose-line input:focus { box-shadow: none; }
.compose-line select { border: none; height: 48px; padding: 0; box-shadow: none; }
.compose-body textarea {
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 16px 0;
  min-height: 320px;
  font-size: 14.5px;
  line-height: 1.75;
}
.compose-body textarea:focus { box-shadow: none; }

.compose-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  flex-wrap: wrap;
}
.file-label { position: relative; overflow: hidden; display: inline-flex; }
.file-label input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ------------------------------------------------------------ 表格 */

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  padding: 10px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid #f2f3f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .num { color: var(--text-3); }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: #fff; }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: #fff;
}
.stat .k { font-size: 12px; color: var(--text-3); }
.stat .v { font-size: 22px; font-weight: 650; letter-spacing: -.4px; margin-top: 2px; }

.section-title { font-size: 14px; font-weight: 650; margin: 0 0 12px; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-all; }

.progress { height: 6px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.inline-form { display: inline-flex; align-items: center; gap: 6px; }
.inline-form input[type=number] { width: 84px; height: 32px; }
.inline-form input[type=password] { width: 150px; height: 32px; }

/* ------------------------------------------------------------ 响应式 */

.mobile-only { display: none; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }
  .brand { padding-bottom: 10px; }
  .compose-btn { margin-bottom: 10px; }
  .nav { display: flex; gap: 6px; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; }
  .nav-item .count { display: none; }
  .side-user { display: none; }
  .nav-sep { display: none; }
  .topbar { height: 56px; padding: 0 14px; }
  .content { padding: 14px; }
  .list-head { display: none; }
  .row { grid-template-columns: 20px 1fr 70px; height: auto; padding: 12px 14px; }
  .row .from { display: none; }
  .row .subject { white-space: normal; }
  .row .subject .snippet { display: none; }
  .mobile-only { display: block; }
  .msg-date { margin-left: 0; width: 100%; }
  .msg-meta { flex-wrap: wrap; }
}

/* ------------------------------------------------------------ 提示条 */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 14px);
  background: #16181d;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
