/* Leads portal styles, shared by both pages. System fonts only, no external files.
   Part 1 is the shared look (tokens, header, panels, buttons, pills, tiles, tables, forms).
   Part 2 is the contractor page. admin.css adds the admin-only layout on top of part 1. */

:root {
  --navy: #12233f;
  --navy-2: #1c3358;
  --orange: #f08804;             /* logo mark and the admin's main action only */
  --orange-hover: #ffa02b;
  --blue: #1d6fd8;               /* white text on this is 4.9:1 */
  --action: #1d6fd8;
  --action-hover: #175bb3;
  --blue-soft: #e7f0fc;
  --blue-text: #134f9e;
  --blue-line: #c9dbf2;
  --bg: #edf2f8;                 /* pale blue-grey page */
  --card: #ffffff;
  --text: #1a2638;
  --muted: #4b5b72;
  --quiet: #7a889c;
  --line: #d3deec;               /* panel borders */
  --grid: #cbd8ea;               /* table cell borders */
  --head: #e3ecf8;               /* table header row */
  --zebra: #f6f9fe;
  --hover: #dceafd;
  --dirty: #fff6dc;
  --field-line: #9fb0c7;
  --ok: #17663a;
  --ok-soft: #e1f4e8;
  --amber: #7a4f00;
  --amber-soft: #fff1d1;
  --amber-line: #d99a00;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --grey: #3d4f68;
  --grey-soft: #e9eef6;
  --call: #1a7f45;               /* white text on this is 5.0:1 */
  --call-hover: #156a39;
  --call-soft: #e6f5ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 35, 63, 0.05), 0 6px 18px rgba(18, 35, 63, 0.06);
  --page-max: 1400px;
  --gutter: 28px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4 { color: var(--navy); line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute; left: 0.5rem; top: -4rem; z-index: 50;
  background: var(--blue); color: #fff; font-weight: 700;
  padding: 0.75rem 1rem; border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 0.5rem; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.topbar :focus-visible { outline-color: #8fc0ff; }

/* ============================================================ PART 1: shared */

/* ------------------------------------------------------------ header and frame */

.topbar { background: var(--navy); color: #fff; }
.topbar-inner, .topbar-biz, main {
  max-width: var(--page-max); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-mark { display: block; flex: none; }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.01em; }
.brand-tag {
  padding: 0.1rem 0.6rem; border-radius: 999px; background: rgba(255, 255, 255, 0.16);
  color: #fff; font-weight: 600; font-size: 0.95rem;
}
.topbar-biz { padding-bottom: 1rem; }
.biz-name { margin: 0; font-size: 1.15rem; font-weight: 600; color: #dfe9f7; unicode-bidi: plaintext; }

.menu { position: relative; }
.menu-button {
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 48px; min-width: 48px; padding: 0 0.9rem;
  background: transparent; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 10px; cursor: pointer;
}
.menu-button:hover { background: var(--navy-2); }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  list-style: none; margin: 0; padding: 0.4rem;
  min-width: 13rem; max-width: calc(100vw - 2rem);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(18, 35, 63, 0.22);
}
.menu-list button, .menu-list a {
  display: flex; align-items: center; width: 100%; min-height: 48px; padding: 0 1rem;
  background: none; border: 0; border-radius: 8px; text-align: left;
  color: var(--navy); cursor: pointer; text-decoration: none; font-weight: 400;
}
.menu-list button:hover, .menu-list a:hover { background: var(--blue-soft); }
.menu-list :focus-visible { outline-color: var(--blue); outline-offset: -3px; }

.mock-banner {
  margin: 0; padding: 0.6rem 1rem; text-align: center;
  background: #fff4d6; color: #5b3d00; border-bottom: 1px solid #f0d58a; font-weight: 600;
}

main { display: block; padding-top: 24px; padding-bottom: 48px; }
main:focus { outline: none; }

/* Admin "view as contractor": read only banner with an Exit button */
.view-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px var(--gutter); background: var(--amber-soft); color: var(--amber); border-bottom: 2px solid var(--amber-line); font-weight: 700;
}
.view-banner[hidden] { display: none; }
.view-banner-text { margin: 0; }
.view-exit { flex: 0 0 auto; }
.lead.is-viewing .chip, .lead.is-viewing textarea, .lead.is-viewing .btn-save { cursor: not-allowed; }

/* ------------------------------------------------------------ sign-in style cards */

.screen-narrow { max-width: 28rem; margin: 1.5rem auto 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem;
}
.card h1 { margin-bottom: 0.4rem; }
.intro { color: var(--muted); }
.help { margin: 1.25rem 0 0; color: var(--muted); }
.loading { display: flex; align-items: center; justify-content: center; gap: 0.75rem; padding: 3rem 0; color: var(--muted); }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--blue-line); border-top-color: var(--blue);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { max-width: 28rem; margin: 2rem auto; padding: 1rem; background: #fff; border-radius: 12px; }

/* ------------------------------------------------------------ forms */

.field { margin-bottom: 1rem; }
.field label, .lbl { display: block; font-weight: 600; color: var(--navy); margin-bottom: 0.35rem; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"], textarea, select {
  display: block; width: 100%;
  min-height: 48px; padding: 0.6rem 0.8rem;
  background: #fff; border: 1px solid var(--field-line); border-radius: 10px; font-size: 1rem;
}
select { padding-right: 28px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { border-color: var(--blue); outline-offset: 0; }
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.45; }
.hint { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.95rem; }
.form-error { padding: 0.75rem 0.9rem; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.notice, .page-note { padding: 0.75rem 0.9rem; border-radius: 10px; background: var(--blue-soft); color: var(--navy); }
.page-note { background: var(--ok-soft); color: var(--ok); font-weight: 600; margin-bottom: 16px; }

/* ------------------------------------------------------------ buttons: no dark fills anywhere */

/* Large buttons (sign in, dialogs, pager) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; padding: 0.6rem 1.2rem;
  border-radius: 10px; border: 1.5px solid transparent;
  font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn:disabled { cursor: default; opacity: 0.55; }
.btn-block { width: 100%; }
.btn-block + .btn-block { margin-top: 0.75rem; }
.btn-primary, .btn-save { background: var(--action); color: #fff; }
.btn-primary:hover:not(:disabled), .btn-save:hover:not(:disabled) { background: var(--action-hover); }
.btn-secondary { background: #fff; color: var(--action); border-color: var(--action); }
.btn-secondary:hover:not(:disabled) { background: var(--blue-soft); }
.link-button {
  min-height: 48px; padding: 0; background: none; border: 0;
  color: var(--blue); font-weight: 600; text-decoration: underline; cursor: pointer;
}

/* Compact buttons (panel bars, tables) */
.btn-a {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 1rem; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.btn-a:disabled { opacity: 0.5; cursor: default; }
.btn-main { background: var(--orange); color: var(--navy); }
.btn-main:hover:not(:disabled) { background: var(--orange-hover); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover:not(:disabled) { background: var(--action-hover); }
.btn-outline { background: #fff; color: var(--blue); border-color: var(--blue); }
.btn-outline:hover:not(:disabled) { background: var(--blue-soft); }
.btn-danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn-xs { min-height: 34px; padding: 0 10px; font-size: 0.95rem; }

/* On/off switch built from a button with role="switch" */
.switch {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px 0 6px;
  border: 1.5px solid var(--field-line); border-radius: 999px; background: #fff; color: var(--grey);
  font-weight: 700; cursor: pointer; white-space: nowrap;
}
.switch-track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #b8c4d4; flex: none; transition: background-color 0.12s ease; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.12s ease; }
.switch[aria-checked="true"] { border-color: #3fa96b; color: var(--ok); background: var(--ok-soft); }
.switch[aria-checked="true"] .switch-track { background: #2f9a5c; }
.switch[aria-checked="true"] .switch-knob { transform: translateX(16px); }

/* ------------------------------------------------------------ pills and quiet text */

.pill {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px;
  font-size: 0.95rem; font-weight: 700; white-space: nowrap; line-height: 1.5;
}
.pill-green { background: var(--ok-soft); color: var(--ok); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--bad-soft); color: var(--bad); }
.pill-blue { background: var(--blue-soft); color: var(--blue-text); }
.pill-grey { background: var(--grey-soft); color: var(--grey); }
.pill-orange { background: var(--orange); color: var(--navy); }
.none { color: var(--quiet); white-space: nowrap; }
.quiet { color: var(--quiet); }
.small { font-size: 0.95rem; color: var(--muted); }
.warn { color: var(--bad); font-weight: 700; font-size: 0.95rem; }
.strong { font-weight: 700; color: var(--navy); }
.tel-link { color: var(--blue); font-weight: 700; white-space: nowrap; }
.user-text { unicode-bidi: plaintext; overflow-wrap: anywhere; }
.row-msg, .save-msg { font-weight: 700; font-size: 0.95rem; }
.row-msg { white-space: nowrap; }
.row-msg.is-ok, .save-msg.is-ok { color: var(--ok); }
.row-msg.is-ok::before, .save-msg.is-ok::before { content: "\2713  "; }
.row-msg.is-bad, .save-msg.is-bad { color: var(--bad); white-space: normal; }

/* ------------------------------------------------------------ panels */

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 24px; min-width: 0;
}
.panel-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  background: linear-gradient(#f7faff, #eef4fc); border-radius: var(--radius) var(--radius) 0 0;
}
.bar-title { min-width: 0; flex: 1 1 14rem; }
.bar-title h2 { margin: 0; font-size: 1.35rem; color: var(--navy); }
.bar-sub { margin: 0.2rem 0 0; color: var(--muted); }
.bar-actions { display: flex; gap: 10px; align-items: center; }
.panel-body { padding: 20px; min-width: 0; }
.bar-status:empty { display: none; }
.bar-status { margin: 0 0 12px; color: var(--muted); }
.sub-title { margin: 24px 0 12px; font-size: 1.1rem; color: var(--navy); }

/* Filters: one tidy line, labels above, all controls the same height */
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.f-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f-field > label, .f-label-spacer { font-size: 0.95rem; font-weight: 600; color: var(--navy); line-height: 1.3; margin: 0; }
.f-label-spacer { visibility: hidden; }
.filters select, .filters input[type="search"], .filters input[type="text"] { min-height: 40px; padding: 6px 10px; border-radius: 8px; width: 13rem; }
.filters select { padding-right: 28px; }
.f-small select { width: 9.5rem; }
.f-tiny select { width: 6rem; }
.f-search input { width: 18rem; }
.check {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--field-line); border-radius: 8px; background: #fff; cursor: pointer; white-space: nowrap; font-weight: 600; color: var(--navy);
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }

/* ------------------------------------------------------------ summary tiles */

.stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.stat-link-wrap { display: flex; }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px;
  background: linear-gradient(#ffffff, #f4f8fe); border-top: 4px solid var(--blue); text-align: left;
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.04);
}
.stat-num { font-size: 2rem; font-weight: 800; color: var(--navy); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-weight: 600; }
.stat-money, .stat-good { border-top-color: #3fa96b; }
.stat-link { cursor: pointer; font: inherit; color: inherit; }
.stat-link:hover { border-color: var(--blue); }
.stat-link.is-alert { background: linear-gradient(#fff8e6, #fff1d1); border-color: #f0c66b; border-top-color: var(--orange); }
.stat-link.is-alert .stat-num { color: var(--amber); }
.stat-go { color: var(--blue); font-weight: 700; text-decoration: underline; }

/* ------------------------------------------------------------ spreadsheet tables */

/* position: relative keeps hidden labels inside the scroll box, so they cannot widen the page */
.grid-scroll, .grid-plain { position: relative; }
.grid-scroll { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--grid); border-radius: 10px; }
.grid-plain { overflow-x: auto; border: 1px solid var(--grid); border-radius: 10px; }
.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; font-size: 1rem; }
.grid th, .grid td {
  border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid);
  padding: 8px 10px; text-align: left; vertical-align: top; line-height: 1.45;
}
.grid th:last-child, .grid td:last-child { border-right: 0; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid th {
  position: sticky; top: 0; z-index: 2; background: var(--head); color: var(--navy);
  font-weight: 700; font-size: 0.95rem; white-space: nowrap; vertical-align: bottom;
  box-shadow: inset 0 -1px 0 var(--grid);
}
.grid tbody tr:nth-child(even) td { background: var(--zebra); }
.grid tbody tr:hover td { background: var(--hover); }
.grid tbody tr.is-dirty td { background: var(--dirty); }
.grid .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid .nowrap { white-space: nowrap; }
.cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.cell-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.cell-line.nowrap-line { flex-wrap: nowrap; }
.empty-line { margin: 0; padding: 28px 16px; text-align: center; color: var(--quiet); border: 1px dashed var(--grid); border-radius: 10px; }

/* Money input with a pound sign */
.money { display: inline-flex; align-items: stretch; }
.money-wrap { display: inline-flex; }
.money-sign {
  display: inline-flex; align-items: center; padding: 0 8px; min-height: 40px;
  background: var(--blue-soft); border: 1px solid var(--field-line); border-right: 0; border-radius: 8px 0 0 8px;
  font-weight: 700; color: var(--navy);
}
.money .money-input {
  width: 110px; min-height: 40px; padding: 6px 10px; border-radius: 0 8px 8px 0;
  text-align: right; font-variant-numeric: tabular-nums;
}
.money-input.is-dirty { border-color: var(--amber-line); background: #fffaf0; }

/* Pager */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.pager .range { margin: 0; color: var(--muted); font-weight: 600; }

/* ------------------------------------------------------------ dialogs */

.dialog {
  width: min(28rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
  color-scheme: light;
  padding: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(18, 35, 63, 0.3); background: var(--card); color: var(--text);
}
.dialog::backdrop { background: rgba(18, 35, 63, 0.5); }
.dialog h2 { font-size: 1.35rem; margin-bottom: 1rem; }
.dialog-actions, .dialog-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.confirm-message { white-space: pre-line; }

/* ============================================================ PART 2: contractor page */

.stats.summary { margin-bottom: 24px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stats.summary .tile-owed { grid-column: 1 / -1; }
.list-status:empty { display: none; }
.list-status { margin: 0 0 12px; color: var(--muted); }

/* Enquiries: cards on phones and tablets, spreadsheet rows on wide screens */
.list-head { display: none; }
.lead-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.lead {
  display: flex; flex-direction: column; min-width: 0;
  background: #fff; border: 1px solid var(--grid); border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(18, 35, 63, 0.05);
}
.lead > * { min-width: 0; padding: 12px 16px; }
.lead.is-emergency { border-left: 5px solid var(--bad); }
.lead.is-dirty { border-color: var(--amber-line); box-shadow: 0 0 0 2px var(--amber-soft); }

/* Card order on phones: name and Call, when and cost, area, the job, then status */
.lead .c-who { order: 0; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.lead .c-when { order: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding-top: 0; color: var(--muted); font-weight: 600; }
.lead .c-area { order: 2; padding-top: 0; }
.lead .c-job { order: 3; border-top: 1px solid var(--grid); }
.lead .c-update { order: 4; border-top: 1px solid var(--grid); background: #f7faff; display: grid; gap: 12px; padding-bottom: 16px; }

.lead .name { margin: 0; font-size: 1.2rem; color: var(--navy); unicode-bidi: plaintext; }
.is-missing { color: var(--quiet); font-weight: 400; }
.lead .no-phone { margin: 0; color: var(--muted); }
.lead .lbl { font-size: 0.95rem; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.lead .c-area .lbl { display: inline; margin-right: 0.4rem; }
.lead .c-area .lbl::after { content: ":"; }
.lead .c-area .val { unicode-bidi: plaintext; font-weight: 600; }
.lead .when { white-space: nowrap; }
.problem { margin: 0; white-space: pre-line; unicode-bidi: plaintext; }
.lead .facts { margin: 10px 0 0; display: grid; gap: 2px; }
.lead .fact { display: flex; flex-wrap: wrap; gap: 0 0.4rem; }
.lead .fact dt { color: var(--muted); }
.lead .fact dt::after { content: ":"; }
.lead .fact dd { margin: 0; font-weight: 600; unicode-bidi: plaintext; min-width: 0; }

/* Call: a calm green pill with a phone glyph; still the clearest action on the card */
.btn-call {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px 0 18px; border-radius: 999px; width: 100%;
  background: var(--call); color: #fff; border: 1.5px solid var(--call);
  font-weight: 700; font-size: 1.05rem; text-decoration: none; white-space: nowrap;
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(26, 127, 69, 0.25);
  transition: background-color 0.12s ease;
}
.btn-call:hover { background: var(--call-hover); }
.btn-call svg { flex: none; width: 20px; height: 20px; }

/* Queries: a pill for the state, then the reasons */
.query { margin-top: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--grid); background: #fff; display: grid; gap: 4px; justify-items: start; }
.query p { margin: 0; }
.query-detail { color: var(--text); unicode-bidi: plaintext; white-space: pre-line; font-size: 0.95rem; }

/* Status: a row of pill buttons. The chosen one gets a coloured tint and a tick, never a dark fill. */
.statuses { border: 0; margin: 0; padding: 0; min-width: 0; }
.statuses legend { padding: 0; }
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.chip { position: relative; display: block; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip span {
  display: flex; align-items: center; justify-content: center; gap: 4px; text-align: center;
  min-height: 48px; padding: 4px 6px;
  border: 1.5px solid var(--grid); border-radius: 999px; background: #fff;
  color: var(--navy); font-weight: 600; line-height: 1.2; overflow-wrap: normal;
}
.chip:hover span { border-color: var(--blue); background: var(--blue-soft); }
.chip input:checked + span { font-weight: 800; border-width: 2px; background: var(--blue-soft); border-color: var(--blue); color: var(--blue-text); }
.chip input:checked + span::before { content: "\2713"; }
.chip-won input:checked + span { background: var(--ok-soft); border-color: #3fa96b; color: var(--ok); }
.chip-lost input:checked + span { background: var(--bad-soft); border-color: #e0786e; color: var(--bad); }
.chip-not_valid input:checked + span { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.chip input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

.reason-box { border: 1.5px solid var(--amber-line); border-radius: 12px; padding: 12px; background: #fffaf0; }
.reason-box .hint { margin: 0 0 10px; color: var(--text); }
.starters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.starter {
  min-height: 48px; padding: 4px 14px; border-radius: 999px;
  border: 1.5px solid var(--grid); background: #fff; color: var(--blue-text); font-weight: 600; cursor: pointer;
}
.starter:hover { background: var(--blue-soft); border-color: var(--blue); }

.note-field .count { display: block; margin-top: 4px; color: var(--muted); font-size: 0.95rem; text-align: right; }
.lead .c-update textarea { background: #fff; }
.save-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.save-row .btn-save { min-width: 7rem; }

.empty { padding: 2rem 1.5rem; text-align: center; color: var(--muted); border: 1px dashed var(--grid); border-radius: 12px; }
.empty p { margin: 0; }

.contractor-page .pager .btn { min-width: 8rem; }

/* ------------------------------------------------------------ contractor: wider screens */

@media (min-width: 600px) {
  .stats.summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats.summary.has-owed { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats.summary .tile-owed { grid-column: auto; }
  .chips { grid-template-columns: repeat(6, minmax(0, auto)); justify-content: start; }
  .chip span { padding: 4px 14px; }
  .btn-call { width: auto; align-self: flex-start; }
}
@media (min-width: 960px) {
  .stats.summary.has-owed { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Spreadsheet rows: tinted sticky header, cell borders, zebra, hover */
@media (min-width: 1200px) {
  .lead-table { border: 1px solid var(--grid); border-radius: 10px; overflow: clip; }
  .list-head, .lead { display: grid; grid-template-columns: 10rem 14rem 8rem minmax(0, 1fr) 22rem; }
  .list-head {
    position: sticky; top: 0; z-index: 3; background: var(--head); color: var(--navy);
    font-weight: 700; font-size: 0.95rem; border-bottom: 1px solid var(--grid);
  }
  .list-head > span { padding: 8px 12px; border-right: 1px solid var(--grid); white-space: nowrap; }
  .list-head > span:last-child { border-right: 0; }
  .lead-list { gap: 0; }
  .lead { border: 0; border-bottom: 1px solid var(--grid); border-radius: 0; box-shadow: none; overflow: visible; }
  .lead:last-child { border-bottom: 0; }
  .lead:nth-child(even) { background: var(--zebra); }
  .lead:hover { background: var(--hover); }
  .lead > * { padding: 10px 12px; border-right: 1px solid var(--grid); border-top: 0 !important; order: 0 !important; }
  .lead > :last-child { border-right: 0; }
  .lead .c-who { padding-top: 10px; gap: 8px; }
  .lead .c-when { flex-direction: column; align-items: flex-start; padding-top: 10px; }
  .lead .c-area { padding-top: 10px; }
  .lead .c-update { background: transparent; padding-bottom: 12px; align-content: start; }
  .lead.is-emergency { border-left: 0; }
  .lead.is-emergency > :first-child { box-shadow: inset 4px 0 0 var(--bad); }
  .lead.is-dirty { box-shadow: none; background: var(--dirty); }
  .lead.is-dirty > :first-child { box-shadow: inset 4px 0 0 var(--amber-line); }
  .lead .c-area .lbl, .lead .c-job > .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .lead .name { font-size: 1.05rem; }
  /* Nobody taps to call from a desktop: a slimmer outlined green button */
  .btn-call {
    width: 100%; min-height: 40px; padding: 0 12px; font-size: 0.95rem; gap: 6px;
    background: #fff; color: var(--call); box-shadow: none;
  }
  .btn-call:hover { background: var(--call-soft); }
  .btn-call svg { width: 16px; height: 16px; }
  .chips { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .chip span { min-height: 40px; padding: 4px 6px; font-size: 0.95rem; }
  .starter { min-height: 40px; }
  .lead .c-update { gap: 8px; }
  .lead .c-update textarea { min-height: 2.75rem; }
  .lead .statuses .lbl, .lead .note-field .lbl { font-size: 0.95rem; }
  .lead .save-row .btn-save { min-height: 40px; }
}

/* ------------------------------------------------------------ small screens: both pages */

@media (max-width: 999px) {
  :root { --gutter: 16px; }
  main { padding-top: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .panel-bar, .panel-body { padding: 14px; }
  .filters { width: 100%; }
  .f-field { flex: 1 1 8rem; }
  .filters select, .filters input[type="search"], .filters input[type="text"],
  .f-small select, .f-tiny select, .f-search input { width: 100%; min-height: 48px; }
  .filters .btn-a, .filters .check { min-height: 48px; }
  .f-label-spacer { display: none; }
  .f-check, .f-end { flex: 0 0 auto; justify-content: flex-end; }
}
@media (max-width: 599px) {
  .contractor-page .f-end { flex: 1 1 100%; }
  .contractor-page .f-end .btn-a { width: 100%; }
  .contractor-page .pager { display: grid; grid-template-columns: 1fr 1fr; }
  .contractor-page .pager .range { grid-column: 1 / -1; grid-row: 1; text-align: center; }
  .contractor-page .pager .btn { min-width: 0; }
  .dialog-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .chip input:checked + span { outline: 3px solid CanvasText; }
  .btn, .btn-a, .btn-call { border-color: ButtonText; }
}
