:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8dee6;
  --accent: #1769aa;
  --accent-dark: #0f4f82;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --ok: #067647;
  --ok-bg: #ecfdf3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 28px auto 40px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.status-pill {
  min-width: 128px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px 12px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.status-pill.loaded {
  border-color: #a6f4c5;
  background: var(--ok-bg);
  color: var(--ok);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  margin-bottom: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.step {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

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

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

.field span,
.metric-box span {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.span-2 {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #b9c2cf;
  border-radius: 6px;
  background: #fff;
  padding: 10px 11px;
  color: var(--ink);
}

.email-builder {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  align-items: center;
}

.email-builder input {
  border-radius: 6px 0 0 6px;
}

.email-builder span {
  display: grid;
  min-height: 43px;
  place-items: center;
  border: 1px solid #b9c2cf;
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: #eef2f6;
  padding: 0 12px;
  color: #344054;
  font-weight: 700;
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr)) auto;
  gap: 10px;
}

.secondary-button {
  border: 1px solid #b9c2cf;
  border-radius: 6px;
  background: #fff;
  color: #344054;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(23, 105, 170, 0.16);
  border-color: var(--accent);
}

select:disabled {
  background: #eef2f6;
  color: var(--muted);
}

.metric-box {
  display: grid;
  align-content: center;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.metric-box strong {
  margin-top: 4px;
  font-size: 24px;
}

.metric-box.muted strong {
  font-size: 18px;
}

.delivery-status {
  border-width: 2px;
}

.delivery-status strong {
  font-size: 22px;
}

.delivery-status.immediate {
  border-color: #fda29b;
  background: var(--danger-bg);
}

.delivery-status.immediate strong {
  color: var(--danger);
}

.delivery-status.scheduled {
  border-color: #75e0a7;
  background: var(--ok-bg);
}

.delivery-status.scheduled strong {
  color: var(--ok);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag-list button {
  border: 1px solid #b7d4ea;
  border-radius: 6px;
  background: #f2f8fd;
  color: var(--accent-dark);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.message {
  margin-top: 14px;
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 12px;
}

.hidden {
  display: none;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 18px;
}

pre {
  min-height: 180px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
  white-space: pre-wrap;
}

.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.check-list li.ok {
  color: var(--ok);
}

.check-list li.error {
  color: var(--danger);
}

.check-list li.warning {
  color: var(--danger);
  font-weight: 700;
}

.action-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 14px;
  backdrop-filter: blur(10px);
}

.action-bar button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 700;
}

.action-bar button:disabled {
  background: #98a2b3;
  cursor: not-allowed;
}

.result {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 760px) {
  .page-header,
  .action-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .preview-grid,
  .schedule-grid {
    grid-template-columns: 1fr;
  }
}
