:root {
  --ink: #221309;
  --navy: #150c06;
  --accent: #f08200;
  --accent-dark: #cf6d00;
  --gold: #ffb62e;
  --paper: #faf6ef;
  --surface: #ffffff;
  --line: #e7e2d8;
  --text: #24313d;
  --muted: #64717e;
  --danger: #c0392b;
  --ok: #1f7a3d;
  --radius: 14px;
  --font: "Source Han Sans SC", "Noto Sans SC", "思源黑体", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

.admin-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 50% -120px, rgba(240, 130, 0, 0.18), transparent 60%),
    linear-gradient(160deg, #150c06 0%, #221309 55%, #3a2414 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 40px 36px 34px;
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 16px;
  object-fit: cover;
  background: #fff;
  padding: 4px;
}

.login-card h1 {
  font-size: 21px;
  color: var(--ink);
  margin: 0 0 4px;
}

.login-card .sub {
  color: var(--muted);
  margin: 0 0 26px;
  font-size: 13px;
}

.captcha-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.captcha-row input {
  flex: 1;
  min-width: 0;
}

.captcha-box {
  flex: 0 0 auto;
  width: 150px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.captcha-box svg {
  width: 100%;
  height: 100%;
  display: block;
}

.field {
  text-align: left;
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 600;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 130, 0, 0.14);
}

.btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 11px 20px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s, transform 0.05s;
}

.btn:hover {
  background: var(--accent-dark);
}

.btn:active {
  transform: translateY(1px);
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: var(--paper);
}

.btn-danger {
  background: var(--danger);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.msg {
  display: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.msg.show {
  display: block;
}

.msg.error {
  background: #fdecea;
  color: var(--danger);
}

.msg.ok {
  background: #e9f7ee;
  color: var(--ok);
}

/* ---------- Dashboard ---------- */

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #150c06, #221309);
  color: #e7dfd3;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 16px;
}

.side-brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
}

.side-brand b {
  font-size: 15px;
  color: #fff;
  display: block;
  line-height: 1.2;
}

.side-brand span {
  font-size: 12px;
  color: #c8beb0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: #d8cfc2;
  cursor: pointer;
  margin-bottom: 4px;
  font-size: 14px;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.side-foot {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: #b7aa99;
}

.side-foot a {
  color: #fff;
  text-decoration: underline;
}

.main {
  padding: 26px 30px 40px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
  color: var(--ink);
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 18px rgba(15, 33, 56, 0.05);
}

.mail-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  min-height: 560px;
}

.mail-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.mail-list__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.mail-list__head b {
  color: var(--ink);
}

.mail-list__items {
  overflow-y: auto;
  flex: 1;
  max-height: 600px;
}

.mail-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s;
}

.mail-item:hover {
  background: #fdf6ec;
}

.mail-item.active {
  background: #fff1dd;
  border-left: 3px solid var(--accent);
}

.mail-item.unread .mail-item__from {
  font-weight: 800;
  color: var(--ink);
}

.mail-item.unread .mail-item__dot {
  background: var(--accent);
}

.mail-item__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.mail-item__from {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.mail-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.mail-item__date {
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.mail-item__subject {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.mail-read {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mail-read__head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.mail-read__head h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--ink);
}

.mail-read__meta {
  color: var(--muted);
  font-size: 13px;
}

.mail-read__body {
  padding: 20px 22px;
  flex: 1;
  overflow-wrap: anywhere;
}

.mail-read__body pre {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
}

.mail-read__body iframe {
  width: 100%;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.mail-read__attachments {
  padding: 12px 22px 18px;
  border-top: 1px solid var(--line);
}

.mail-read__attachments a {
  display: inline-block;
  margin: 4px 8px 4px 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--accent-dark);
  background: var(--paper);
}

.mail-read__actions {
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
}

.status-line {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.status-line.error {
  color: var(--danger);
}

.compose {
  max-width: 720px;
}

.compose .field textarea {
  min-height: 260px;
  resize: vertical;
}

.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}

.empty-state h3 {
  color: var(--ink);
  margin-bottom: 8px;
}

.cfg-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.cfg-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
}

.cfg-card h4 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 15px;
}

.cfg-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #e9f7ee;
  color: var(--ok);
}

.badge.no {
  background: #fdecea;
  color: var(--danger);
}

code {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 13px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 18px;
}

.contact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.contact-table th,
.contact-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.contact-table th {
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.contact-table tbody tr:hover {
  background: #fdf8f0;
}

.contact-table .btn {
  margin-right: 4px;
}

.save-from {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 9px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-dark);
  background: #fff7ec;
  white-space: nowrap;
}

.save-from:hover {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 12px;
    overflow-x: auto;
  }
  .side-brand {
    border: 0;
    margin: 0;
    padding: 0 12px 0 0;
  }
  .nav-item {
    width: auto;
    white-space: nowrap;
  }
  .side-foot {
    margin-left: auto;
    border: 0;
    padding: 0 8px;
    white-space: nowrap;
  }
  .main {
    padding: 18px 16px 30px;
  }
  .mail-layout {
    grid-template-columns: 1fr;
  }
  .mail-list__items {
    max-height: 320px;
  }
  .contact-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
