/* Lead Hunter app - Leadsun look. Minimal: white and light grey, charcoal text, one red accent.
   Red (#F9423A) is only for the active tab marker, the main button and the logo.
   CSP is style-src 'self': no inline styles anywhere. */

@font-face { font-family: "Lato"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/lato-400.woff2") format("woff2"); }
@font-face { font-family: "Lato"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/lato-700.woff2") format("woff2"); }
@font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-display: swap; src: url("fonts/opensans-latin.woff2") format("woff2"); }

:root {
  --bg: #F7F7F7; --surface: #FFFFFF; --line: #E6E6E6; --line-soft: #EFEFEF;
  --text: #3A3A3A; --text-2: #555555; --muted: #7A7A7A; --red: #F9423A; --red-hover: #E5332B;
  --keep: #1F7A45; --keep-bg: #EAF5EE; --review: #9A5B00; --review-bg: #FFF4E0; --removed: #7A2E2A; --removed-bg: #F8E9E7;
  --radius: 12px; --sidebar: 232px; --tabbar: 64px;
  --head: "Lato", "Segoe UI", Arial, sans-serif; --body: "Open Sans", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--body); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; color: var(--text); }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }
img { display: block; max-width: 100%; height: auto; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sr-only:focus { position: fixed; top: 8px; left: 8px; width: auto; height: auto; clip: auto; padding: 8px 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; z-index: 100; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 26px 0 16px; }
.sidebar .brand { padding: 0 24px 30px; }
.sidebar .brand img { width: 150px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; height: 42px; padding: 0 20px 0 24px; color: var(--text-2); font-size: 14px; text-align: left; }
.nav-item:hover { background: #FAFAFA; color: var(--text); }
.nav-item[aria-current="page"] { color: var(--text); font-weight: 700; background: #FAFAFA; }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 2px 2px 0; background: var(--red); }
.nav-item .icon { width: 18px; height: 18px; color: var(--muted); }
.nav-item[aria-current="page"] .icon { color: var(--text); }
.nav-count { margin-left: auto; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; font-size: 11px; font-weight: 700; background: var(--review-bg); color: var(--review); }
.nav-count + .nav-badge { margin-left: -4px; }
.spacer { flex: 1; }
.nav-user { margin-top: 12px; padding: 16px 24px 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; }
.nav-user strong { font-size: 13.5px; }
.nav-user span { font-size: 12px; color: var(--muted); }
.nav-out { margin: 0; }

.topbar { display: none; }
.tabbar { display: none; }
.main { min-width: 0; width: 100%; max-width: 1240px; padding: 40px 52px 56px; }

/* ---------- messages ---------- */
.flash { margin-bottom: 16px; padding: 10px 14px; border-radius: 10px; background: var(--keep-bg); color: var(--keep); font-size: 13.5px; }
.flash.bad { background: var(--removed-bg); color: var(--removed); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: min(92vw, 460px); padding: 10px 16px; border-radius: 10px; background: var(--text); color: #fff; font-size: 13.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.toast.bad { background: var(--removed); }

/* ---------- type helpers ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sub { color: var(--text-2); font-size: 13.5px; margin-top: 3px; }
.big { font-family: var(--head); font-size: 22px; font-weight: 700; margin: 2px 0 4px; }
.label { font-family: var(--head); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- page head ---------- */
.page-head { margin-bottom: 22px; }
.page-head.row-between { align-items: flex-end; }
.page-head h1 { font-size: 28px; letter-spacing: -.01em; line-height: 1.2; }
.page-head > .muted, .page-head div > .muted { margin-top: 4px; }
.page-head p.row-between { margin-top: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; color: var(--muted); font-size: 13px; font-weight: 600; }
.back .icon { width: 16px; height: 16px; }
.back:hover { color: var(--text); }

/* ---------- panels, tiles ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--muted); font-size: 13px; }
.tile:hover { border-color: #D6D6D6; color: var(--muted); }
.tile .n { font-family: var(--head); font-size: 30px; font-weight: 700; line-height: 1.1; margin-bottom: 4px; }
.tile.keep .n { color: var(--keep); }
.tile.review .n { color: var(--review); }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.decisions { list-style: none; }
.decisions li + li { border-top: 1px solid var(--line-soft); }
.decisions a { display: flex; flex-direction: column; padding: 10px 0; }
.decisions a strong { font-family: var(--head); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.decisions a span { font-size: 12.5px; }
.decisions a:hover strong { text-decoration: underline; }
.history { list-style: none; }
.hist { display: flex; gap: 14px; padding: 9px 0; font-size: 13.5px; overflow-wrap: anywhere; }
.hist + .hist { border-top: 1px solid var(--line-soft); }
.hist .when { flex: none; width: 128px; color: var(--muted); font-size: 12.5px; padding-top: 1px; }

/* ---------- filters ---------- */
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 16px; }
.switch { display: inline-flex; background: #EFEFEF; border-radius: 9px; padding: 3px; }
.switch a { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 14px; border-radius: 7px; font-size: 13px; font-weight: 600; color: #666; }
.switch a span { color: var(--muted); font-weight: 600; }
.switch a[aria-current] { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.chip span { color: var(--muted); }
.chip:hover { border-color: #CFCFCF; }
.chip.on { border-color: var(--text); color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.search { display: flex; align-items: center; gap: 8px; height: 36px; width: 300px; max-width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); }
.search .icon { width: 16px; height: 16px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13.5px; }
.search:focus-within { border-color: #BDBDBD; }

/* ---------- rows ---------- */
.rows { list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 230px 250px; align-items: center; gap: 18px; padding: 15px 20px; }
.row + .row, .section-label + .row { border-top: 1px solid var(--line-soft); }
.row .title { font-family: var(--head); font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.3; }
a.title:hover { text-decoration: underline; }
.row .sub { margin-top: 2px; font-size: 13px; }
.row .muted.small { margin-top: 1px; }
.row-main { min-width: 0; overflow-wrap: anywhere; }
.row-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-act { display: flex; justify-content: flex-end; }
.age { display: inline-block; font-size: 12.5px; color: var(--muted); text-align: left; white-space: nowrap; }
.age::first-line { color: var(--text); font-weight: 600; }
.count-big { font-family: var(--head); font-size: 15px; font-weight: 700; white-space: nowrap; }
.row-meta:has(.count-big) { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
.section-label { list-style: none; padding: 14px 20px 6px; font-family: var(--head); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: #FBFBFB; }
.section-label:not(:first-child) { border-top: 1px solid var(--line-soft); }
.empty { list-style: none; padding: 34px 20px; text-align: center; color: var(--muted); }
.foot-note { margin-top: 12px; padding: 0 4px; }

/* ---------- pills, notes ---------- */
.pills { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: #F1F1F1; color: #555; }
.pill.outline { background: transparent; border: 1px solid #D9D9D9; color: var(--text); }
.ai { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; margin-left: 6px; border-radius: 10px; font-family: var(--body); font-size: 11px; font-weight: 700; color: var(--review); background: var(--review-bg); vertical-align: middle; }
.note { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: var(--review-bg); color: var(--review); font-size: 12.5px; line-height: 1.45; }
.note.removed { background: var(--removed-bg); color: var(--removed); }
.who { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
form.inline { display: inline; }
.link { padding: 0; color: var(--text); font-size: 12px; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Keep / Review / Remove ---------- */
form.state { display: flex; flex-direction: column; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { height: 32px; padding: 0 13px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: #fff; transition: background-color .12s, color .12s; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:not(:disabled):hover { background: #F7F7F7; color: var(--text); }
.seg .k.on, .seg .k.on:hover { background: var(--keep-bg); color: var(--keep); }
.seg .r.on, .seg .r.on:hover { background: var(--review-bg); color: var(--review); }
.seg .x.on, .seg .x.on:hover { background: var(--removed-bg); color: var(--removed); }
.seg button:disabled:not(.on) { color: #B5B5B5; }
.reason { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
.reason:focus { outline: 0; border-color: var(--removed); box-shadow: 0 0 0 2px var(--removed-bg); }
.reason.needs { border-color: var(--removed); }
.row-act form.state { align-items: flex-end; }
.row-act .reason { width: 230px; }
.panel form.state { align-items: flex-start; }
.panel form.state .reason { width: min(420px, 100%); }

/* ---------- lead page fields ---------- */
.sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.sections .panel { margin-bottom: 0; }
.fields > div { padding: 9px 0; }
.fields > div + div { border-top: 1px solid var(--line-soft); }
.fields dt { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.fields dd { margin-top: 1px; font-size: 14px; overflow-wrap: anywhere; white-space: pre-line; }
.fields dd a { color: var(--text); text-decoration: underline; text-decoration-color: #C9C9C9; text-underline-offset: 2px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-family: var(--head); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .wrap { overflow-wrap: anywhere; min-width: 200px; }

/* ---------- fill bar ---------- */
progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; max-width: 420px; height: 6px; margin-top: 8px; border: 0; border-radius: 999px; background: #EFEFEF; overflow: hidden; color: var(--keep); }
progress::-webkit-progress-bar { background: #EFEFEF; border-radius: 999px; }
progress::-webkit-progress-value { background: var(--keep); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--keep); border-radius: 999px; }

/* ---------- forms: sign in, setup, upload ---------- */
.plain { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 72px 20px 40px; }
.plain-logo { width: 190px; margin-bottom: 28px; }
.panel.auth { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 26px 26px 28px; }
.panel.auth h1 { font-size: 21px; }
.panel.auth .muted { font-size: 13px; margin-top: -6px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
label input:not([type="file"]) { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; font-weight: 400; color: var(--text); }
label input:not([type="file"]):focus { outline: 0; border-color: #BDBDBD; box-shadow: 0 0 0 3px #F1F1F1; }
input[type="file"] { font-size: 13px; font-weight: 400; color: var(--text-2); }
input[type="file"]::file-selector-button { height: 32px; margin-right: 10px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 14px; font-weight: 700; color: var(--text); }
.button.primary { background: var(--red); border-color: var(--red); color: #fff; }
.button.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.upload { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.upload label { flex: 1 1 280px; }
.upload .muted { flex-basis: 100%; margin: -2px 0 0; }

/* ---------- desktop extras ---------- */
@media (min-width: 900px) {
  .tabbar { display: none !important; }
  /* White sidebar column all the way down, however long the page. */
  .shell::before { content: ""; position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--line); z-index: -1; }
  .sidebar { background: transparent; border-right: 0; }
  .shell { position: relative; z-index: 0; }
}

/* ---------- tablet: narrower rows ---------- */
@media (max-width: 1180px) and (min-width: 900px) {
  .main { padding: 32px 32px 48px; }
  .row { grid-template-columns: minmax(0, 1fr) 190px 236px; }
  .sections { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- phone ---------- */
@media (max-width: 899px) {
  body { font-size: 14px; }
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .topbar .brand img { width: 118px; }
  .avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #F3F3F3; color: #555; font-size: 12px; font-weight: 700; }
  .main { max-width: none; padding: 20px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); }

  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar summary { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabbar); font-size: 10.5px; font-weight: 600; color: #8A8A8A; cursor: pointer; }
  .tabbar a[aria-current="page"] { color: var(--red); }
  .tabbar .icon { width: 22px; height: 22px; }
  .more { position: relative; }
  .more > summary { list-style: none; }
  .more > summary::-webkit-details-marker { display: none; }
  .more[open] > summary { color: var(--text); }
  .more-menu { position: absolute; right: 8px; bottom: calc(var(--tabbar) + 6px); min-width: 180px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .10); display: flex; flex-direction: column; }
  .more-menu a, .more-menu button { display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text); height: auto; flex-direction: row; }
  .more-menu a:hover, .more-menu button:hover { background: #F7F7F7; }
  .more-menu form { margin: 0; border-top: 1px solid var(--line-soft); margin-top: 4px; padding-top: 4px; }

  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 24px; }
  .page-head.row-between { flex-direction: column; align-items: stretch; gap: 12px; }
  .search { width: 100%; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 14px; }
  .tile .n { font-size: 28px; }
  .cols, .sections { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .panel { padding: 16px; }
  .hist { flex-direction: column; gap: 1px; }
  .hist .when { width: auto; }

  .filters { gap: 10px; }
  .switch { display: flex; width: 100%; }
  .switch a { flex: 1; justify-content: center; padding: 0 8px; }

  .rows { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  .row { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
  .row + .row, .section-label + .row { border-top: 1px solid var(--line); }
  .row-meta { margin-top: 10px; }
  .row-meta:has(.count-big) { flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 6px; }
  .row-act { display: block; margin-top: 10px; }
  .row-act form.state, .panel form.state { align-items: stretch; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1; height: 36px; }
  .row-act .reason, .panel form.state .reason { width: 100%; }
  .age { text-align: right; }
  .age::first-line { color: var(--muted); font-weight: 400; }
  .section-label { background: transparent; padding: 12px 4px 6px; border-top: 0 !important; }
  .empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

  .panel .table { display: block; overflow-x: auto; }
  .table th, .table td { white-space: nowrap; }
  .table .wrap { white-space: normal; min-width: 220px; }
  .toast { bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); }
  .plain { padding-top: 48px; }
}
