:root {
  --bg: #0e1216;
  --surface: #161c23;
  --surface-2: #1d252e;
  --border: #2a343f;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #2dd4bf;
  --accent-dim: #14776e;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Code", "Consolas", monospace;
  --sans: system-ui, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  background: radial-gradient(1200px 600px at 80% -10%, #16242b 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}
h1, h2 { margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); }
.err { color: var(--danger); }
.warn { color: var(--warn); }
code { font-family: var(--mono); background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }

button {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px;
  padding: .55rem 1rem; background: var(--accent); color: #04201c; font-weight: 600;
  transition: filter .15s ease, transform .05s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover { background: var(--surface-2); filter: none; }
button.link, a.link { background: none; color: var(--accent); padding: .2rem .4rem; font-weight: 500; }
a.link { display: inline-block; border-radius: 8px; text-decoration: none; }
a.link:hover { background: var(--surface-2); }
button.danger { background: none; color: var(--danger); padding: .2rem .4rem; font-weight: 500; }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent-dim); }
textarea { font-family: var(--mono); resize: vertical; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem; width: min(360px, 92vw); display: grid; gap: .9rem;
  box-shadow: 0 24px 60px -20px #000;
}
.login-card h1 { font-size: 1.35rem; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.5rem; background: rgba(14,18,22,.82); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: -.02em; }
.brand::before { content: "◆ "; color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: .8rem; }
.badge { font-size: .78rem; color: var(--muted); font-family: var(--mono);
  border: 1px solid var(--border); padding: .2rem .55rem; border-radius: 999px; }
.badge.ok { color: var(--accent); border-color: var(--accent-dim); }

.container { max-width: 1040px; margin: 0 auto; padding: 1.6rem 1.5rem 4rem; display: grid; gap: 1.2rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.4rem; }
.row { display: flex; align-items: center; gap: .8rem; margin-top: .8rem; flex-wrap: wrap; }
.card textarea { margin-top: .5rem; }

/* 列表 */
.list-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.toolbar-controls { display: flex; gap: .6rem; }
.toolbar-controls input { width: 240px; }
.toolbar-controls select { width: auto; }

.acct-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.acct-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .04em; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.acct-table td { padding: .65rem .6rem; border-bottom: 1px solid var(--surface-2); }
.acct-table tbody tr:hover { background: var(--surface-2); }
.acct-table .email { font-family: var(--mono); }
.acct-table .actions-col { text-align: right; }
.acct-table td.actions { text-align: right; white-space: nowrap; }
.status-ok { color: var(--accent); }
.status-bad { color: var(--danger); }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 1rem; z-index: 20; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; width: min(720px, 95vw); max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px -20px #000; }
.keybox { background: var(--bg); border: 1px solid var(--accent-dim); border-radius: 8px;
  padding: 1rem; font-family: var(--mono); word-break: break-all; white-space: pre-wrap; color: var(--accent); }
.linkbox { margin-top: .6rem; min-height: 12rem; font-family: var(--mono); color: var(--accent); }

/* 邮件 */
.mail-card { width: min(900px, 96vw); }
.mail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .8rem; }
.mail-list { display: grid; gap: .4rem; margin: .5rem 0; }
.mail-item { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem .8rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.mail-item:hover { border-color: var(--accent-dim); }
.mail-item .subj { font-weight: 600; }
.mail-item .ftag { display: inline-block; font-size: .68rem; font-weight: 700; color: var(--warn);
  border: 1px solid var(--warn); border-radius: 4px; padding: 0 .35em; margin-right: .5em; vertical-align: middle; }
.mail-item.unread .subj::before { content: "● "; color: var(--accent); }
.mail-item .date { color: var(--muted); font-size: .8rem; white-space: nowrap; }
#mail-body { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.direct-wrap { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.direct-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.direct-head h1 { font-size: 1.35rem; overflow-wrap: anywhere; }
#direct-body { width: 100%; height: calc(100vh - 150px); min-height: 420px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.spinner { color: var(--muted); }
[hidden] { display: none !important; }
