/* leadscrap — utilitarian lead-scraping console.
   System fonts only. Light + dark via prefers-color-scheme. */

:root {
  color-scheme: light dark;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #eef0f2;
  --border: #d5d9dd;
  --text: #1c2126;
  --text-muted: #5b646d;

  --accent: #1f7a4d;          /* an actionable lead — worth contacting */
  --accent-strong: #135f3a;
  --accent-tint: #e4f2ea;

  --warn: #9a6a00;            /* errors / warnings — attention, not alarm */
  --warn-tint: #fbf3e0;

  --link: #1256a8;

  --radius: 6px;
  --pad: 1rem;
  --maxw-form: 40rem;
  --maxw-page: 78rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --surface-2: #24292e;
    --border: #363c42;
    --text: #e7eaed;
    --text-muted: #9aa4ad;

    --accent: #46b47e;
    --accent-strong: #6fce9c;
    --accent-tint: #1a3a2b;

    --warn: #d7a63c;
    --warn-tint: #352e18;

    --link: #6db1f2;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: 0 var(--pad) 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

header {
  max-width: var(--maxw-page);
  margin: 0 auto;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

header a { color: var(--text); text-decoration: none; letter-spacing: 0.02em; }

main {
  max-width: var(--maxw-page);
  margin: 0 auto;
  padding-top: 1.5rem;
}

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

h1 { font-size: 1.4rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 0.75rem; }

/* --- Job form: the hero of the index page --------------------------------- */

#job-form {
  max-width: var(--maxw-form);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: grid;
  gap: 1.1rem;
}

#job-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
}

#job-form input[type="text"],
#job-form input:not([type]),
#job-form select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#job-form input:focus-visible,
#job-form select:focus-visible,
button:focus-visible,
a:focus-visible,
th[data-sort]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#job-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

#job-form fieldset legend { padding: 0 0.4rem; font-weight: 600; }

#job-form fieldset label {
  flex-direction: row;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 400;
}

button,
#job-form button[type="submit"] {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.55rem 1.1rem;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent-strong);
  border-radius: var(--radius);
}

button:hover { background: var(--accent-strong); }

#job-form button[type="submit"] { justify-self: start; }

#cancel {
  color: var(--warn);
  background: transparent;
  border-color: var(--warn);
}

#cancel:hover { background: var(--warn-tint); }

/* --- Status line -------------------------------------------------------- */

#status { font-weight: 600; }
#status #progress-msg { font-weight: 400; color: var(--text-muted); }

/* --- Error / warning block ------------------------------------------------ */

.error {
  max-width: var(--maxw-form);
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--warn);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--warn-tint);
  color: var(--text);
}

/* --- Filters bar ------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0 0.75rem;
}

.filters label { display: inline-flex; align-items: center; gap: 0.4rem; }

#f-text {
  padding: 0.4rem 0.6rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 14rem;
}

#csv {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

/* --- Tables ----------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 0.55rem 0.7rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]::after { content: " \2195"; color: var(--text-muted); font-size: 0.85em; }

tbody td {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:nth-child(even) { background: var(--surface); }
tbody tr:nth-child(odd) { background: var(--bg); }
tbody tr:hover { background: var(--surface-2); }

/* numeric-ish columns read better monospaced */
#results td:nth-child(4),
#results td:nth-child(5) { font-family: var(--font-mono); white-space: nowrap; }

/* Target column: the payoff — emphasised with the accent tint */
#results th[data-sort="is_target"],
#results td.target {
  text-align: center;
  background: var(--accent-tint);
  font-weight: 700;
  color: var(--accent-strong);
}

#jobs td, #jobs th { white-space: nowrap; }

/* --- Social chips ---------------------------------------------------- */

.chip {
  display: inline-block;
  margin: 0.1rem 0.15rem 0.1rem 0;
  padding: 0.1rem 0.55rem;
  font-size: 0.8rem;
  line-height: 1.5;
  text-decoration: none;
  color: var(--link);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

.chip:hover { border-color: var(--link); }

/* --- Responsive ------------------------------------------------------ */

@media (max-width: 40rem) {
  body { padding: 0 0.75rem 3rem; }
  #job-form { padding: 1.1rem; border-radius: 0; margin-inline: -0.75rem; }
  h1 { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
