:root {
  --ink: #172027;
  --muted: #65717a;
  --paper: #f4f5f2;
  --surface: #ffffff;
  --line: #d7dcd8;
  --accent: #b5282f;
  --accent-dark: #861d23;
  --green: #17805b;
  --amber: #b56c08;
  --blue: #246b91;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 108px;
  padding: 22px clamp(20px, 5vw, 72px);
  color: #fff;
  background: #1d272d;
  border-bottom: 5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
h1, h2 { margin: 0; font-family: Georgia, serif; font-weight: 600; letter-spacing: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); }
h2 { font-size: 22px; }
.eyebrow { margin: 0 0 5px; font-size: 11px; font-weight: 700; letter-spacing: 0; color: var(--muted); }
.topbar .eyebrow { color: #bcc8ce; }
.service-state { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); }
.dot.active { background: #46c991; box-shadow: 0 0 0 4px rgb(70 201 145 / 18%); }

main { width: min(1240px, calc(100% - 40px)); margin: 28px auto 60px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  background: var(--surface);
}
.metrics div { min-height: 88px; padding: 18px 22px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span { display: block; color: var(--muted); font-size: 13px; }
.metrics strong { display: block; margin-top: 6px; font-family: Georgia, serif; font-size: 25px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); margin-top: 24px; border: 1px solid var(--line); background: var(--surface); }
.editor, .preview-panel { padding: clamp(22px, 4vw, 38px); }
.preview-panel { border-left: 1px solid var(--line); background: #fafaf7; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 26px; }
.switch-row { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.switch-row input { width: 19px; height: 19px; accent-color: var(--accent); }
label { display: block; margin-bottom: 20px; color: #39464e; font-size: 13px; font-weight: 700; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="datetime-local"], textarea {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bfc8c3;
  border-radius: 3px;
  outline: none;
}
.connection-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(120px, .7fr) minmax(220px, 1fr); gap: 0 18px; }
.connection-grid .wide-field { grid-column: span 3; }
.secure-field { display: flex; align-items: center; gap: 8px; padding-top: 24px; }
.secure-field input { width: 18px; height: 18px; accent-color: var(--accent); }
.real-send { margin-top: 4px; padding: 13px 14px; color: var(--accent-dark); background: #fff4f3; border: 1px solid #e7c0bd; }
.credential-state { padding: 6px 9px; color: var(--amber); background: #fff7e8; border: 1px solid #ecd19d; border-radius: 3px; font-size: 12px; font-weight: 700; }
.credential-state.ready { color: var(--green); background: #edf8f3; border-color: #b9decf; }
button:disabled { cursor: wait; opacity: .65; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(36 107 145 / 12%); }
textarea { resize: vertical; line-height: 1.55; }
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tokens { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -8px; }
.tokens button, .secondary { padding: 7px 10px; color: var(--blue); background: #edf5f8; border: 1px solid #b9d4df; border-radius: 3px; font-size: 12px; font-weight: 700; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; }
.report-help { margin: -8px 0 18px; color: var(--muted); font-size: 13px; }
.actions { min-height: 46px; margin-top: 30px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.actions p { margin: 0; color: var(--green); font-size: 13px; }
.primary { min-height: 42px; padding: 0 18px; color: #fff; background: var(--accent); border: 0; border-radius: 3px; font-weight: 700; }
.primary:hover { background: var(--accent-dark); }
.mail-meta { margin: 24px 0; padding: 12px 0; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; }
.mail-meta span { margin-right: 12px; color: var(--ink); font-weight: 700; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.65 Georgia, serif; }

.activity { margin-top: 24px; padding: clamp(22px, 4vw, 34px); background: var(--surface); border: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
td:first-child { width: 155px; white-space: nowrap; }
td:nth-child(2) { width: 90px; font-weight: 700; }

@media (max-width: 780px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  main { width: min(100% - 24px, 680px); margin-top: 16px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div:nth-child(2) { border-right: 0; }
  .metrics div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { border-left: 0; border-top: 1px solid var(--line); }
  .time-grid { grid-template-columns: 1fr; gap: 0; }
  .connection-grid { grid-template-columns: 1fr; }
  .connection-grid .wide-field { grid-column: span 1; }
  .secure-field { padding-top: 0; }
  .actions { align-items: stretch; flex-direction: column; }
}
