:root {
  --pure-0: #ffffff;
  --gray-2: #fbf7f2;
  --gray-5: #f6f6f6;
  --gray-10: #e6e6e6;
  --gray-20: #cccccc;
  --gray-50: #777777;
  --gray-70: #555555;
  --gray-80: #333333;
  --brand-cream: #f8f2ed;
  --brand-green: #008f6b;
  --brand-magenta: #d41467;
  --brand-purple: #5b2387;
  --brand-purple-dark: #321257;
  --brand-yellow: #ffcd07;
  --blue-vivid: #135184;
  --red-vivid: #c5164e;
  --red-soft: #fde0db;
  --green-soft: #e6f6ef;
  --yellow-soft: #fff6cf;
  --focus-ring: #ffcd07;
  color-scheme: light;
  font-family: Rawline, "Rawline", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--brand-cream);
  color: var(--gray-80);
  font-family: Rawline, "Rawline", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-page {
  position: relative;
  display: grid;
  min-height: 100vh;
  overflow: hidden;
  background: var(--brand-cream);
}

.login-page::before,
.login-page::after {
  position: absolute;
  z-index: 0;
  content: "";
  pointer-events: none;
}

.login-page::before {
  top: -6.5rem;
  right: -8rem;
  width: 28rem;
  height: 12rem;
  border-bottom-left-radius: 18rem 9rem;
  background: linear-gradient(90deg, var(--brand-green) 0 44%, var(--brand-purple) 44% 100%);
}

.login-page::after {
  right: -4rem;
  bottom: -6rem;
  left: -4rem;
  height: 11rem;
  background: linear-gradient(176deg, transparent 0 25%, var(--brand-yellow) 25% 36%, var(--brand-green) 36% 100%);
  clip-path: polygon(0 45%, 14% 30%, 32% 48%, 50% 64%, 68% 52%, 84% 40%, 100% 55%, 100% 100%, 0 100%);
}

.login-layout {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: min(100%, 31rem);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--brand-purple) 18%, var(--gray-10));
  border-radius: 8px;
  background: var(--pure-0);
  box-shadow: 0 14px 34px rgb(50 18 87 / 0.18);
}

.login-card__header {
  padding: 1.6rem 1.5rem 1.1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--brand-purple) 12%, var(--gray-10));
  background: linear-gradient(180deg, var(--pure-0), var(--brand-cream));
  text-align: center;
}

.login-card__mark {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 0.7rem;
  border: 2px solid color-mix(in srgb, var(--brand-magenta) 44%, transparent);
  border-radius: 50%;
  background: var(--pure-0);
  color: var(--brand-purple);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}

.login-card h1 {
  margin: 0;
  color: var(--brand-purple-dark);
  font-size: 1.35rem;
  line-height: 1.25;
}

.login-card p {
  margin: 0.25rem 0 0;
  color: var(--gray-70);
}

.login-card__body,
.field-stack {
  display: grid;
  gap: 0.45rem;
}

.login-card__body {
  gap: 1rem;
  padding: 1.35rem 1.5rem 1.5rem;
}

.login-field {
  display: grid;
  gap: 0.45rem;
}

label {
  color: var(--gray-80);
  font-weight: 700;
}

.text-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--gray-20);
  border-radius: 4px;
  background: var(--pure-0);
  color: var(--gray-80);
}

select.text-input {
  appearance: auto;
}

.text-input:focus-visible,
.primary-action:focus-visible,
.secondary-action:focus-visible,
.step-nav__item:focus-visible,
.placeholder-token:focus-visible,
.confirm-line input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.text-input[aria-invalid="true"] {
  border-color: var(--red-vivid);
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
}

.primary-action {
  border: 1px solid var(--brand-purple);
  background: var(--brand-purple);
  color: var(--pure-0);
}

.primary-action:hover:not(:disabled) {
  border-color: var(--brand-purple-dark);
  background: var(--brand-purple-dark);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.secondary-action {
  border: 1px solid var(--brand-purple);
  background: var(--pure-0);
  color: var(--brand-purple);
}

.secondary-action:hover:not(:disabled) {
  background: var(--brand-cream);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid color-mix(in srgb, var(--brand-purple) 14%, var(--gray-10));
  background: color-mix(in srgb, var(--brand-cream) 94%, var(--pure-0));
}

.app-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 92rem);
  margin: 0 auto;
  padding: 0.85rem 1rem;
}

.app-header__brand {
  display: inline-flex;
  flex: 1 1 24rem;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: var(--brand-purple-dark);
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.app-header__title {
  flex: 1 1 12rem;
  min-width: 10rem;
}

.session-user {
  color: var(--gray-70);
  font-size: 0.875rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr);
  gap: 1rem;
  width: min(100%, 92rem);
  margin: 0 auto;
  padding: 1rem;
}

.step-nav {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  display: grid;
  gap: 0.5rem;
}

.step-nav__item {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.65rem;
  align-items: center;
  min-height: 3rem;
  padding: 0.55rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--gray-70);
  text-decoration: none;
}

.step-nav__item span {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--gray-10);
  color: var(--gray-80);
  font-weight: 800;
}

.step-nav__item.is-active,
.step-nav__item:hover {
  border-color: color-mix(in srgb, var(--brand-purple) 22%, var(--gray-10));
  background: var(--pure-0);
  color: var(--brand-purple-dark);
}

.step-nav__item.is-active span {
  background: var(--brand-purple);
  color: var(--pure-0);
}

.workspace {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.workspace-hero,
.panel {
  border: 1px solid color-mix(in srgb, var(--brand-purple) 14%, var(--gray-10));
  border-radius: 8px;
  background: var(--pure-0);
  box-shadow: 0 10px 28px rgb(50 18 87 / 0.08);
}

.workspace-hero {
  display: grid;
  gap: 1rem;
  padding: 1.4rem;
  background: linear-gradient(90deg, var(--pure-0), var(--brand-cream));
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--brand-magenta);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workspace-hero h1,
.panel h2 {
  margin: 0;
  color: var(--brand-purple-dark);
  line-height: 1.18;
}

.workspace-hero h1 {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2.15rem);
}

.panel h2 {
  font-size: 1.35rem;
}

.campaign-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.campaign-stats div {
  min-height: 5.25rem;
  padding: 0.85rem;
  border-left: 4px solid var(--brand-purple);
  background: var(--gray-2);
}

.campaign-stats div:nth-child(2) {
  border-left-color: var(--brand-green);
}

.campaign-stats div:nth-child(3) {
  border-left-color: var(--brand-magenta);
}

.campaign-stats div:nth-child(4) {
  border-left-color: var(--blue-vivid);
}

.campaign-stats span {
  display: block;
  color: var(--brand-purple-dark);
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
}

.campaign-stats small {
  display: block;
  margin-top: 0.3rem;
  color: var(--gray-70);
  font-weight: 700;
}

.panel {
  display: grid;
  gap: 1.1rem;
  padding: 1.1rem;
  scroll-margin-top: 6rem;
}

.panel__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid color-mix(in srgb, var(--brand-purple) 12%, var(--gray-10));
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--blue-vivid) 28%, var(--gray-20));
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue-vivid) 8%, var(--pure-0));
  color: var(--blue-vivid);
  font-size: 0.85rem;
  font-weight: 800;
}

.state-pill.is-ready {
  border-color: color-mix(in srgb, var(--brand-green) 40%, var(--gray-20));
  background: var(--green-soft);
  color: #005f49;
}

.state-pill.is-error {
  border-color: color-mix(in srgb, var(--red-vivid) 40%, var(--gray-20));
  background: var(--red-soft);
  color: var(--red-vivid);
}

.data-grid,
.mapping-grid,
.sender-grid,
.link-grid {
  display: grid;
  gap: 0.85rem;
}

.data-grid {
  grid-template-columns: minmax(16rem, 1.2fr) minmax(12rem, 1fr) minmax(12rem, 1fr);
}

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

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

.upload-zone {
  display: grid;
  min-height: 8.5rem;
  border: 2px dashed color-mix(in srgb, var(--brand-purple) 38%, var(--gray-20));
  border-radius: 8px;
  background: var(--gray-2);
}

.upload-zone.is-dragover {
  border-color: var(--brand-green);
  background: var(--green-soft);
}

.upload-zone label {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.25rem;
  min-height: 6rem;
  padding: 1rem;
  color: var(--brand-purple-dark);
  text-align: center;
}

.upload-zone label strong {
  font-size: 1.05rem;
}

.upload-zone label span,
.upload-zone p {
  color: var(--gray-70);
  font-size: 0.9rem;
}

.upload-zone p {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--gray-10);
  overflow-wrap: anywhere;
}

.table-shell {
  max-height: 22rem;
  overflow: auto;
  border: 1px solid var(--gray-10);
  border-radius: 8px;
  background: var(--pure-0);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 44rem;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--gray-5);
  color: var(--gray-80);
  font-size: 0.82rem;
  text-transform: uppercase;
}

td {
  color: var(--gray-70);
  font-size: 0.92rem;
}

.row-error {
  color: var(--red-vivid);
  font-weight: 800;
}

.template-actions,
.send-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.composer-layout,
.review-layout {
  display: grid;
  gap: 1rem;
}

.composer-layout {
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 22rem);
}

.composer-main {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}

.body-editor {
  min-height: 24rem;
  resize: vertical;
  line-height: 1.55;
}

.placeholder-panel {
  align-self: start;
  display: grid;
  gap: 0.85rem;
  padding: 0.95rem;
  border: 1px solid color-mix(in srgb, var(--brand-purple) 14%, var(--gray-10));
  border-radius: 8px;
  background: var(--gray-2);
}

.placeholder-panel h3 {
  margin: 0;
  color: var(--brand-purple-dark);
  font-size: 1rem;
}

.placeholder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.placeholder-token {
  min-height: 2rem;
  padding: 0.2rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--brand-purple) 30%, var(--gray-20));
  border-radius: 999px;
  background: var(--pure-0);
  color: var(--brand-purple);
  font-size: 0.86rem;
  font-weight: 800;
}

.placeholder-token:hover {
  background: var(--brand-cream);
}

.review-layout {
  grid-template-columns: minmax(16rem, 20rem) minmax(0, 1fr);
}

.review-checks {
  display: grid;
  gap: 0.55rem;
  align-self: start;
}

.check-item {
  display: grid;
  grid-template-columns: 1.7rem 1fr;
  gap: 0.55rem;
  align-items: start;
  min-height: 3rem;
  padding: 0.65rem;
  border-left: 4px solid var(--gray-20);
  background: var(--gray-2);
}

.check-item span {
  display: inline-grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--gray-20);
  color: var(--gray-80);
  font-weight: 900;
}

.check-item strong {
  display: block;
  color: var(--gray-80);
  line-height: 1.25;
}

.check-item small {
  display: block;
  margin-top: 0.15rem;
  color: var(--gray-70);
  line-height: 1.35;
}

.check-item.is-ok {
  border-left-color: var(--brand-green);
  background: var(--green-soft);
}

.check-item.is-ok span {
  background: var(--brand-green);
  color: var(--pure-0);
}

.check-item.is-error {
  border-left-color: var(--red-vivid);
  background: var(--red-soft);
}

.check-item.is-error span {
  background: var(--red-vivid);
  color: var(--pure-0);
}

.preview-panel {
  min-width: 0;
  border: 1px solid var(--gray-10);
  border-radius: 8px;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--gray-10);
  background: var(--gray-5);
}

.preview-toolbar label {
  flex: 0 0 auto;
}

.preview-toolbar select {
  flex: 1 1 16rem;
}

.email-preview {
  min-height: 24rem;
  padding: 1rem;
  background: var(--pure-0);
}

.email-preview h3 {
  margin: 0 0 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--gray-10);
  color: var(--brand-purple-dark);
  font-size: 1.15rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.email-preview div {
  color: var(--gray-80);
  overflow-wrap: anywhere;
}

.send-panel {
  display: grid;
  grid-template-columns: minmax(14rem, 20rem) minmax(16rem, 1fr) auto;
  gap: 0.85rem;
  align-items: end;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--brand-purple) 14%, var(--gray-10));
  border-radius: 8px;
  background: var(--gray-2);
}

.confirm-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: center;
  min-height: 2.75rem;
  font-weight: 700;
}

.confirm-line input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--brand-purple);
}

.status-message {
  min-height: 0;
}

.status-message__alert,
.status-message__success,
.status-message__info {
  margin: 0;
  padding: 0.75rem;
  border-left: 4px solid var(--blue-vivid);
  background: color-mix(in srgb, var(--blue-vivid) 8%, var(--pure-0));
  color: var(--gray-80);
}

.status-message__alert {
  border-left-color: var(--red-vivid);
  background: var(--red-soft);
}

.status-message__success {
  border-left-color: var(--brand-green);
  background: var(--green-soft);
}

.status-message__info {
  border-left-color: var(--brand-yellow);
  background: var(--yellow-soft);
}

@media (max-width: 980px) {
  .app-shell,
  .composer-layout,
  .review-layout,
  .send-panel {
    grid-template-columns: 1fr;
  }

  .step-nav {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .step-nav__item {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .data-grid,
  .mapping-grid,
  .sender-grid,
  .link-grid,
  .campaign-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header__inner,
  .app-shell {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }

  .workspace-hero,
  .panel {
    padding: 0.9rem;
  }

  .data-grid,
  .mapping-grid,
  .sender-grid,
  .link-grid,
  .campaign-stats,
  .step-nav {
    grid-template-columns: 1fr;
  }

  .template-actions,
  .send-actions {
    width: 100%;
  }

  .template-actions button,
  .send-actions button {
    flex: 1 1 11rem;
  }
}
