:root {
  --bg: #f5f4ef;
  --ink: #0f172a;
  --muted: #475569;
  --line: #d7d4cc;
  --card: #fffefb;
  --accent: #14532d;
  --accent-soft: #d9f99d;
  --danger: #9f1239;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #efe7d8 0%, var(--bg) 35%, #f5f4ef 100%);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.45;
  z-index: 0;
  pointer-events: none;
}

.bg-a {
  width: 260px;
  height: 260px;
  top: -80px;
  right: 8%;
  background: #bef264;
}

.bg-b {
  width: 240px;
  height: 240px;
  bottom: -90px;
  left: 5%;
  background: #fde68a;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 18px 54px;
}

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

.eyebrow {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: -0.03em;
}

.panel {
  background: color-mix(in srgb, var(--card), white 25%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  backdrop-filter: blur(2px);
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  background: #fff;
}

input:focus {
  outline: 2px solid #84cc16;
  outline-offset: 1px;
}

select,
textarea {
  width: 100%;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  background: #fff;
}

select:focus,
textarea:focus {
  outline: 2px solid #84cc16;
  outline-offset: 1px;
}

.btn {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  background: #fff;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.09);
}

.btn-primary {
  border-color: #166534;
  background: linear-gradient(160deg, #166534, #14532d);
  color: #f8fafc;
}

.metrics {
  margin: 14px 0;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

.card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.card strong {
  display: block;
  margin-top: 7px;
  font-size: 28px;
}

.table-wrap {
  margin-top: 12px;
  overflow: hidden;
}

.status {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 14px;
}

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

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

th,
td {
  text-align: left;
  border-top: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: top;
  font-size: 13px;
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td code {
  font-family: 'IBM Plex Mono', monospace;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 2px 5px;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
}

.lead-row {
  cursor: pointer;
  transition: background 120ms ease;
}

.lead-row:hover {
  background: #fffbeb;
}

.lead-primary {
  display: grid;
  gap: 3px;
}

.lead-name {
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-new { background: #dbeafe; color: #1d4ed8; }
.status-contacted { background: #ede9fe; color: #6d28d9; }
.status-qualified { background: #dcfce7; color: #166534; }
.status-proposal { background: #fef3c7; color: #92400e; }
.status-won { background: #bbf7d0; color: #166534; }
.status-lost { background: #fecaca; color: #991b1b; }

.lead-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
}

.lead-modal.hidden {
  display: none;
}

.lead-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
}

.lead-drawer {
  position: relative;
  width: min(760px, 100vw);
  height: 100%;
  background: #fffefb;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(15, 23, 42, 0.15);
  padding: 18px;
  overflow-y: auto;
}

.lead-drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.lead-drawer-header h2 {
  margin: 5px 0 0;
  font-size: 24px;
}

.lead-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.lead-form-grid .full {
  grid-column: 1 / -1;
}

.lead-meta {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  margin-bottom: 12px;
}

.lead-meta p {
  margin: 6px 0;
  font-size: 13px;
}

.scan-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  overflow: hidden;
}

.scan-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 11px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.scan-box-head .btn {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.scan-preview {
  margin: 0;
  padding: 12px;
  overflow: auto;
  max-height: 260px;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
}

.lead-drawer-footer {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 860px) {
  .controls {
    grid-template-columns: 1fr;
  }

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

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

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