/* WildSun CRM — one plain stylesheet, shared by every page and fragment. */
:root {
  --text: #1a1a1a;
  --muted: #666;
  --border: #e2e2e2;
  --bg: #fff;
  --hover: #f6f8fa;
  --accent: #0b5fff;
  --danger: #c1121f;
}

* { box-sizing: border-box; }

/* Type scale: 12 / 15 / 19 / 24 / 28. Each step is at least a 1.25 ratio.
   Every small label is 12px. Two labels at 11px and 12px read as an accident. */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  margin: 0;
}

.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
/* The list holds six columns, so it uses the screen. 1100px cut every column
   to an ellipsis. The person page stays at 1100px, where prose reads better. */
.container.wide { max-width: 1760px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.dash { color: var(--muted); }

/* Search page header */
header.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
header.top h1 { font-size: 24px; margin: 0; }
header.top p { margin: 0; }

/* Search box */
.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
}
.searchbox:focus-within { border-color: var(--accent); }
.scope { color: var(--muted); }
#q {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font-size: 16px;
  padding: 10px 0;
}

/* Filter bar. The controls wrap, so a narrow window keeps every one reachable. */
.filterbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-items: end;
  gap: 10px 14px;
  margin: 12px 0 4px;
}
.filterbar label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.filterbar input,
.filterbar select {
  font: inherit;
  font-size: 15px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  /* 130px lets all six controls sit on one row inside the 1100px container.
     At 150px the last one wrapped and left a gap. */
  width: 100%;
  min-width: 0;
}
.filterbar input:focus,
.filterbar select:focus { border-color: var(--accent); outline: 0; }
.filterbar .clear { align-self: center; }

/* Search row: the box, the Filters button, the in-flight hint */
.searchrow { display: flex; align-items: center; gap: 12px; }
.searchrow .searchbox { flex: 1; }

/* Active-filter chips, so the state reads without opening the modal */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; }
.chips-lead { color: var(--muted); }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--hover);
}
.chip-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.chip-drop {
  padding: 0 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.chip-drop:hover { color: var(--danger); text-decoration: none; }

/* Modal. It opens with :target, so it needs no JavaScript. */
.modal { display: none; }
.modal:target {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 10;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow: auto;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
/* Elevation only, no border. A hairline edge under a wide shadow states the same
   thing twice, and the dimmed backdrop already separates the panel from the page. */
.modal-panel {
  position: relative;
  width: min(680px, 100%);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 20px 24px 16px;
}
.modal-head { display: flex; align-items: baseline; justify-content: space-between; }
.modal-head h2 { margin: 0; }
.modal-x { font-size: 24px; line-height: 1; color: var(--muted); text-decoration: none; }
.modal-x:hover { color: var(--text); text-decoration: none; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  line-height: 1.5;
  cursor: pointer;
}
.btn:hover { background: #0a50d6; }
.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--hover); }

/* In-flight hint (shown by htmx via the htmx-request class) */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Results table — dense, one hover colour, nothing else moves */
table.results {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-top: 8px;
}
.results th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.results td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
/* Only the cells that open the person page show the hand cursor. */
.results tbody td[hx-get] { cursor: pointer; }
.lastact .when { color: var(--muted); }
.results tbody tr:hover { background: var(--hover); }
/* Six columns in 1100px. Each one truncates, and the full value sits in title. */
.results th:nth-child(1) { width: 16%; }
.results th:nth-child(2) { width: 17%; }
.results th:nth-child(3) { width: 15%; }
.results th:nth-child(4) { width: 19%; }
.results th:nth-child(5) { width: 15%; }
.results th:nth-child(6) { width: 18%; }

/* A company name in this data can run to 80 characters, because it carries the whole
   Amazon store title. Without this a single row grows to five lines. The full value
   stays in the title attribute. */
.role, .email, .company, .website, .lastact {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;
}

/* A record with no person name is a company inbox, e.g. info@example.co.uk.
   4,868 of them arrived with the data_ssot merge. */
.inbox { color: var(--muted); font-style: italic; }

/* Grouped filters inside the modal */
.filtergroup {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0;
  padding: 14px 0 4px;
}
.filtergroup:first-of-type { border-top: 0; padding-top: 6px; }
.filtergroup legend {
  padding: 0 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Do-not-contact pill */
.pill {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  background: #fbe5e7;
  color: var(--danger);
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

.count { color: var(--muted); margin: 16px 0 0; }

/* Page controls */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 20px 0 8px;
}
.pager .pageof { color: var(--muted); }
.btn.disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.5;
}
.btn.disabled:hover { background: #fff; }

/* Person page */
.crumb { margin: 0 0 12px; }

#person-header { margin: 4px 0 8px; }
#person-header h1 { font-size: 28px; margin: 0; }
#person-header .pill { margin-left: 8px; }
#person-header .sub { color: var(--muted); margin: 2px 0 12px; }

/* 19px against the 15px body is a 1.27 ratio. At 16px the ratio was 1.07, and a
   section heading read as bold body text. */
h2 { font-size: 19px; margin: 28px 0 6px; }

dl.details {
  display: grid;
  grid-template-columns: 160px 1fr;
  column-gap: 16px;
  margin: 8px 0;
}
dl.details dt { color: var(--muted); padding: 4px 0; }
dl.details dd { margin: 0; padding: 4px 0; overflow-wrap: anywhere; }

/* Log section: primary button beside the note box */
/* The Log row is one form: a box and two buttons. The box takes the free width, so
   the placeholder is readable. At 340px fixed it shrank to a few characters. */
.logrow {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin: 8px 0 20px;
  max-width: 820px;
}
/* Four rows, and the user can drag it taller. A one-row box made a long note hard
   to read back while typing it. */
.logrow textarea { width: 100%; max-width: 100%; resize: vertical; min-height: 88px; }
.logbuttons { display: flex; gap: 12px; }
/* A plain-text button, used for Edit on a timeline row. */
.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }

/* One timeline row, open for editing */
.editrow { display: flex; gap: 8px; align-items: center; flex: 1; flex-wrap: wrap; }
.editrow input {
  flex: 1;
  min-width: 220px;
  font: inherit;
  color: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.editrow input:focus { border-color: var(--accent); outline: 0; }
ul.timeline .what { flex: 1; }
textarea {
  font: inherit;
  color: inherit;
  width: 340px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
textarea:focus { border-color: var(--accent); outline: 0; }

/* Timeline: muted date on the left, body on the right */
ul.timeline { list-style: none; margin: 8px 0; padding: 0; }
ul.timeline li {
  display: flex;
  gap: 16px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
ul.timeline .when { color: var(--muted); white-space: nowrap; min-width: 140px; }
.tag {
  padding: 0 6px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Reduced motion: nothing animates anyway; keep any future motion off. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
