:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --ink: #1f2933;
  --muted: #687482;
  --line: #dde3ea;
  --teal: #157a73;
  --teal-soft: #e4f5f2;
  --blue: #315fbc;
  --amber: #9a6507;
  --red: #b54045;
  --shadow: 0 12px 30px rgba(31, 41, 51, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(21, 122, 115, 0.14);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 700;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.top-actions,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  min-height: 82px;
}

.topbar h1,
.section-heading h2,
.login-card h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(340px, 1fr);
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.config-panel,
.mailbox-panel,
.messages-panel {
  grid-column: 1 / -1;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h2,
.login-card h2 {
  font-size: 18px;
  line-height: 1.25;
}

.primary-btn {
  padding: 0 16px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.ghost-btn,
.danger-btn {
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.danger-btn {
  color: var(--red);
}

.small-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.metric-row,
.dns-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.dns-grid {
  grid-template-columns: repeat(3, 1fr);
}

.metric,
.dns-grid div {
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric strong,
.dns-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 24px;
}

.dns-grid strong {
  font-size: 15px;
}

.metric span,
.dns-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.mailbox-controls {
  grid-template-columns: minmax(120px, 0.5fr) minmax(220px, 1fr) repeat(4, auto);
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

.align-end {
  align-self: end;
}

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.address-cell {
  font-family: "Cascadia Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 128px;
}

.code-box {
  margin: 14px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1f2933;
  color: #e8edf2;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

.mail-list {
  display: grid;
  gap: 10px;
}

.mail-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.mail-item h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.mail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.mail-body {
  margin: 10px 0 0;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  color: #334155;
  font-size: 13px;
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 140px);
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #1f2933;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .config-panel,
  .mailbox-panel,
  .messages-panel {
    grid-column: auto;
  }

  .metric-row,
  .dns-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mailbox-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .top-actions,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .form-grid,
  .mailbox-controls,
  .metric-row,
  .dns-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }
}
