.admin-body {
  --ink: #14131a;
  --ink-soft: #1e1c26;
  --paper: #f7f4ef;
  --paper-2: #efe9e0;
  --line-soft: #e5ded3;
  --text-ink: #1f1c18;
  --muted-ink: #8a8176;
  --gold: #b08a52;
  --gold-deep: #8d6c3c;
  --danger-soft: #b45a55;
  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --font-ui: "Source Sans 3", "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--text-ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 280px),
    radial-gradient(900px 480px at 100% 0%, #efe6d7 0%, transparent 55%),
    var(--paper);
}

.admin-body .muted { color: var(--muted-ink); }
.admin-body h1,
.admin-body h2,
.admin-body .brand-mark {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.admin-login.login-page {
  min-height: 100vh;
  margin: 0;
  background: transparent;
}

.admin-login .login-stage {
  min-height: 100vh;
}

.brand-mark {
  display: inline-block;
  margin: 0;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 600;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background:
    radial-gradient(520px 320px at 0% 0%, rgba(176, 138, 82, 0.14), transparent 60%),
    linear-gradient(180deg, #17151e 0%, #14121a 100%);
  color: #f6f1e8;
  padding: 32px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  overflow: auto;
}

.sidebar-brand {
  display: grid;
  gap: 8px;
  padding: 0 10px 8px;
}

.sidebar-brand .brand-mark {
  letter-spacing: 0.18em;
  font-size: 0.82rem;
  color: rgba(246, 241, 232, 0.55);
}

.sidebar-brand strong {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #f8f1e4, #d8b57a 55%, #f4ebe0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.side-nav {
  display: grid;
  gap: 6px;
  flex: 1;
  align-content: start;
}

.nav-divider {
  height: 1px;
  margin: 18px 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  margin-top: auto;
}

.side-nav .nav-link {
  margin-top: 0;
}

.nav-item {
  border: 0;
  background: transparent;
  color: rgba(246, 241, 232, 0.66);
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  text-decoration: none;
  display: block;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item.active {
  background: rgba(176, 138, 82, 0.14);
  color: #f3e2c2;
  box-shadow: inset 0 0 0 1px rgba(196, 165, 116, 0.22);
}

.nav-link {
  margin-top: auto;
  background: linear-gradient(180deg, #b89963, var(--gold-deep));
  color: #fff !important;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 22px rgba(141, 108, 60, 0.2);
}

.nav-link:hover {
  filter: brightness(1.04);
  color: #fff !important;
  transform: translateY(-1px);
}

.nav-logout {
  margin-top: 8px;
  background: transparent;
  color: rgba(246, 241, 232, 0.72) !important;
  font-weight: 500;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.nav-logout:hover {
  background: rgba(180, 90, 85, 0.14);
  color: #ffc7bc !important;
}

.admin-main {
  padding: 36px 40px 56px;
  min-width: 0;
}

.page-head {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(228, 221, 210, 0.9);
}

.page-head h1 {
  margin: 0 0 8px;
  font-size: 2.15rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.03em;
}

.page-head .muted {
  font-size: 0.95rem;
}

.admin-body .panel.elevate {
  background: rgba(255, 252, 248, 0.9);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  box-shadow: 0 12px 32px rgba(35, 28, 20, 0.04);
  color: var(--text-ink);
  padding: 22px;
  margin-bottom: 18px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 600;
}

.admin-body .form.row {
  grid-template-columns: 1.1fr 1.1fr 1.4fr auto;
  gap: 14px;
}

.admin-body label {
  color: var(--muted-ink);
  font-size: 0.86rem;
}

.admin-body input,
.admin-body textarea,
.admin-body select {
  background: #fff;
  border: 1px solid var(--line-soft);
  color: var(--text-ink);
  border-radius: 12px;
  padding: 11px 13px;
}

.admin-body input:focus,
.admin-body textarea:focus,
.admin-body select:focus {
  outline: none;
  border-color: #c4a574;
  box-shadow: 0 0 0 3px rgba(176, 138, 82, 0.14);
}

.admin-body .btn {
  background: linear-gradient(180deg, #b89963, var(--gold-deep));
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(141, 108, 60, 0.16);
  font-weight: 600;
}

.admin-body .btn.ghost {
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--text-ink);
  box-shadow: none;
  font-weight: 500;
}

.admin-body .btn.ghost.danger {
  border-color: #e8d0cd;
  color: var(--danger-soft);
}

.admin-body .btn.ghost:hover {
  background: rgba(176, 138, 82, 0.06);
}

.admin-body table {
  font-size: 0.9rem;
}

.admin-body table th {
  color: var(--muted-ink);
  font-weight: 600;
  background: #f7f2ea;
  border-bottom: 1px solid var(--line-soft);
}

.admin-body table td,
.admin-body table th {
  padding: 12px 10px;
  border-bottom-color: var(--line-soft);
}

.admin-body table tr:hover td {
  background: rgba(255, 248, 238, 0.65);
}

.admin-body .link {
  color: var(--gold-deep);
}

.admin-body .badge {
  background: #ebf2e7;
  color: #4a6b4f;
}

.admin-body .badge.off {
  background: #f5e7e5;
  color: #9a5753;
}

.admin-body .modal-card {
  background: #fffcf8;
  border-color: var(--line-soft);
  color: var(--text-ink);
  border-radius: 20px;
}

.admin-body .error,
.admin-body .login-error {
  color: var(--danger-soft);
}

.pager-bar {
  padding: 4px 0 8px;
}

.toolbar h2 {
  font-size: 1.3rem;
}

.tab-bar {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--line-soft);
  background: rgba(255, 252, 247, 0.7);
  color: var(--text-ink);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
}

.tab-btn.active {
  background: linear-gradient(180deg, #ad8d5d, var(--gold-deep));
  border-color: transparent;
  color: #fff;
}

.unread-chip {
  background: #e25b2a !important;
  color: #fff !important;
  border: 0 !important;
  min-width: 1.4em;
  text-align: center;
}

.unread-badge {
  background: #e25b2a !important;
  color: #fff !important;
}

.mail-item.is-unread {
  border-color: #e2a06a;
  background: #fff7ee;
  box-shadow: inset 3px 0 0 #e08a1e;
}

.mail-item.is-unread .subj {
  font-weight: 700;
  color: #8a4b12;
}

.btn.active-box {
  border-color: var(--gold);
  color: var(--gold-deep);
  background: #f7eee0;
}

.chat-form {
  max-width: 720px;
}

.mailbox-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  min-height: 100vh;
  align-items: stretch;
}

.mailbox-shell .mailbox-main {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 28px 28px 48px;
}

.mail-right-col {
  display: grid;
  gap: 16px;
  min-width: 0;
  align-content: start;
}

.chat-preview-panel {
  border-color: #e2c48a !important;
  background: linear-gradient(180deg, #fff8ec, #fffdf9) !important;
}

.latest-chat-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.latest-chat-item {
  width: 100%;
  text-align: left;
  border: 1px solid #efd4a4;
  background: #fffaf0;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: grid;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.latest-chat-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(154, 123, 79, 0.12);
}

.latest-chat-item.is-unread {
  border-color: #e39a3c;
  background: linear-gradient(135deg, #fff3d6, #ffe8b8);
  box-shadow: inset 3px 0 0 #e08a1e;
}

.latest-chat-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.latest-chat-top strong {
  color: #8a5a16;
  font-size: 0.92rem;
}

.latest-chat-subject {
  font-weight: 600;
  color: #5c3d12;
}

.latest-chat-body,
.chat-preview-text,
.chat-body-text {
  color: #c45c16 !important;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.latest-chat-body {
  font-size: 0.95rem;
}

.latest-chat-time {
  color: #a8895c;
  font-size: 0.78rem;
}

.sender-row {
  display: grid;
  gap: 8px;
}

.sender-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sender-line .btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.chat-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.chat-item-main {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  font: inherit;
  width: 100%;
}

.chat-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

.mini-add-friend {
  padding: 4px 8px !important;
  font-size: 0.78rem !important;
  white-space: nowrap;
}

.latest-chat-open {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  font: inherit;
  width: 100%;
  display: grid;
  gap: 6px;
}

.friend-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 14px;
  background: linear-gradient(180deg, #1b181f 0%, #121016 100%);
  color: #f4efe7;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.friend-rail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 4px 6px;
}

.friend-rail-head strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.friend-rail-head .muted,
.friend-rail .muted {
  color: rgba(244, 239, 231, 0.55);
}

.friend-rail-form {
  display: grid;
  gap: 8px;
  padding: 0 2px;
}

.friend-rail-form input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #f4efe7;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.friend-rail-form input::placeholder {
  color: rgba(244, 239, 231, 0.35);
}

.friend-rail-form .btn {
  width: 100%;
}

.friend-rail-form .error {
  min-height: 1.1em;
  margin: 0;
  font-size: 0.82rem;
}

.friend-rail-scroll {
  flex: 1;
  overflow: auto;
  display: grid;
  gap: 8px;
  align-content: start;
  padding-right: 2px;
}

.rail-empty {
  text-align: center;
  padding: 24px 8px;
  line-height: 1.6;
  font-size: 0.9rem;
}

.friend-nav-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: stretch;
}

.friend-nav-main {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  text-align: left;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  display: grid;
  gap: 4px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.friend-nav-main:hover {
  background: linear-gradient(135deg, rgba(154, 123, 79, 0.28), rgba(154, 123, 79, 0.08));
  border-color: rgba(196, 165, 116, 0.28);
}

.friend-remark {
  font-weight: 600;
  font-size: 0.95rem;
  color: #f7e7c8;
}

.friend-email {
  font-size: 0.78rem;
  color: rgba(244, 239, 231, 0.62);
  word-break: break-all;
  line-height: 1.35;
}

.friend-nav-del {
  border: 0;
  background: transparent;
  color: rgba(244, 239, 231, 0.35);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 8px;
}

.friend-nav-del:hover {
  color: #ffb4b4;
  background: rgba(255, 255, 255, 0.04);
}

.admin-body .email-row code {
  background: #fffdf9;
  border-color: var(--line-soft);
  color: var(--text-ink);
}

@media (max-width: 1100px) {
  .mailbox-shell {
    grid-template-columns: 1fr;
  }

  .friend-rail {
    position: relative;
    height: auto;
    max-height: none;
    order: -1;
  }

  .friend-rail-scroll {
    max-height: 260px;
  }

  .mailbox-shell .mailbox-main {
    padding: 18px 16px 40px;
  }

  .mail-right-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    padding: 16px;
  }

  .side-nav {
    grid-template-columns: 1fr 1fr;
  }

  .nav-divider {
    grid-column: 1 / -1;
  }

  .admin-main {
    padding: 18px 16px 40px;
  }

  .admin-body .form.row {
    grid-template-columns: 1fr;
  }
}
