:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1e2933;
  --muted: #667085;
  --border: #d7dde5;
  --accent: #176b87;
  --accent-dark: #0f5268;
  --danger: #b42318;
  --success: #067647;
  --field: #ffffff;
  --table-head: #f1f4f8;
  --status-bg: #eef2f6;
  --status-text: #344054;
}

html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d23;
  --text: #edf2f7;
  --muted: #a6b0bd;
  --border: #2e3844;
  --accent: #4db3d3;
  --accent-dark: #2f94b4;
  --danger: #f97066;
  --success: #47cd89;
  --field: #111820;
  --table-head: #202832;
  --status-bg: #26313d;
  --status-text: #d5dde8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar h1,
.auth-box h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

.topbar p,
.muted {
  margin: 0;
  color: var(--muted);
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.panel,
.auth-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 20px;
}

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

.section-header h2 {
  margin: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-box {
  width: min(460px, 100%);
}

.login-card {
  position: relative;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.14);
}

.login-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.login-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-copy {
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form button {
  width: 100%;
  margin-top: 4px;
}

.stack {
  display: grid;
  gap: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

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

.editor-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-label-row label {
  display: block;
}

.editor-toolbar {
  display: flex;
  gap: 6px;
}

.editor-button {
  min-width: 36px;
  width: 36px;
  min-height: 34px;
  padding: 0;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: var(--field);
}

textarea {
  resize: vertical;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary {
  background: var(--panel);
  color: var(--accent);
}

.secondary:hover {
  color: #fff;
}

.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.danger:hover {
  background: #8f1d14;
}

.actions,
.nav-actions,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-toggle {
  width: 40px;
  min-width: 40px;
  padding: 0;
  background: var(--panel);
  color: var(--accent);
  border-color: var(--border);
  font-size: 20px;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--table-head);
  color: var(--text);
}

.auth-theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
}

.alert {
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-weight: 700;
}

.alert.error {
  color: #7a271a;
  background: #ffebe7;
  border: 1px solid #f4b8ae;
}

.alert.success {
  color: #054f31;
  background: #dcfae6;
  border: 1px solid #a6f4c5;
}

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

.stats div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.stats strong {
  display: block;
  font-size: 24px;
}

.stats span {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  background: var(--table-head);
  font-size: 13px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
}

.email-preview {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

.body-cell {
  min-width: 360px;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--status-bg);
  color: var(--status-text);
  font-size: 12px;
  font-weight: 700;
}

.status.sent {
  color: var(--success);
  background: #dcfae6;
}

.status.failed {
  color: var(--danger);
  background: #ffebe7;
}

.status.generated {
  color: #175cd3;
  background: #dbeafe;
}

details {
  margin-top: 12px;
}

summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

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

  .page {
    width: min(100% - 20px, 1180px);
  }
}
