:root {
  --ink: #202936;
  --muted: #607086;
  --paper: #fffaf3;
  --card: rgba(255, 252, 247, 0.92);
  --line: #dfd0bf;
  --green: #087961;
  --green-soft: #d6f2e8;
  --danger: #a31632;
  --shadow: 0 26px 80px rgba(50, 38, 24, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 216, 166, 0.34), transparent 34rem),
    linear-gradient(135deg, #fbf4e9 0%, #f6efe4 48%, #eef6ee 100%);
  font-family: Georgia, "Times New Roman", serif;
}

.page {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 52px 0 80px;
}

.auth-page {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  align-items: center;
  gap: 52px;
  padding: 52px 0;
}

.auth-intro h1 {
  font-size: clamp(52px, 7vw, 88px);
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.auth-card {
  margin-top: 0;
}

.auth-card h2 {
  margin: 0 0 18px;
  font-size: 30px;
}

.auth-card label + label,
.small-dialog label + label {
  margin-top: 14px;
}

.auth-card button,
.small-dialog button[type="submit"] {
  margin-top: 18px;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 18px 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 252, 247, 0.76);
}

.account-bar strong {
  display: block;
  font-size: 20px;
}

.account-actions {
  display: flex;
  gap: 10px;
}

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

.lead-type-picker {
  margin: 4px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.lead-type-picker legend {
  padding: 0 6px;
  color: #41506a;
  font-size: 15px;
}

.lead-type-picker .checkbox,
.lead-source-card .checkbox,
.legacy-source .checkbox {
  margin-top: 9px;
}

.lead-type-allocation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 126px;
  gap: 12px;
  align-items: end;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.lead-type-allocation-single {
  grid-template-columns: 1fr;
  border-bottom: 0;
}

.lead-type-allocation .checkbox {
  margin: 0 0 12px;
}

.lead-target-field {
  color: var(--muted);
  font-size: 12px;
}

.lead-target-field input {
  margin-top: 4px;
  padding: 9px 10px;
}

.lead-target-field input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.lead-source-settings {
  margin-top: 26px;
}

.lead-source-settings h3 {
  margin: 0;
  font-size: 24px;
}

.lead-source-card,
.legacy-source {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.source-toggle {
  font-weight: 700;
}

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

.legacy-source summary {
  cursor: pointer;
  color: #41506a;
  font-weight: 700;
}

.unavailable-option {
  opacity: 0.66;
}

.lead-type-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lead-type-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.setting-checkbox {
  align-self: end;
  min-height: 48px;
}

.warning-pill {
  background: #f2dfd8;
  color: #8f2d1f;
}

.status-label {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 700;
}

.status-active { background: var(--green-soft); color: var(--green); }
.status-success,
.status-completed,
.status-sent { background: var(--green-soft); color: var(--green); }
.status-pending { background: #fff0c8; color: #815d00; }
.status-running,
.status-processing,
.status-prepared,
.status-sending { background: #fff0c8; color: #815d00; }
.status-rejected,
.status-disabled,
.status-failed,
.status-quarantined { background: #f2dfd8; color: #8f2d1f; }

.small-dialog {
  width: min(520px, calc(100% - 32px));
}

.hero {
  max-width: 860px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #ba4a1d;
  font-size: 13px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(44px, 8vw, 92px);
  line-height: 0.88;
  letter-spacing: -0.06em;
}

.lead {
  max-width: 760px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
}

.card,
.status {
  margin-top: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.compact h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

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

label {
  display: block;
  color: #41506a;
  font-size: 16px;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input {
  padding: 13px 16px;
}

select {
  padding: 13px 16px;
}

.field-hint {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.schedule-toggle {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--green-soft);
}

.schedule-inactive {
  opacity: 0.58;
}

textarea {
  min-height: 150px;
  padding: 16px;
  resize: vertical;
}

.recipients-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(360px, 1.18fr);
  gap: 20px;
  margin-top: 22px;
}

.recipient-editor,
.recipient-table-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.66);
  padding: 20px;
}

.section-heading,
.table-head {
  margin-bottom: 16px;
}

.section-heading h2,
.table-head h2 {
  margin: 0;
  font-size: 27px;
  line-height: 1;
}

.mini {
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.28em;
}

.recipient-fields {
  display: grid;
  gap: 14px;
}

.recipient-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.ghost-button {
  background: #eadfce;
  color: var(--ink);
}

.inline-error {
  margin: 12px 0 0;
  color: var(--danger);
}

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

.pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
}

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

.lead-evidence-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.lead-evidence-head h2 {
  margin: 0 0 8px;
  font-size: 31px;
}

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

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

th {
  color: #6d5d4e;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td a {
  color: var(--green);
}

.row-actions {
  white-space: nowrap;
}

.table-button {
  padding: 8px 12px;
  font-size: 14px;
}

.row-actions .table-button + .table-button {
  margin-left: 8px;
}

.danger-button {
  background: #f2dfd8;
  color: #8f2d1f;
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.metric-number {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.error-text {
  color: var(--danger);
}

.muted-value {
  color: var(--muted);
  font-style: italic;
}

.workbook-table {
  min-width: 940px;
}

.workbook-section-divider {
  margin-top: 38px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.workbook-section-divider h2 {
  margin-bottom: 8px;
}

.workbook-actions {
  white-space: normal;
  min-width: 300px;
}

.workbook-actions .table-button {
  margin: 3px 5px 3px 0;
}

.admin-users-table {
  min-width: 900px;
}

.admin-log-row > td {
  padding: 0 10px 18px;
  background: rgba(234, 223, 206, 0.24);
}

.admin-log-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.admin-log-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.admin-log-heading p {
  margin: 6px 0 0;
}

.admin-log-table {
  min-width: 900px;
}

.admin-log-table td {
  vertical-align: top;
}

.history-dialog {
  width: min(920px, calc(100% - 32px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.history-dialog::backdrop {
  background: rgba(32, 41, 54, 0.52);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 30px;
}

.current-version {
  background: rgba(214, 242, 232, 0.5);
}

.version-badge {
  display: inline-block;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.checkbox input {
  width: auto;
  margin: 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 22px;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  padding: 14px 24px;
  font: 700 16px Georgia, "Times New Roman", serif;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:disabled {
  cursor: wait;
  filter: grayscale(0.4);
  opacity: 0.72;
}

.hint {
  color: var(--muted);
}

.status {
  color: var(--green);
  background: var(--green-soft);
}

.status.error {
  color: var(--danger);
  background: #fff7f6;
}

@media (max-width: 760px) {
  .lead-type-allocation {
    grid-template-columns: 1fr;
  }

  .lead-type-allocation .checkbox {
    margin-bottom: 0;
  }

  .page {
    width: min(100% - 24px, 1080px);
    padding-top: 34px;
  }

  .recipients-layout,
  .compact,
  .lead-evidence-head,
  .auth-page,
  .auth-grid,
  .settings-grid,
  .source-fields,
  .account-bar {
    display: block;
  }

  .recipient-table-card,
  .compact button,
  .lead-evidence-head button {
    margin-top: 18px;
  }

  .actions {
    display: block;
  }

  .auth-page {
    width: min(100% - 24px, 1080px);
  }

  .auth-grid,
  .account-actions {
    margin-top: 22px;
  }

  .auth-card + .auth-card {
    margin-top: 18px;
  }

  .dialog-head {
    display: block;
  }

  .admin-log-heading {
    display: block;
  }

  .admin-log-heading button {
    margin-top: 14px;
  }

  .dialog-head button {
    margin-top: 16px;
  }
}
