:root {
  --bg: #f6f7f8;
  --bg-soft: #fafafa;
  --surface: #ffffff;
  --surface-muted: #f5f5f5;
  --ink: #1f1f1f;
  --muted: #6c6c6c;
  --line: #e8e8e8;
  --accent: #ff8800;
  --accent-deep: #eb7b00;
  --accent-soft: #fff0dd;
  --success: #2f8a45;
  --danger: #ba4f29;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Open Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(255, 136, 0, 0.08), transparent 24%),
    linear-gradient(180deg, #ffffff, #f6f7f8 38%, #f3f4f5 100%);
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.admin-page {
  min-height: 100vh;
}

.admin-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-login-card {
  width: min(100%, 520px);
  padding: 32px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.admin-login-card h1,
.admin-header h1 {
  margin: 0 0 12px;
  font-family: "Merriweather", Georgia, serif;
  color: #222222;
}

.admin-login-form {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.admin-sidebar,
.admin-main {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.admin-sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  padding: 28px;
  position: sticky;
  top: 24px;
  align-self: start;
}

.admin-menu {
  display: grid;
  gap: 12px;
}

.admin-menu__item,
.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.admin-menu__item {
  background: var(--surface-muted);
  color: var(--ink);
  text-align: left;
}

.admin-menu__item.is-active {
  background: var(--accent-soft);
  border-color: rgba(255, 136, 0, 0.28);
  color: #6a4300;
}

.admin-menu__item--logout {
  margin-top: 6px;
  background: rgba(186, 79, 41, 0.06);
  color: var(--danger);
  border-color: rgba(186, 79, 41, 0.16);
}

.danger-button {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(186, 79, 41, 0.2);
  background: rgba(186, 79, 41, 0.08);
  color: var(--danger);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.danger-button:hover,
.danger-button:focus-visible {
  background: rgba(186, 79, 41, 0.14);
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-deep);
}

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.admin-sidebar__footer {
  display: grid;
  gap: 12px;
}

.admin-danger-zone {
  margin-top: 24px;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid rgba(186, 79, 41, 0.18);
  background: rgba(186, 79, 41, 0.04);
}

.admin-danger-zone h4 {
  margin: 0 0 10px;
  font-family: "Merriweather", Georgia, serif;
}

.admin-danger-zone p {
  margin: 0 0 14px;
  color: var(--muted);
}

.admin-user {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.admin-main {
  padding: 24px;
}

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

.admin-statusline {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.admin-view {
  display: none;
}

.admin-view.is-active {
  display: grid;
  gap: 20px;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.94rem;
}

.admin-table__meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.admin-link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.admin-link-button:hover,
.admin-link-button:focus-visible {
  text-decoration: underline;
}

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

.admin-toolbar__copy {
  margin: 6px 0 0;
  color: var(--muted);
}

.admin-toolbar--stacked {
  align-items: stretch;
}

.admin-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  width: 100%;
}

.admin-filter-grid--conversion-stats {
  margin-top: 6px;
}

.admin-search select {
  min-height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}

.admin-search {
  display: grid;
  gap: 6px;
  min-width: min(100%, 320px);
}

.admin-search span {
  font-weight: 700;
  font-size: 0.9rem;
}

.admin-date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 160px));
  gap: 12px;
}

.lead-detail-content {
  display: grid;
  gap: 18px;
}

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

.lead-detail-actions {
  margin-top: 18px;
}

.admin-key-value {
  display: grid;
  gap: 12px;
  margin: 0;
}

.admin-key-value__row {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
  gap: 12px;
}

.admin-key-value__row dt {
  font-weight: 700;
  color: var(--muted);
}

.admin-key-value__row dd {
  margin: 0;
}

.admin-email-preview {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fffdf8;
  overflow-x: auto;
}

.admin-pre {
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f8f8f8;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-table th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.admin-activity-list {
  display: grid;
  gap: 12px;
}

.admin-activity-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.admin-activity-item p {
  margin: 6px 0 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #ececec;
  color: #4d4d4d;
}

.status-pill--completed {
  background: rgba(47, 138, 69, 0.12);
  color: var(--success);
}

.status-pill--failed {
  background: rgba(186, 79, 41, 0.12);
  color: var(--danger);
}

.status-pill--queued,
.status-pill--processing {
  background: rgba(255, 136, 0, 0.12);
  color: #8a5600;
}

.metric-value--small {
  font-size: 1rem;
  line-height: 1.5;
  word-break: break-word;
}

.hero-panel,
.main-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 28px;
  position: sticky;
  top: 24px;
  align-self: start;
  overflow: hidden;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: var(--accent);
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 220px;
  max-width: 100%;
  height: auto;
}

.brand-tag {
  display: inline-flex;
  width: fit-content;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #6a4300;
  font-size: 0.8rem;
  font-weight: 700;
}

.eyebrow,
.section-label {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}

.hero-panel h1,
.wizard-header h2,
.card h3,
.chart-card h4 {
  font-family: "Merriweather", Georgia, serif;
  color: #222222;
}

.hero-panel h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 3.4vw, 3rem);
  line-height: 1.16;
}

.hero-copy,
.hero-note p,
.card p,
.plain-list,
label span,
th,
td {
  line-height: 1.65;
}

.step-list {
  list-style: none;
  margin: 28px 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.step-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  opacity: 0.72;
}

.step-list li.is-active,
.step-list li.is-complete {
  opacity: 1;
}

.step-list li.is-active {
  background: var(--surface-muted);
  border-color: var(--line);
}

.step-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #222222;
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 700;
}

.step-list li.is-active .step-index,
.step-list li.is-complete .step-index {
  background: var(--accent);
}

.hero-note {
  padding: 18px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 136, 0, 0.08), rgba(255, 255, 255, 0.9)),
    #ffffff;
  border: 1px solid var(--line);
}

.hero-note h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-family: "Open Sans", sans-serif;
}

.main-panel {
  padding: 24px;
}

.wizard-header {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.wizard-header h2 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 2.5rem);
  line-height: 1.15;
}

.section-label {
  color: var(--muted);
}

.progress-rail {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #efefef;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #ffab44);
  transition: width 220ms ease;
}

.wizard-step {
  display: none;
}

.wizard-step.is-active {
  display: block;
}

.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

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

.content-grid.single {
  grid-template-columns: 1fr;
}

.ai-form-grid {
  grid-template-columns: 1fr;
  max-width: 720px;
}

.submission-status {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.submission-status.is-success {
  background: rgba(47, 138, 69, 0.08);
  border-color: rgba(47, 138, 69, 0.2);
  color: var(--success);
}

.submission-status.is-error {
  background: rgba(186, 79, 41, 0.08);
  border-color: rgba(186, 79, 41, 0.18);
  color: var(--danger);
}

.debug-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.debug-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.debug-panel pre {
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(31, 31, 31, 0.06);
  color: #1f1f1f;
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.card,
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card {
  padding: 24px;
}

.card h3,
.chart-card h4 {
  margin-top: 0;
}

.card h3 {
  font-size: 1.42rem;
  margin-bottom: 18px;
}

.intro-card {
  min-height: 320px;
}

.intro-visual {
  margin-top: 18px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at top right, rgba(255, 136, 0, 0.12), transparent 30%),
    linear-gradient(180deg, #ffffff, #f7f7f7);
  max-width: 720px;
}

.intro-visual__image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: cover;
  object-position: center;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
}

.form-grid,
.metric-grid,
.report-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 14px;
  row-gap: 20px;
  align-items: start;
}

label {
  display: grid;
  grid-template-rows: auto minmax(52px, auto);
  gap: 4px;
  align-content: start;
}

label span {
  display: inline-flex;
  align-items: center;
  align-self: start;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
}

.form-grid > label > span {
  min-height: calc(1.35em * 2);
}

.tooltip-trigger {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #d7d7d7;
  background: #ffffff;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  position: relative;
  box-shadow: none;
}

.tooltip-trigger::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: min(260px, 70vw);
  padding: 10px 12px;
  border-radius: 10px;
  background: #1f1f1f;
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 5;
}

.tooltip-trigger::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #1f1f1f transparent transparent transparent;
  opacity: 0;
  transition: opacity 120ms ease;
}

.tooltip-trigger:hover::after,
.tooltip-trigger:hover::before,
.tooltip-trigger:focus-visible::after,
.tooltip-trigger:focus-visible::before {
  opacity: 1;
}

input {
  width: 100%;
  border: 1px solid #dddddd;
  border-radius: 8px;
  min-height: 52px;
  padding: 13px 14px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  line-height: 1.2;
  appearance: none;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: stretch;
}

.input-shell input {
  height: 100%;
  padding-right: 42px;
}

.input-suffix {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  pointer-events: none;
}

label > input,
label > .input-shell {
  width: 100%;
}

@media (max-width: 980px) {
  .admin-shell,
  .page-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar,
  .hero-panel {
    position: static;
  }

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

  label {
    grid-template-rows: auto minmax(52px, auto);
  }
}

input:focus {
  outline: 2px solid rgba(255, 136, 0, 0.18);
  border-color: rgba(255, 136, 0, 0.7);
}

.help-card {
  background:
    linear-gradient(180deg, rgba(255, 136, 0, 0.06), rgba(255, 255, 255, 0.94)),
    #ffffff;
}

.metric,
.summary-card {
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.metric-label,
.summary-label {
  font-size: 0.84rem;
  color: var(--muted);
}

.metric-label--with-tooltip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.metric-value,
.summary-value {
  margin-top: 8px;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
}

.callout {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: #6a4300;
  font-weight: 600;
}

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

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chart-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.chart-legend__swatch--gain {
  background: #c55f32;
}

.chart-legend__swatch--cost {
  background: #2d7a53;
}

.chart-card {
  padding: 20px;
}

.chart-card h4 {
  font-size: 1.08rem;
  margin-bottom: 14px;
}

.conversion-stats-table-card {
  margin-top: 18px;
}

.conversion-stats-table-card h4 {
  margin-bottom: 14px;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
}

.narrative {
  display: grid;
  gap: 12px;
}

.narrative p {
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.table-wrap {
  margin-top: 22px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.wizard-footer {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.page-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  flex-wrap: wrap;
}

.page-footer__label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.page-footer__value {
  font-weight: 600;
}

.footer-actions {
  display: flex;
  gap: 12px;
}

button {
  border: none;
  border-radius: 0 6px 6px 6px;
  padding: 15px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(255, 136, 0, 0.22);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-deep);
}

.secondary-button,
.ghost-button {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid #d8d8d8;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

@media (max-width: 1100px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .page-shell,
  .hero-panel,
  .main-panel {
    padding: 18px;
  }

  .content-grid,
  .chart-grid,
  .metric-grid,
  .report-summary,
  .lead-detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-key-value__row,
  .admin-date-range,
  .admin-filter-grid {
    grid-template-columns: 1fr;
  }

  .form-grid > label > span {
    min-height: 0;
  }

  .wizard-footer {
    flex-direction: column-reverse;
  }

  .footer-actions {
    width: 100%;
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .brand-logo {
    width: 180px;
  }
}
