/* Layout and components. Colors and fonts come only from theme.css tokens. */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
  margin: 0 0 16px;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }

a { color: var(--link); }

/* Top bar */
.topbar {
  background: var(--navy);
  color: var(--white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--white);
  text-decoration: none;
}
.topbar form { margin: 0; }
.topbar .btn-quiet {
  background: none;
  border: 1px solid var(--teal);
  color: var(--white);
  border-radius: var(--radius);
  padding: 6px 12px;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.footer {
  background: var(--navy);
  color: var(--white);
  font-size: 0.8rem;
  padding: 12px 16px;
  text-align: center;
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px var(--shadow);
  padding: 24px 20px;
}
.card-narrow { max-width: 400px; margin: 8vh auto 0; }

/* Forms */
label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
}
input[type="text"], input[type="password"], input[type="email"], input[type="tel"], input[type="url"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 48px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
.field { margin-bottom: 20px; }

/* Buttons: exactly one .btn-primary per screen/panel */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: var(--text);
  border: 1px solid var(--accent);
}
.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 2px solid var(--teal);
}
.btn-block { width: 100%; }

.error {
  color: var(--error);
  font-weight: 500;
  margin: 0 0 16px;
}
.muted { color: var(--text); opacity: 0.75; }

/* Status chip (gold always carries navy text) */
.chip {
  display: inline-block;
  background: var(--gold);
  color: var(--navy);
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius);
  padding: 2px 8px;
}

/* Nav tabs: teal underline marks the active screen */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 8px;
  background: var(--white);
  border-bottom: 1px solid var(--soft);
  overflow-x: auto;
}
.tabs a {
  padding: 12px;
  color: var(--navy);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tabs a[aria-current="page"] { border-bottom-color: var(--teal); font-weight: 700; }

fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
legend { font-weight: 500; padding: 0; margin-bottom: 8px; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-weight: 400;
  margin: 0;
}
input[type="checkbox"], input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--link);
  flex: none;
}

.estimate { margin-bottom: 16px; }
.estimate p { margin: 0; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }

.htmx-indicator { display: none; margin: 12px 0 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

.results { margin-top: 24px; }
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--soft); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th {
  background: var(--soft);
  color: var(--navy);
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
}
td { padding: 10px 12px; border-top: 1px solid var(--soft); vertical-align: top; }
tbody tr:hover { background: var(--soft); }
.nowrap { white-space: nowrap; }

/* Lookup candidates */
.option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-weight: 400;
  padding: 12px;
  margin: 0 0 12px;
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  cursor: pointer;
}
.option:has(input:checked) { border-color: var(--teal); background: var(--soft); }
.option input { margin-top: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Lead detail + research */
.card + .card { margin-top: 16px; }
.small { font-size: 0.85rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { font-weight: 500; color: var(--navy); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.brief p { margin: 0 0 12px; }
.pains { padding-left: 20px; margin: 0 0 12px; }
.pains li { margin-bottom: 10px; }
.signals { padding-left: 18px; font-size: 0.875rem; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--link); font-weight: 500; }
.research-item { border-top: 1px solid var(--soft); padding-top: 16px; margin-top: 16px; }
.contacts { list-style: none; padding: 0; margin: 0; }
.contacts li { padding: 10px 0; border-top: 1px solid var(--soft); overflow-wrap: anywhere; }
.contacts li:first-child { border-top: 0; }

/* Contact confidence badges */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius);
  padding: 2px 8px;
  margin-right: 4px;
}
.badge-verified_on_site { background: var(--link); color: var(--white); }
.badge-inferred { background: var(--soft); color: var(--navy); }
.badge-guessed { background: var(--gold); color: var(--navy); }

/* Sequence + pipeline */
textarea { min-height: 120px; line-height: 1.45; resize: vertical; }
.footer-preview, .body-preview {
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 0.875rem;
  background: var(--soft);
  border-radius: var(--radius);
  padding: 12px;
  margin: 0 0 16px;
}
.touch-list { padding-left: 20px; margin: 0; }
.touch-list li { margin-bottom: 10px; }

/* Add Company: photo */
.file-btn { cursor: pointer; margin: 0 0 8px; }
.photo-card .muted { margin: 0; }
.or { text-align: center; margin: 16px 0; font-weight: 500; color: var(--navy); }
.extracted { background: var(--soft); border-left: 4px solid var(--teal); border-radius: var(--radius); padding: 12px; margin-bottom: 20px; }
.extracted p { margin: 0 0 6px; }
.wrap { overflow-wrap: anywhere; }
.err-row td { border-top: 0; padding-top: 0; }

/* Pipeline status tiles: the whole tile is the link */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; }
.stat,
.stat:link,
.stat:visited,
.stat:hover,
.stat:active {
  display: flex;
  flex-direction: column;
  background: var(--soft);
  color: var(--text);
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 12px;
}
.stat:hover { border-color: var(--teal); }
.stat.stat-active { border-color: var(--navy); background: var(--soft); color: var(--navy); }
.stat-n { font-family: var(--font-heading); font-weight: 700; font-size: 1.5rem; color: var(--navy); }
.stat-label { font-size: 0.8rem; }
.stat.stat-active .stat-label { font-weight: 700; }

/* Sequence touch chips */
.touch-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.tchip { font-size: 0.72rem; font-weight: 700; border-radius: var(--radius); padding: 2px 6px; white-space: nowrap; border: 1px solid var(--soft); color: var(--navy); background: var(--white); }
.tchip-drafted { background: var(--gold); border-color: var(--gold); }
.tchip-sent, .tchip-replied { background: var(--link); border-color: var(--link); color: var(--white); }
.tchip-cancelled { color: var(--text); opacity: 0.6; text-decoration: line-through; }
