:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --line: #2a3542;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3d9cfd;
  --accent2: #1f6feb;
  --danger: #f07178;
  --ok: #7fd99a;
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1b3a5a 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #243248 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}
.wrap.narrow { width: min(720px, calc(100% - 32px)); }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
h1 { margin: 0 0 6px; font-size: 1.6rem; letter-spacing: 0.02em; }
h2 { margin: 0 0 14px; font-size: 1.1rem; }
.muted { color: var(--muted); margin: 0; font-size: 0.92rem; }
.label { margin: 0 0 8px; color: var(--muted); font-size: 0.85rem; }

.panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
}

.form { display: grid; gap: 12px; }
.form.row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}
label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #121820;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  color: white;
  font: inherit;
  cursor: pointer;
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.toolbar h2 { margin: 0; }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }
code, .mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
}
.link {
  color: var(--accent);
  word-break: break-all;
  text-decoration: none;
}
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }
.hidden { display: none !important; }

.email-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.email-row code {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1.05rem;
}

.code-box {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, #163526, #122033);
  border: 1px solid #2f5d45;
}
.code-box strong {
  font-size: 1.8rem;
  letter-spacing: 0.12em;
  color: var(--ok);
}

.mail-list { display: grid; gap: 10px; }
.mail-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #121820;
}
.mail-item .head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.mail-item .subj { font-weight: 600; }
.mail-item .meta { color: var(--muted); font-size: 0.82rem; margin-bottom: 8px; }
.mail-item .body {
  white-space: pre-wrap;
  word-break: break-word;
  color: #c9d4e0;
  font-size: 0.9rem;
  max-height: 180px;
  overflow: auto;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #214433;
  color: var(--ok);
  font-size: 0.8rem;
}
.badge.off { background: #3a2430; color: #ffb4b4; }
.chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cred-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.demo-tip {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #2a2416;
  border: 1px solid #5a4a22;
  color: #f0d58c;
  font-size: 0.9rem;
}
.mailbox-wrap { width: min(1200px, calc(100% - 32px)); }
.mailbox-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.3fr);
  gap: 16px;
  align-items: start;
}
.list-panel .mail-list { max-height: 70vh; overflow: auto; }
.mail-item.clickable {
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.mail-item.clickable.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent);
}
.mail-item .preview {
  color: #9aa8b8;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.detail-head h3 { margin: 0; font-size: 1.15rem; }
.code-line { color: var(--ok); }
.links-box ul { margin: 6px 0 0; padding-left: 18px; }
.atts-box, .content-box, .links-box { margin-top: 14px; }
.att-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-top: 8px;
  background: #121820;
}
.att-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.att-preview {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
  background: #000;
}
.mail-frame {
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.mail-detail pre.body {
  white-space: pre-wrap;
  word-break: break-word;
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  max-height: 480px;
  overflow: auto;
}

.btn.danger,
.btn.ghost.danger {
  border-color: #6a3038;
  color: #ffb4b4;
}
.pager-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.inline-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}
.inline-label select {
  border: 1px solid var(--line);
  background: #121820;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
.pager-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-card {
  position: relative;
  width: min(860px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.modal-actions { margin-top: 12px; }
.modal-card textarea {
  margin-top: 10px;
  min-height: 280px;
}

@media (max-width: 860px) {
  .form.row { grid-template-columns: 1fr; }
  .cred-grid, .mailbox-layout { grid-template-columns: 1fr; }
}
