:root {
  color-scheme: light;
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-muted: #f6f6f6;
  --line: #cfcfcf;
  --line-strong: #c7c7c7;
  --text: #20242a;
  --muted: #69727d;
  --accent: #3f7fb7;
  --danger: #b23a3a;
  --success: #16835c;
  --page-max: 1180px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

.admin-header {
  width: calc(100% - 32px);
  max-width: var(--page-max);
  min-height: 48px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #f4f4f4;
  color: var(--text);
  border: 1px solid #d1d1d1;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.admin-header h1 {
  font-size: 17px;
  line-height: 1;
  font-weight: 700;
}

.admin-header span {
  display: none;
}

.admin-header nav {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.admin-header a {
  color: #3f4751;
  text-decoration: none;
}

.admin-header a:hover {
  color: #11151b;
}

button {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid #2f6fa7;
  border-radius: 0;
  background: #2f6fa7;
  color: #ffffff;
  font: inherit;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  box-shadow: none;
}

button:hover {
  border-color: #285f91;
  background: #285f91;
  color: #ffffff;
}

button:disabled {
  background: #eeeeee;
  color: #8a8f96;
  cursor: not-allowed;
  opacity: 1;
}

.admin-header button {
  min-height: 28px;
}

.admin-shell {
  width: calc(100% - 32px);
  max-width: var(--page-max);
  margin: 16px auto 30px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.form-panel,
.data-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}

.form-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.note-form-panel,
.full-form-panel {
  grid-column: 1 / -1;
}

.form-panel .section-title,
.form-panel button,
.secret-box,
.note-form-panel label,
.note-form-panel .form-note,
.full-form-panel label,
.result-box,
.form-actions {
  grid-column: 1 / -1;
}

.form-note {
  align-self: end;
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
}

.mfa-status {
  grid-column: 1 / -1;
  padding: 0;
}

.mfa-status.enabled {
  color: var(--success);
}

.mfa-secret {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 8px 0;
  padding: 7px 9px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
}

#mfaSetupDetails a {
  color: var(--accent);
}

#mfaRecoveryCodes pre {
  margin: 9px 0 0;
  white-space: pre-wrap;
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.6;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-actions button {
  grid-column: auto;
}

.section-title {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2 {
  font-size: 14px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 5px;
  color: #505b66;
  font-size: 11px;
  font-weight: 400;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #ffffff;
  font: inherit;
  box-shadow: none;
}

input {
  min-height: 30px;
  padding: 0 8px;
}

select {
  min-height: 30px;
  padding: 0 8px;
}

textarea {
  min-height: 116px;
  resize: vertical;
  padding: 8px;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #7fa7d7;
  outline: 1px solid #7fa7d7;
  box-shadow: none;
}

.data-panel {
  margin-top: 12px;
}

.smtp-pool-panel {
  margin-top: 0;
}

.smtp-pool-summary {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.smtp-pool-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.email-smtp-dialog {
  width: min(760px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: visible;
  color: inherit;
  background: transparent;
  border: 0;
}

.email-smtp-dialog::backdrop {
  background: rgba(24, 31, 38, .46);
}

.email-smtp-dialog-panel {
  max-height: calc(100dvh - 32px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid #aeb5bc;
  box-shadow: 0 10px 28px rgba(20, 31, 41, .18);
}

.email-smtp-dialog-heading {
  position: sticky;
  top: -14px;
  z-index: 2;
  padding: 0 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.dialog-close {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: #68717b;
  font-size: 22px;
  line-height: 1;
}

.dialog-close:hover {
  border-color: transparent;
  background: #edf0f2;
  color: #20242a;
}

.email-smtp-dialog-actions {
  justify-content: flex-end;
}

.smtp-pool-table {
  min-width: 960px;
}

.smtp-pool-table th:nth-child(1) {
  width: 19%;
}

.smtp-pool-table th:nth-child(2) {
  width: 18%;
}

.smtp-pool-table th:nth-child(3) {
  width: 15%;
}

.smtp-pool-table th:nth-child(4) {
  width: 18%;
}

.smtp-pool-table th:nth-child(5) {
  width: 18%;
}

.smtp-record-cell,
.smtp-error-cell,
.smtp-muted-cell {
  white-space: pre-line;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.smtp-error-cell {
  color: var(--danger);
}

.smtp-muted-cell {
  color: var(--muted);
}

.smtp-account-status.cooling {
  color: #9a6800;
}

.smtp-account-actions {
  min-width: 188px;
}

.data-panel .section-title {
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

th {
  background: var(--surface-muted);
  color: #616975;
  font-size: 11px;
  font-weight: 400;
}

td:last-child,
th:last-child {
  border-right: 0;
}

tbody tr:hover td {
  background: #f2f6fb;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.actions button {
  min-height: 26px;
  padding: 0 8px;
}

.actions .danger,
.danger-button {
  border-color: #2f6fa7;
  background: #2f6fa7;
  color: #ffffff;
}

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

.deleted-orders-table {
  min-width: 0;
  table-layout: fixed;
  font-size: 11px;
}

.deleted-orders-table th:nth-child(1) { width: 3.5%; }
.deleted-orders-table th:nth-child(2) { width: 10%; }
.deleted-orders-table th:nth-child(3) { width: 23%; }
.deleted-orders-table th:nth-child(4) { width: 7%; }
.deleted-orders-table th:nth-child(5) { width: 6.5%; }
.deleted-orders-table th:nth-child(6) { width: 17%; }
.deleted-orders-table th:nth-child(7) { width: 5.5%; }
.deleted-orders-table th:nth-child(8) { width: 9%; }
.deleted-orders-table th:nth-child(9) { width: 12%; }
.deleted-orders-table th:nth-child(10) { width: 6.5%; }

.deleted-orders-table th,
.deleted-orders-table td {
  padding: 5px 6px;
}

.deleted-orders-table td {
  line-height: 1.35;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.deleted-orders-table td.actions {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
}

.deleted-orders-table td.actions button {
  width: 100%;
  min-width: 0;
  min-height: 24px;
  padding: 0 3px;
  font-size: 11px;
  white-space: nowrap;
}

.deleted-order-info > div:first-child,
.deleted-order-contact > div:first-child {
  color: #152433;
  font-weight: 600;
}

.deleted-order-info > div:not(:first-child),
.deleted-order-contact > div:not(:first-child),
.deleted-order-deletion > div:not(:first-child) {
  color: var(--muted);
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  min-height: 44px;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
  color: var(--muted);
  font-size: 12px;
}

.admin-pagination button {
  min-width: 62px;
  min-height: 30px;
  border-color: #b9c5d0;
  background: #ffffff;
  color: #285c8c;
}

.admin-pagination button:disabled {
  border-color: #d8dde2;
  background: #f3f4f5;
  color: #a1a8af;
}

.status {
  font-weight: 400;
}

.status.on {
  color: var(--success);
}

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

.secret-box {
  padding: 10px;
  border: 1px solid #d7c18d;
  background: #fff8e8;
  color: #6c4d0e;
  overflow-wrap: anywhere;
  font-family: Consolas, monospace;
}

.result-box {
  padding: 10px;
  border: 1px solid #cdd7e2;
  background: #f8fbff;
  color: #31516a;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message {
  position: sticky;
  bottom: 12px;
  min-height: 20px;
  margin-top: 12px;
  padding: 8px 10px;
  color: #31516a;
}

.hidden {
  display: none !important;
}

@media (max-width: 800px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .form-panel {
    grid-template-columns: 1fr;
  }

  .admin-header {
    width: 100%;
    min-height: 50px;
    padding: 0 12px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .admin-shell {
    width: calc(100% - 16px);
  }

  .deleted-orders-table {
    min-width: 980px;
  }

  .smtp-pool-heading-actions {
    gap: 6px;
  }

  .smtp-pool-summary {
    white-space: normal;
    text-align: right;
  }

  .email-smtp-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .email-smtp-dialog-panel {
    max-height: calc(100dvh - 16px);
  }
}
