:root { color-scheme: light; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  margin: 0;
  background: #ffffff;
  color: #1f2340;
}
.wrap { max-width: 1320px; margin: 0 auto; padding: 20px; }
.card {
  background: #ffffff;
  border: 1px solid #dfe4ff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(88, 99, 255, .08);
}
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
a { color: #4752c4; text-decoration: none; }
a:hover { text-decoration: underline; }
input, select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #cfd7ff;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
}
button {
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #5563de, #7a5af8);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  font-family: inherit;
}
button.secondary { background: #eef2ff; color: #343a77; border: 1px solid #cfd7ff; }
button:hover { filter: brightness(0.92); }
button.secondary:hover { background: #dfe7ff; }
button:disabled { opacity: 0.6; cursor: not-allowed; filter: none; }
.muted { color: #636a83; font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid #edf0ff; text-align: left; vertical-align: top; }
th { font-size: 12px; color: #646d92; text-transform: uppercase; letter-spacing: .04em; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-size: 12px;
}
.pill-used { background: #e0f2fe; border-color: #7dd3fc; }
.pre { white-space: pre-wrap; word-break: break-word; }
.msg { border: 1px solid #eef0f6; border-radius: 12px; padding: 12px; background: #fafbff; }
.topbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.topbar form { margin: 0; }
.login-wrap { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; }
.login-card { width: min(100%, 430px); padding: 24px; }
.input-group {
  display: flex;
  align-items: center;
  border: 1px solid #cfd7ff;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.input-group input { border: 0; border-radius: 0; flex: 1 1 auto; min-width: 0; }
.input-suffix {
  background: #f2f5ff;
  color: #4f5680;
  padding: 0 10px;
  font-size: 13px;
  border-left: 1px solid #e3e8ff;
  height: 40px;
  display: flex;
  align-items: center;
  /* 后缀按内容自适应宽度且不换行，长域名时由输入框收缩让位 */
  white-space: nowrap;
  flex: 0 0 auto;
}
.password-row {
  display: flex;
  align-items: center;
  border: 1px solid #cfd7ff;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.password-row input { flex: 1; border: 0; border-radius: 0; }
.pwd-icon-btn {
  width: 42px;
  height: 40px;
  border: 0;
  border-left: 1px solid #e3e8ff;
  border-radius: 0;
  background: #f2f5ff;
  color: #5b6394;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pwd-icon-btn:hover { filter: none; background: #e5ebff; }
.pwd-icon-btn svg { width: 20px; height: 20px; }
.btn-lg { width: 100%; padding: 12px 14px; font-size: 16px; font-weight: 600; }
.account-highlight { font-size: 18px; font-weight: 800; letter-spacing: .2px; }
.toolbar { display: flex; gap: 18px; align-items: center; }
.inbox-title { line-height: 1.6; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding-top: 12px; }
.inbox-table th:nth-child(1), .inbox-table td:nth-child(1) { width: 22%; }
.inbox-table th:nth-child(2), .inbox-table td:nth-child(2) { width: 58%; }
.inbox-table th:nth-child(3), .inbox-table td:nth-child(3) { width: 20%; text-align: right; }
.click-row { cursor: pointer; transition: background-color .15s ease; }
.click-row:hover { background: #eef2ff; }
.meta-grid { display: grid; grid-template-columns: 96px 1fr; gap: 10px 14px; }
.meta-k { color: #5b6474; font-size: 13px; }
.content-card { border: 1px solid #eef0f6; border-radius: 12px; padding: 16px; background: #fff; }
.search-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.search-bar input { max-width: 320px; }
.empty { color: #636a83; padding: 16px 8px; text-align: center; }
.summary { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(0,0,0,.08); font-size: 13px; color: #636a83; }
.admin-row-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 280px;
}
.admin-row-form label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.admin-row-form input[type="text"] { min-width: 100px; flex: 1; }
.actions-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ─── 表格内操作按钮组 ─── */
.row-remark {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #4f5670;
  font-size: 13px;
}
.row-remark.muted-empty { color: #b4bacb; font-style: italic; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 220px;
}
.row-actions > a { display: inline-block; }
button.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  line-height: 1.4;
}
button.btn-danger {
  background: #e74c3c;
  color: #fff;
  border: 1px solid #e74c3c;
}
button.btn-danger:hover:not(:disabled) {
  background: #d44331;
  filter: none;
}

/* ─── 弹窗内只读输入 ─── */
.modal input[readonly] {
  background: #f4f7ff;
  color: #5b6474;
  cursor: default;
}
.modal input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ─── 附件列表 ─── */
.attach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #f4f7ff;
  border: 1px solid #e0e6ff;
  border-radius: 8px;
  font-size: 12px;
}
.attach-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1f2340;
}
.attach-item .size {
  color: #5b6474;
  white-space: nowrap;
}
.attach-item .remove-btn {
  padding: 2px 8px;
  font-size: 11px;
  height: 22px;
  border-radius: 5px;
  background: transparent;
  color: #c0392b;
  border: 1px solid #f5c6c0;
}
.attach-item .remove-btn:hover {
  background: #fdecea;
  filter: none;
}
.attach-item.error {
  background: #fdecea;
  border-color: #f5c6c0;
  color: #c0392b;
}
.attach-item.loading .name::after {
  content: " · 读取中…";
  color: #5b6474;
  font-style: italic;
}

/* ─── 邮件详情页：附件卡片 ─── */
.attach-card { margin-top: 16px; }
.attach-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #1f2340;
  margin-bottom: 10px;
}
.attach-tag {
  display: inline-block;
  padding: 0 6px;
  font-size: 11px;
  color: #5a6dff;
  background: #e8edff;
  border: 1px solid #cfd7ff;
  border-radius: 4px;
}
.attach-download {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, #5563de, #7a5af8);
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
}
.attach-download:hover { filter: brightness(0.92); }

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 35, 64, 0.42);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(100%, 520px);
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: #fff;
  border: 1px solid #dfe4ff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(31, 35, 64, 0.25);
  padding: 22px;
  box-sizing: border-box;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-title { font-size: 17px; font-weight: 800; }
.modal-close {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
  color: #343a77;
  border: 1px solid #cfd7ff;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}
.modal-close:hover { background: #dfe7ff; filter: none; }
.modal label.field-label {
  display: block;
  color: #5b6474;
  font-size: 13px;
  margin: 12px 0 6px;
}
.modal label.field-label:first-of-type { margin-top: 0; }
.modal textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 200px;
  padding: 10px 12px;
  border: 1px solid #cfd7ff;
  border-radius: 10px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  resize: vertical;
}
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.import-result {
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  background: #f4f7ff;
  border: 1px solid #dfe4ff;
  font-size: 13px;
  color: #343a77;
  max-height: 220px;
  overflow: auto;
  display: none;
}
.import-result.show { display: block; }
.import-result ul { margin: 6px 0 0; padding-left: 18px; }
.import-result li { margin: 2px 0; }
.import-result code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  background: #e4eaff;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ─── Pagination ─── */
.pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #eef0f8;
  font-size: 13px;
  color: #5b6474;
}
.pagination .pg-info {
  flex: 1;
  min-width: 180px;
}
.pagination .pg-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pagination .pg-btn {
  min-width: 32px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #cfd7ff;
  background: #fff;
  color: #343a77;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pagination .pg-btn:hover:not(:disabled) {
  background: #eef2ff;
  filter: none;
}
.pagination .pg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pagination .pg-current {
  padding: 0 8px;
  color: #1f2340;
  font-weight: 600;
}
.pagination .pg-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pagination .pg-jump input {
  width: 56px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #cfd7ff;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}
.pagination .pg-size select {
  height: 30px;
  border-radius: 8px;
  border: 1px solid #cfd7ff;
  padding: 0 8px;
  background: #fff;
  font-size: 13px;
}

/* ─── Toast ─── */
.toast-host {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 40px);
}
.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 28px 1fr 24px;
  gap: 10px;
  align-items: start;
  min-width: 280px;
  max-width: 420px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #dfe4ff;
  border-left: 4px solid #5a6dff;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(31, 35, 64, 0.18);
  transform: translateX(20px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.toast.show {
  transform: translateX(0);
  opacity: 1;
}
.toast.leaving {
  transform: translateX(20px);
  opacity: 0;
}
.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: #5a6dff;
  margin-top: 1px;
}
.toast-body { min-width: 0; }
.toast-message {
  font-size: 14px;
  color: #1f2340;
  line-height: 1.5;
  word-break: break-word;
}
.toast-close {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: #9aa3b2;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.toast-close:hover { color: #1f2340; filter: none; }
.toast-detail {
  margin-top: 6px;
  font-size: 12px;
  color: #5b6474;
}
.toast-detail summary {
  cursor: pointer;
  color: #5a6dff;
  user-select: none;
}
.toast-detail pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: #f4f7ff;
  border-radius: 8px;
  max-height: 200px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}
.toast-success { border-left-color: #2ecc71; }
.toast-success .toast-icon { background: #2ecc71; }
.toast-info    { border-left-color: #5a6dff; }
.toast-info    .toast-icon { background: #5a6dff; }
.toast-warn    { border-left-color: #f39c12; }
.toast-warn    .toast-icon { background: #f39c12; }
.toast-error   { border-left-color: #e74c3c; }
.toast-error   .toast-icon { background: #e74c3c; }

@media (max-width: 640px) {
  .wrap { padding: 14px; }
  .card { padding: 14px; }
  .meta-grid { grid-template-columns: 72px 1fr; }
  .modal { padding: 16px; }
  .pagination .pg-info { flex-basis: 100%; }
  .toast-host {
    top: 12px;
    right: 12px;
    left: 12px;
  }
  .toast { max-width: none; }
}
