/* LinkPuller — Linear-inspired dark product canvas */

:root {
  --primary: #5e6ad2;
  --on-primary: #ffffff;
  --primary-hover: #828fff;
  --primary-focus: #5e69d1;

  --ink: #f7f8f8;
  --ink-muted: #d0d6e0;
  --ink-subtle: #8a8f98;
  --ink-tertiary: #62666d;

  --canvas: #010102;
  --surface-1: #0f1011;
  --surface-2: #141516;
  --surface-3: #18191a;
  --surface-4: #191a1b;

  --hairline: #23252a;
  --hairline-strong: #34343a;
  --hairline-tertiary: #3e3e44;

  --inverse-canvas: #ffffff;
  --inverse-ink: #000000;

  --brand-secure: #7a7fad;
  --semantic-success: #27a644;
  --warn: #e5484d;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-xxl: 24px;
  --radius-pill: 9999px;

  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  --space-section: 96px;

  --font-display: "Inter", "SF Pro Display", -apple-system, system-ui, "Segoe UI", sans-serif;
  --font-body: "Inter", "SF Pro Text", -apple-system, system-ui, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --container: 1120px;
  --nav-height: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.05px;
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

.page-bg {
  display: none;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

/* ——— Top nav ——— */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.2px;
  color: var(--primary);
  text-decoration: none;
}

.brand:hover {
  color: var(--primary-hover);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.site-header nav a {
  color: var(--ink-subtle);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  margin: 0;
  padding: 6px 0;
}

.site-header nav a:hover,
.site-header nav a.is-active {
  color: var(--ink);
}

/* ——— Layout ——— */

.container,
.hero,
.analytics-page,
.campaign-page,
.not-found,
.preview-page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-xxl) var(--space-lg) var(--space-section);
}

.campaign-page {
  max-width: 1120px;
}

.generator-page .container {
  max-width: 640px;
}

/* ——— Type ——— */

.brand-mark {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  font-weight: 600;
  letter-spacing: -1.8px;
  line-height: 1.1;
  color: var(--primary);
}

.page-eyebrow {
  margin: 0 0 var(--space-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.4px;
  color: var(--ink-subtle);
  text-transform: none;
}

header h1,
.hero h1,
.analytics-page h1,
.campaign-page h1,
.not-found h1,
.container > header h1 {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1.15;
  color: var(--ink);
}

.lede {
  margin: 0 0 var(--space-xl);
  color: var(--ink-subtle);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.1px;
  max-width: 36rem;
}

.card-title,
.form-card h2,
.result-card h2,
.result h2 {
  margin: 0 0 var(--space-md);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.4px;
  line-height: 1.25;
  color: var(--ink);
}

/* ——— Panels / cards ——— */

.panel,
.form-card,
.result-card,
.result,
.analytics-result,
.options-fieldset,
.generate-form.form-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.analytics-result {
  margin-top: var(--space-xl);
}

/* ——— Forms ——— */

.generate-form label,
.form-group label,
.form-card > label,
.result-item > label {
  display: block;
  margin: 0 0 var(--space-xs);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
}

.form-group,
.form-block {
  margin-bottom: var(--space-md);
}

.form-group:last-child,
.form-block:last-child {
  margin-bottom: 0;
}

.field-row {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
}

.form-actions {
  margin-top: var(--space-lg);
}

.generate-form > label + input,
.generate-form > label + .field-row {
  margin-bottom: var(--space-md);
}

input[type="url"],
input[type="text"],
input:not([type="checkbox"]):not([type="radio"]),
select {
  width: 100%;
  flex: 1 1 200px;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  letter-spacing: -0.05px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-card input,
.panel input,
.panel select,
.generate-form input:not([type="checkbox"]),
.generate-form select {
  background: var(--canvas);
}

input::placeholder {
  color: var(--ink-tertiary);
}

input:focus,
select:focus {
  outline: 2px solid rgba(94, 105, 209, 0.5);
  outline-offset: 0;
  border-color: var(--hairline-strong);
}

input[readonly] {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ——— Buttons ——— */

button,
.btn-primary,
.btn-secondary,
.btn-tertiary,
.ghost-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 40px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

button[type="submit"],
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

button[type="submit"]:hover,
.btn-primary:hover {
  background: var(--primary-hover);
}

button[type="submit"]:active,
.btn-primary:active {
  background: var(--primary-focus);
}

button[type="submit"]:disabled,
.btn-primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-secondary,
button[type="button"]:not(.btn-primary):not(.style-btn):not(.continue-btn) {
  background: var(--surface-1);
  color: var(--ink);
  border: 1px solid var(--hairline);
}

.btn-secondary:hover,
button[type="button"]:not(.btn-primary):not(.style-btn):not(.continue-btn):hover {
  background: var(--surface-2);
  border-color: var(--hairline-strong);
}

.ghost-btn,
.btn-tertiary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--hairline);
  text-decoration: none;
}

.ghost-btn:hover,
.btn-tertiary:hover {
  background: var(--surface-1);
  color: var(--ink);
}

.continue-btn {
  display: inline-flex;
  margin-top: var(--space-xs);
  background: var(--primary);
  color: var(--on-primary) !important;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
}

.continue-btn:hover {
  background: var(--primary-hover);
  color: var(--on-primary) !important;
}

.security-audit {
  margin-top: var(--space-xl);
  padding: var(--space-md);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  max-width: 420px;
}

.security-audit .audit-score {
  margin: 0 0 var(--space-sm);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.security-audit .audit-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink-subtle);
  font-size: 14px;
  line-height: 1.5;
}

.security-audit .audit-list li {
  margin: 0.2rem 0;
}

/* ——— Fieldsets / checkboxes ——— */

fieldset.form-group,
.options-fieldset {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--canvas);
}

fieldset.form-group legend,
.options-fieldset legend {
  padding: 0 var(--space-xxs);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--ink-subtle);
}

fieldset.form-group label,
.options-fieldset label,
.checkbox-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  margin: var(--space-xs) 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-muted);
  cursor: pointer;
  line-height: 1.4;
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
  margin-top: 3px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.checkbox-row strong {
  font-weight: 500;
  color: var(--ink);
}

/* ——— Result / QR ——— */

.result-card,
.result {
  margin-top: var(--space-xl);
}

.result-item {
  margin-bottom: var(--space-md);
}

.input-with-btn,
.result-link {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.input-with-btn input {
  flex: 1 1 220px;
}

.result-link a,
.hint a,
.stats a,
#target-urls a {
  color: var(--primary);
  word-break: break-all;
}

.result-link a:hover,
.hint a:hover,
.stats a:hover,
#target-urls a:hover {
  color: var(--primary-hover);
}

.hint {
  margin: var(--space-sm) 0 var(--space-md);
  color: var(--ink-subtle);
  font-size: 14px;
}

.hint code {
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  color: var(--ink-muted);
}

.qr-styles,
.qr-toolbar,
.style-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin: var(--space-md) 0 var(--space-sm);
}

.style-btn {
  background: var(--canvas);
  color: var(--ink-subtle);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  min-height: 36px;
  font-size: 14px;
  font-weight: 500;
}

.style-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.style-btn.active,
.style-btn.is-active {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--hairline-strong);
}

#qrcode,
.qrcode {
  display: inline-block;
  padding: var(--space-md);
  background: var(--inverse-canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
}

#qrcode img,
#qrcode canvas,
.qrcode img,
.qrcode canvas {
  display: block;
}

/* ——— Vanity ——— */

.vanity-row {
  display: flex;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--canvas);
  overflow: hidden;
}

.vanity-prefix {
  padding: 8px 12px;
  color: var(--ink-tertiary);
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
  border-right: 1px solid var(--hairline);
}

.vanity-row input {
  border: none;
  border-radius: 0;
  background: transparent;
}

.vanity-row input:focus {
  outline: none;
}

.vanity-row:focus-within {
  outline: 2px solid rgba(94, 105, 209, 0.5);
  border-color: var(--hairline-strong);
}

/* ——— Analytics / tables ——— */

.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--hairline);
}

.summary-bar p {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.2px;
  color: var(--ink);
}

.stats {
  display: grid;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stats > div {
  padding: var(--space-md);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.stat-label {
  display: block;
  margin-bottom: var(--space-xxs);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-subtle);
}

.stats strong {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.6px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--canvas);
}

.panel > .table-wrap,
.analytics-result.panel > .table-wrap {
  border: none;
  border-radius: 0;
  background: transparent;
  margin-left: calc(-1 * var(--space-lg));
  margin-right: calc(-1 * var(--space-lg));
  margin-bottom: calc(-1 * var(--space-lg));
}

.panel > .table-wrap th:first-child,
.analytics-result.panel > .table-wrap th:first-child,
.panel > .table-wrap td:first-child,
.analytics-result.panel > .table-wrap td:first-child {
  padding-left: var(--space-lg);
}

.panel > .table-wrap th:last-child,
.analytics-result.panel > .table-wrap th:last-child,
.panel > .table-wrap td:last-child,
.analytics-result.panel > .table-wrap td:last-child {
  padding-right: var(--space-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

th {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--ink-subtle);
  background: var(--surface-2);
}

tr:last-child td {
  border-bottom: none;
}

td {
  color: var(--ink-muted);
}

td a {
  color: var(--primary);
  word-break: break-all;
}

td:first-child {
  color: var(--ink);
  font-weight: 500;
}

.campaign-page td:nth-child(2) {
  max-width: 220px;
  word-break: break-word;
  color: var(--ink-subtle);
  font-weight: 400;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.status-badge.is-active {
  background: rgba(39, 166, 68, 0.15);
  color: var(--semantic-success);
}

.mono,
.tracking-id {
  font-family: var(--font-mono);
  font-size: 13px;
}

.form-error {
  margin: var(--space-sm) 0 0;
  color: var(--warn);
  font-size: 14px;
}

.form-success {
  margin: var(--space-sm) 0 0;
  color: var(--ok, #2f6b3a);
  font-size: 14px;
}

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-lg);
}

#target-urls a {
  display: inline-block;
  margin-bottom: var(--space-xxs);
}

/* ——— Preview / 404 ——— */

.preview-page {
  padding-top: var(--space-section);
}

.preview-progress {
  width: min(280px, 100%);
  height: 4px;
  margin: var(--space-lg) 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}

.preview-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary);
  animation: progress-fill 3s linear forwards;
}

@keyframes progress-fill {
  to {
    width: 100%;
  }
}

.not-found {
  padding-top: var(--space-section);
}

.ip-copy {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
}

/* ——— Responsive ——— */

@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
    gap: var(--space-md);
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 0 var(--space-md);
  }

  .site-header nav {
    gap: var(--space-sm);
  }

  .site-header nav a {
    font-size: 13px;
  }

  .container,
  .analytics-page,
  .campaign-page,
  .not-found,
  .preview-page {
    padding: var(--space-xl) var(--space-md) var(--space-xxl);
  }

  header h1,
  .analytics-page h1,
  .campaign-page h1,
  .container > header h1 {
    font-size: 1.75rem;
    letter-spacing: -0.6px;
  }

  .lede {
    font-size: 16px;
  }
}

/* ——— Lead management ——— */

.leads-page .lead-row {
  cursor: pointer;
}

.leads-page .lead-row:hover td {
  background: var(--surface-2);
}

.leads-page .lead-row.is-selected td {
  background: var(--surface-3);
}

.leads-page .lead-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.lead-detail {
  margin-top: var(--space-lg);
  padding: var(--space-lg);
}

.lead-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-md);
  margin: 0;
}

.lead-detail-grid dt {
  margin: 0 0 var(--space-xxs);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

.lead-detail-grid dd {
  margin: 0;
  font-size: 14px;
  color: var(--ink-muted);
  word-break: break-word;
}

.lead-detail-grid code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
}
