@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap');

:root {
  --ink: #201f1d;
  --black: #201f1d;
  --brand: #ff5408;
  --blue: #ff5408;
  --brand-soft: #ff7a3d;
  --teal: #3b8993;
  --paper: #f4f1ee;
  --line: #e6e0d8;
  --muted: #6f6860;
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: Arial, Helvetica, sans-serif;
  --shadow: 0 18px 50px rgba(32, 31, 29, .12);
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* —— Shell —— */
.admin-shell {
  display: flex;
  min-height: 100vh;
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 84, 8, .08), transparent 42%),
    radial-gradient(circle at 0% 100%, rgba(59, 137, 147, .08), transparent 40%),
    var(--paper);
}
.admin-nav {
  width: 268px;
  background: var(--black);
  color: #fff;
  padding: 28px 18px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 18px;
  text-decoration: none;
  color: #fff;
}
.admin-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: var(--brand);
  border-radius: 50%;
  padding: 8px;
}
.admin-brand-copy strong {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: .04em;
}
.admin-brand-copy small {
  display: block;
  margin-top: 3px;
  color: #a8a29a;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.admin-nav-links { flex: 1; }
.admin-nav a.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cfc8bf;
  padding: 11px 12px;
  border-radius: 10px;
  margin-bottom: 4px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background .18s, color .18s;
}
.admin-nav a.nav-link:hover,
.admin-nav a.nav-link.active {
  background: rgba(255, 84, 8, .16);
  color: #fff;
  text-decoration: none;
}
.admin-nav a.nav-link.active {
  box-shadow: inset 3px 0 0 var(--brand);
}
.admin-nav-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 14px;
  margin-top: 12px;
}
.admin-user {
  padding: 0 12px 10px;
  color: #a8a29a;
  font-size: 12px;
  word-break: break-all;
}
.admin-nav a.logout-link {
  display: block;
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  background: rgba(255,255,255,.06);
  font-size: 13px;
  font-weight: 700;
}
.admin-nav a.logout-link:hover {
  background: var(--brand);
  text-decoration: none;
}

.admin-main {
  flex: 1;
  padding: 28px 32px 40px;
  min-width: 0;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-header h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -.02em;
}
.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.admin-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(32, 31, 29, .04);
}
.admin-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}
.admin-card p.muted {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat {
  padding: 18px;
  background: linear-gradient(180deg, #fff, #faf7f4);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  margin-top: 8px;
  color: var(--ink);
}
.stat a { font-weight: 700; }

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #4d4741;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  margin-bottom: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 84, 8, .12);
}
textarea { min-height: 90px; resize: vertical; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s, opacity .15s;
}
.btn:hover { text-decoration: none; opacity: .94; transform: translateY(-1px); }
.btn.secondary {
  background: #efeae4;
  color: var(--ink);
}
.btn.danger { background: #b42318; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
}
.alert.ok { background: #e8f8ef; color: #0f6b3a; }
.alert.err { background: #fdecec; color: #b42318; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #efeae4;
}
.badge.sent { background: #e8f8ef; color: #0f6b3a; }
.badge.error { background: #fdecec; color: #b42318; }
.badge.skipped, .badge.pending { background: #fff6df; color: #8a6d1d; }
.field-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.field-row label { margin: 0; }
.option-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 110px 1fr 1.4fr 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}
.option-row input, .option-row select, .option-row textarea { margin-bottom: 0; }
.stage-block { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.stage-block h3 { margin: 0 0 12px; font-size: 16px; }
code.snippet {
  display: block;
  background: var(--ink);
  color: #fff;
  padding: 16px;
  border-radius: 10px;
  font-size: 13px;
  overflow-x: auto;
  white-space: pre-wrap;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.checkbox-row input { width: auto; margin: 0; }
.checkbox-row label { margin: 0; font-weight: 600; }
.preview {
  background: var(--ink);
  color: #ece7e1;
  padding: 14px;
  border-radius: 10px;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* —— Login —— */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--paper);
}
.login-brand {
  position: relative;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.16), transparent 40%),
    linear-gradient(145deg, #ff5408 0%, #d94306 55%, #201f1d 120%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.login-brand::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  right: -120px;
  bottom: -140px;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  right: 40px;
  bottom: 40px;
}
.login-brand-inner { position: relative; z-index: 1; }
.login-brand img.login-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: rgba(32, 31, 29, .25);
  border-radius: 50%;
  padding: 16px;
  margin-bottom: 28px;
}
.login-brand h1 {
  margin: 0 0 14px;
  font-size: clamp(36px, 5vw, 52px);
  line-height: 1.05;
  max-width: 420px;
}
.login-brand p {
  margin: 0;
  max-width: 380px;
  color: rgba(255,255,255,.88);
  font-size: 15px;
  line-height: 1.6;
}
.login-brand-meta {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.75);
}
.login-brand-meta span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.login-brand-meta i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  display: inline-block;
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 84, 8, .06), transparent 35%),
    #faf8f6;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  padding: 36px 32px;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.login-card .eyebrow {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.login-card h2 {
  margin: 0 0 8px;
  font-size: 30px;
}
.login-card .lede {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.login-card .btn {
  width: 100%;
  margin-top: 6px;
  min-height: 46px;
}
.password-field {
  position: relative;
  margin-bottom: 14px;
}
.password-field input {
  margin-bottom: 0;
  padding-right: 46px;
}
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6f6860;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.password-toggle svg {
  display: block;
  grid-area: 1 / 1;
}
.password-toggle .icon-eye-off {
  display: none;
}
.password-toggle.is-visible .icon-eye {
  display: none;
}
.password-toggle.is-visible .icon-eye-off {
  display: block;
}
.password-toggle:hover {
  color: var(--brand);
  background: rgba(255, 84, 8, .08);
}
.password-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
.login-hint {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.login-mobile-brand {
  display: none;
  text-align: center;
  margin-bottom: 18px;
}
.login-mobile-brand img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--brand);
  border-radius: 50%;
  padding: 12px;
}

.domain-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 8px;
}
.domain-row input {
  margin-bottom: 0;
  flex: 1;
}
.domain-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
@media (max-width: 960px) {
  .domain-row {
    flex-direction: column;
  }
}
.header-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.header-row input {
  margin-bottom: 0;
}
.header-row-action {
  display: flex;
  flex-direction: column;
}
.header-row-action.is-first .header-remove-spacer {
  display: block;
  min-height: 44px;
  height: 44px;
}
.header-row-action .header-remove {
  width: auto;
  min-height: 44px;
  height: 44px;
  padding: 0 14px;
  white-space: nowrap;
}
@media (max-width: 960px) {
  .header-row {
    grid-template-columns: 1fr;
  }
  .header-row-action .header-remove {
    width: auto;
    align-self: start;
  }
  .admin-shell { flex-direction: column; }
  .admin-nav {
    width: 100%;
    height: auto;
    position: relative;
  }
  .grid-2, .grid-4, .field-row, .option-row { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-mobile-brand { display: block; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .leads-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-dates {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 8px;
  }
  .filter-dates .filter-field {
    width: auto;
    flex: 1;
  }
  .date-sep {
    height: auto;
    padding-bottom: 12px;
  }
  .filter-actions {
    width: 100%;
  }
  .filter-actions .btn,
  .filter-actions .btn.secondary {
    flex: 1;
  }
}

.leads-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: end;
  margin: 0 0 18px;
  padding: 16px;
  background: #faf7f4;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.filter-field label {
  margin-bottom: 6px;
}
.filter-field input {
  margin-bottom: 0;
  height: 44px;
  min-height: 44px;
}
.filter-search {
  flex: 1 1 260px;
  min-width: 220px;
}
.filter-dates {
  display: flex;
  align-items: end;
  gap: 10px;
  flex: 0 1 auto;
  max-width: 100%;
}
.filter-dates .filter-field {
  flex: 0 0 168px;
  width: 168px;
}
.date-sep {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  color: #9a9288;
  font-size: 16px;
  font-weight: 700;
  flex: 0 0 auto;
  padding-bottom: 1px;
}
.date-input {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
  overflow: hidden;
}
.date-input:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 84, 8, .12);
}
.date-input-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 100%;
  color: var(--brand);
  flex: 0 0 auto;
  pointer-events: none;
}
.date-input input[type="date"] {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  margin: 0;
  border: 0 !important;
  border-radius: 0;
  box-shadow: none !important;
  background: transparent;
  padding: 0 10px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  color-scheme: light;
}
.date-input input[type="date"]:focus {
  outline: none;
  box-shadow: none !important;
}
.date-input input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.date-input input[type="date"]::-webkit-datetime-edit {
  padding: 0;
}
.date-input input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}
.date-input input[type="date"]::-webkit-datetime-edit-text {
  color: #9a9288;
  padding: 0 2px;
}
.date-input input[type="date"]::-webkit-datetime-edit-month-field,
.date-input input[type="date"]::-webkit-datetime-edit-day-field,
.date-input input[type="date"]::-webkit-datetime-edit-year-field {
  color: var(--ink);
  padding: 0 1px;
}
.filter-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  align-items: center;
}
.filter-actions .btn,
.filter-actions .btn.secondary {
  min-height: 44px;
  height: 44px;
  padding: 0 18px;
  white-space: nowrap;
}
.leads-meta {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.table-wrap table {
  margin: 0;
}
.table-wrap th:first-child,
.table-wrap td:first-child {
  padding-left: 14px;
}
.table-wrap th:last-child,
.table-wrap td:last-child {
  padding-right: 14px;
}
.cell-muted {
  color: #6f6860;
}
.cell-details {
  margin-top: 6px;
}
.cell-details pre {
  white-space: pre-wrap;
  font-size: 11px;
  margin: 6px 0 0;
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}
.page-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  text-decoration: none;
}
.page-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.page-btn.disabled {
  opacity: .45;
  pointer-events: none;
}
.page-ellipsis {
  color: var(--muted);
  padding: 0 4px;
}

/* —— Messages editor —— */
.msg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.msg-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.msg-tab:hover { border-color: var(--brand); color: var(--brand); }
.msg-tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.msg-panel { display: none; }
.msg-panel.is-active { display: block; }
.msg-field { margin-bottom: 14px; }
.msg-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.msg-field-head label { margin-bottom: 6px; }
.msg-subhead {
  margin: 22px 0 12px;
  font-size: 15px;
}
.opt-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.opt-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #faf8f5;
}
.opt-card-top {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.opt-grow { flex: 1; min-width: 0; }
.opt-grow input { margin-bottom: 0; }
.opt-remove {
  flex: 0 0 auto;
  min-height: 44px;
  height: 44px;
  padding: 0 14px;
}
.opt-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.opt-action-row input,
.opt-action-row select { margin-bottom: 0; }
.btn-link {
  border: 0;
  background: none;
  color: var(--brand);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.btn-link.danger { color: #b42318; }
.msg-savebar {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(32, 31, 29, .08);
}
.msg-add-dock { margin-top: 14px; }
.msg-add-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
}
.msg-add-form .btn { margin-top: 8px; }
@media (max-width: 960px) {
  .opt-card-top { flex-direction: column; align-items: stretch; }
  .opt-action-row { grid-template-columns: 1fr; }
  .msg-savebar { flex-direction: column; align-items: stretch; }
}
