:root {
  color-scheme: light;
  --bg: #f7efe3;
  --bg-2: #fff7e8;
  --panel: #fffdf8;
  --panel-2: #fff4dc;
  --ink: #172033;
  --muted: #64718a;
  --line: #dfcfb8;
  --accent: #20c6a5;
  --accent-2: #4ca8ff;
  --accent-3: #ffd166;
  --accent-4: #ff8f70;
  --danger: #d94f6b;
  --success: #17875d;
  --shadow: rgba(45, 34, 20, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(23, 32, 51, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(23, 32, 51, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
}

.shell {
  display: grid;
  grid-template-columns: minmax(18rem, 28rem) 1fr;
  gap: 1.25rem;
  min-height: 100vh;
  padding: 1.5rem;
}

.brand-panel, .panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1rem 2.5rem var(--shadow);
}

.brand-panel {
  min-height: calc(100vh - 3rem);
  height: calc(100vh - 3rem);
  padding: 2rem;
  position: sticky;
  top: 1.5rem;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.14), transparent 45%),
    linear-gradient(160deg, #18243a, #102c33);
  color: #fffdf8;
}

.brand-panel::before {
  content: "";
  position: absolute;
  inset: 1rem;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  pointer-events: none;
}

.brand-mark {
  width: 3.8rem;
  height: 3.8rem;
  display: grid;
  place-items: center;
  border: 3px solid #172033;
  border-radius: 50%;
  background: var(--accent-3);
  color: #172033;
  font-weight: 900;
  font-size: 1.9rem;
  margin-bottom: 2rem;
  box-shadow: 0.35rem 0.35rem 0 #0c1525;
}

.eyebrow {
  color: #9debd8;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.78rem;
  font-weight: 800;
  margin: 0 0 0.6rem;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(2.35rem, 5vw, 4rem); line-height: 1; }
h2, h3 { color: var(--ink); }
.brand-panel > p:not(.eyebrow) { color: #d7e3ee; line-height: 1.7; font-size: 1.05rem; }

.brand-illustration {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin: 1.5rem 0 0;
}

.mini-card {
  display: grid;
  gap: 0.55rem;
  align-content: center;
  min-height: 5.5rem;
  padding: 0.9rem;
  border: 2px solid #172033;
  border-radius: 8px;
  color: #172033;
  box-shadow: 0.22rem 0.22rem 0 #0c1525;
}

.mini-card strong { font-size: 0.86rem; }
.lead-card { background: #b8e6ff; }
.crm-card { background: #c7f3c9; transform: translateY(0.35rem); }
.pay-card { background: #ffe3a3; }
.mini-icon {
  width: 1.55rem;
  height: 1.55rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  display: block;
  background: rgba(255, 255, 255, 0.45);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 2rem;
}
.stat-grid div {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 1rem;
}
.stat-grid strong { display: block; font-size: 1.55rem; color: #fff; }
.stat-grid span { color: #c8d6e4; font-size: 0.82rem; }

.workspace { min-width: 0; }
.panel {
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: rgba(255, 253, 248, 0.96);
}
.auth-panel { max-width: 30rem; margin: 10vh auto 0; }
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.auth-tab {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0.75rem;
}
.auth-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--accent);
}
.form-help {
  color: var(--muted);
  line-height: 1.6;
  margin: 0.6rem 0 0;
}

label {
  display: grid;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-top: 1rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 3rem;
  padding: 0.85rem 1rem;
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(76, 168, 255, 0.22);
  border-color: var(--accent-2);
}

textarea { resize: vertical; }
button {
  border: 0;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #06101a;
  border-radius: 8px;
  padding: 0.9rem 1.2rem;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 0.45rem 0 rgba(16, 44, 51, 0.14);
}
button:hover { filter: saturate(1.08); }
.secondary-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.verify-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 0.75rem;
}
.verify-row label { margin-top: 1rem; }
.verify-row button { min-height: 3rem; white-space: nowrap; }
.topbar, .section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.topbar button, .section-title button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.lead-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}
.lead-form .full { grid-column: 1 / -1; }
.lead-form button { grid-column: 1 / -1; margin-top: 1rem; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; min-width: 48rem; }
th, td { text-align: left; padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fff4dc; color: #516078; font-weight: 850; }
td { color: var(--ink); }
tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  background: #fff7e8;
}
.accepted, .eligible, .paid { color: var(--success); }
.duplicate, .rejected, .crm_sync_failed { color: var(--danger); }
.notice { color: var(--success); }
.error { color: var(--danger); }
.hidden { display: none !important; }
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
}
.audit-list { display: grid; gap: 0.75rem; }
.audit-list pre {
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  color: var(--ink);
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; padding: 1rem; }
  .brand-panel { position: static; height: auto; min-height: 0; }
  .lead-form { grid-template-columns: 1fr; }
  .verify-row { grid-template-columns: 1fr; }
}
