:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9e0d7;
  --accent: #186a5b;
  --accent-dark: #104b40;
  --warn: #9f3a27;
  --shadow: 0 18px 40px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.admin-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.status {
  max-width: 360px;
  white-space: pre-line;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  border-color: rgba(159, 58, 39, 0.35);
  color: var(--warn);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 18px;
  align-items: start;
}

.panel,
.results,
.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cbd5c8;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 156px;
}

select {
  min-height: 48px;
}

.scope-input {
  min-height: 74px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 106, 91, 0.12);
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 7px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  min-height: 46px;
  background: var(--accent);
  color: #fff;
}

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

.primary-button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 8px 11px;
}

.note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.filter-count {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.results {
  min-height: 620px;
  overflow: hidden;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.results-actions,
.import-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-filter span {
  white-space: nowrap;
}

.inline-filter select {
  min-width: 120px;
  min-height: 42px;
  padding: 8px 10px;
}

.message-list {
  display: grid;
}

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

.message-card {
  border-bottom: 1px solid var(--line);
}

.message-card.unread {
  background: #f0f8f5;
}

.message-card.expanded {
  background: #f7fbf8;
}

.message-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  gap: 14px;
  padding: 16px 18px;
  text-align: left;
}

.message-summary:hover {
  background: rgba(24, 106, 91, 0.06);
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.sender {
  color: #334155;
  font-weight: 700;
}

.subject {
  margin-bottom: 7px;
  font-size: 17px;
  line-height: 1.35;
}

.preview {
  display: -webkit-box;
  margin-bottom: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.toggle-text {
  align-self: start;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.message-detail {
  border-top: 1px solid var(--line);
  padding: 16px 18px 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0 0 14px;
}

.detail-grid div {
  min-width: 0;
}

.detail-grid dt {
  margin-bottom: 4px;
  color: #526071;
  font-size: 13px;
  font-weight: 700;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.detail-body {
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #2f3b48;
  font-family:
    "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  margin: 0;
  padding: 14px;
}

.import-dialog {
  width: min(820px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.import-dialog::backdrop {
  background: rgba(31, 41, 51, 0.32);
}

.import-box {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.import-actions {
  justify-content: flex-end;
}

#importText {
  min-height: 260px;
  white-space: pre;
  overflow: auto;
}

.table-wrap {
  overflow: auto;
}

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

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

.account-table th {
  color: #344054;
  font-weight: 800;
  white-space: nowrap;
}

.mono-cell {
  max-width: 260px;
  overflow-wrap: anywhere;
  font-family:
    Consolas, "Segoe UI Mono", "Microsoft YaHei", monospace;
  font-size: 13px;
}

.status-ok,
.status-new {
  white-space: nowrap;
  font-weight: 800;
}

.status-ok {
  color: var(--accent);
}

.status-new {
  color: var(--warn);
}

.table-action {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--accent);
  font-weight: 800;
  padding: 4px 10px;
  text-decoration: none;
  white-space: nowrap;
}

.table-action:hover {
  border-color: var(--accent);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 18px;
}

#exportText {
  min-height: 300px;
  white-space: pre;
  overflow: auto;
  font-family:
    Consolas, "Segoe UI Mono", "Microsoft YaHei", monospace;
  font-size: 13px;
}

@media (max-width: 860px) {
  .toolbar,
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .grid-two {
    grid-template-columns: 1fr;
  }

  .message-summary,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .results-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .results {
    min-height: 360px;
  }
}
