/* Sage · WhatsApp qualification backoffice.
   Dark workspace (same ground as the KPI board), Sage green for actions, Sage Text throughout.
   @font-face lives in templates/backoffice/_fonts.html (unhashed paths: a missing font never breaks the build). */

:root {
  --font: "Sage Text", "Helvetica Neue", Arial, sans-serif;
  --ink: #000000;        /* page */
  --graphite: #131513;   /* surfaces */
  --raised: #1b1e1b;     /* inputs, chips, hover */
  --seam: #262926;       /* borders */
  --seam-2: #333733;
  --fog: #a3a8a3;        /* secondary text */
  --mist: #7d837d;       /* tertiary text */
  --paper: #f2f4f2;      /* primary text */
  --brand: #00d639;       /* brand: actions */
  --brand-ui: #5ed35a;    /* data marks */
  --brand-soft: rgba(94, 211, 90, .12);
  --red: #ff6a5c; --red-soft: rgba(255, 106, 92, .12); --red-line: rgba(255, 106, 92, .35);
  --amber: #f2b84b; --amber-soft: rgba(242, 184, 75, .12);
  --blue: #7aa5ff; --blue-soft: rgba(76, 130, 240, .16);
  /* KPI status colors (validated against the graphite surface) */
  --st-no_response: #f2b84b; --st-qualified: #2fb84a; --st-off_target: #9aa09a; --st-followup: #4c82f0; --st-unreachable: #d9483f;
  --side: 248px;
  --r-panel: 20px; --r-control: 12px; --r-chip: 8px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--ink); color: var(--paper); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ================= shell ================= */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 16px 18px;
  border-right: 1px solid var(--seam); background: var(--ink); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); display: grid; place-items: center;
  color: #000; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand-text { line-height: 1.2; }
.brand-text b { display: block; font-size: 16px; }
.brand-text span { color: var(--mist); font-size: 13px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-control);
  text-decoration: none; color: var(--fog); font-size: 15px; position: relative; }
.nav a svg { flex: none; width: 19px; height: 19px; }
.nav a:hover { color: var(--paper); background: var(--graphite); }
.nav a.on { color: var(--paper); background: var(--graphite); }
.nav a.on::before { content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--brand); }
.nav a.on svg { color: var(--brand-ui); }
.nav .badge { margin-left: auto; min-width: 24px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  text-align: center; background: var(--raised); color: var(--paper); }
.nav .badge.red { background: var(--red-soft); color: var(--red); }
.side-foot { margin-top: auto; border-top: 1px solid var(--seam); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.me-name { font-size: 14px; line-height: 1.25; }
.me-name small { display: block; color: var(--mist); font-size: 12px; text-transform: capitalize; }
.side-foot .tools { display: flex; gap: 6px; padding: 0 2px; }
.side-foot .tools a, .side-foot .tools button { flex: 1; text-align: center; padding: 8px; border-radius: 10px; border: 1px solid var(--seam);
  background: none; color: var(--fog); font-size: 13px; text-decoration: none; cursor: pointer; }
.side-foot .tools a:hover, .side-foot .tools button:hover { color: var(--paper); border-color: var(--seam-2); }
.side-foot form { flex: 1; display: flex; margin: 0; }
.side-foot form button { width: 100%; }

.main { min-width: 0; padding: 34px 40px 60px; }
.page-head { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -0.01em; }
.page-head p { margin: 6px 0 0; color: var(--fog); }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #000; font-weight: 700; display: grid;
  place-items: center; font-size: 12px; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.ghost { background: var(--raised); color: var(--fog); }

/* ================= controls ================= */
.seg { display: inline-flex; padding: 3px; background: var(--graphite); border: 1px solid var(--seam); border-radius: var(--r-control); }
.seg a { padding: 6px 14px; border-radius: 9px; text-decoration: none; color: var(--fog); font-size: 14px; }
.seg a.on { background: var(--paper); color: #000; font-weight: 700; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px;
  border-radius: var(--r-control); border: 1px solid var(--brand); background: var(--brand); color: #000; font-weight: 700;
  cursor: pointer; text-decoration: none; font-size: 14px; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.quiet { background: transparent; color: var(--paper); border-color: var(--seam-2); }
.btn.quiet:hover { border-color: var(--fog); filter: none; }
.btn.big { height: 52px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn svg { width: 18px; height: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.field, .filters select, .filters input[type=search], .form-row select, .form-row input, .form-row textarea {
  height: 40px; border: 1px solid var(--seam); border-radius: var(--r-control); padding: 0 12px; background: var(--graphite);
  color: var(--paper); }
.filters input[type=search] { min-width: 260px; }
.filters select:hover, .filters input:hover { border-color: var(--seam-2); }
.filters .right { margin-left: auto; }
.count { color: var(--mist); font-size: 14px; }

/* ================= panels & tables ================= */
.panel { background: var(--graphite); border: 1px solid var(--seam); border-radius: var(--r-panel); padding: 22px 24px; }
.panel h2, .panel h3 { margin: 0 0 16px; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.panel h2 .count, .panel h3 .count { font-weight: 400; }
.panel h2 svg, .panel h3 svg { color: var(--brand-ui); width: 20px; height: 20px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 20px 24px 0; }
.stack > * + * { margin-top: 22px; }

.table-scroll { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.list th { text-align: left; font-weight: 400; color: var(--mist); font-size: 13px; padding: 12px 16px; border-bottom: 1px solid var(--seam);
  white-space: nowrap; }
table.list td { padding: 14px 16px; border-bottom: 1px solid var(--seam); white-space: nowrap; }
table.list tr:last-child td { border-bottom: 0; }
table.list th:first-child, table.list td:first-child { padding-left: 24px; }
table.list th:last-child, table.list td:last-child { padding-right: 24px; }
table.list tbody tr { cursor: pointer; transition: background .12s; }
table.list tbody tr:hover td { background: var(--raised); }
table.list tr.is-overdue td:first-child { box-shadow: inset 3px 0 0 var(--red); }
table.list tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
td.name a { font-weight: 700; text-decoration: none; }
td.name small { display: block; color: var(--mist); font-weight: 400; font-size: 13px; }
td.num { font-weight: 700; font-variant-numeric: tabular-nums; }
td.late { color: var(--red); font-weight: 700; }
td.soon { font-weight: 700; }
.muted { color: var(--mist); }
.empty { padding: 34px 24px; text-align: center; color: var(--fog); }
.empty b { display: block; color: var(--paper); font-size: 16px; margin-bottom: 4px; }

/* ================= chips & pills ================= */
.prio { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-chip); font-weight: 700; font-size: 13px; }
.prio.A { background: var(--brand-ui); color: #08200a; }
.prio.B { background: #a8e6a8; color: #08200a; }
.prio.C { background: #3a3e3a; color: var(--paper); }
.tag { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; margin-left: 8px; vertical-align: middle; }
.tag.new { background: var(--brand-soft); color: var(--brand-ui); }
.tag.overdue { background: var(--red-soft); color: var(--red); }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.qualified { background: var(--brand-soft); color: var(--brand-ui); }
.pill.followup { background: var(--blue-soft); color: var(--blue); }
.pill.off_target, .pill.excluded { background: var(--raised); color: var(--fog); }
.pill.no_response { background: var(--amber-soft); color: var(--amber); }
.pill.unreachable { background: var(--red-soft); color: var(--red); }
.pill.in_conversation, .pill.contacted, .pill.ready, .pill.imported { background: var(--raised); color: var(--paper); }
.owner { display: inline-flex; align-items: center; gap: 8px; color: var(--fog); font-size: 14px; }

/* ================= dashboard ================= */
.next { display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center; padding: 30px 32px; border-radius: 26px;
  background: var(--graphite); border: 1px solid var(--seam); position: relative; overflow: hidden; margin-bottom: 22px; }
.next::after { content: ""; position: absolute; right: -80px; top: -80px; width: 280px; height: 280px; border-radius: 50%;
  border: 46px solid var(--brand); opacity: .07; pointer-events: none; }
.next.late { border-color: var(--red-line); }
.next.late::after { border-color: var(--red); }
.next-kicker { color: var(--fog); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.next-name { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 10px 0 6px; }
.next-co { color: var(--fog); font-size: 17px; }
.next-facts { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 22px; }
.next-facts div { font-size: 14px; color: var(--mist); }
.next-facts b { display: block; color: var(--paper); font-size: 16px; margin-top: 2px; }
.next-side { text-align: right; position: relative; z-index: 1; }
.clock { font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.clock.late { color: var(--red); }
.clock-label { color: var(--fog); margin: 8px 0 20px; }
.next-side .btns { display: flex; gap: 10px; justify-content: flex-end; }
.strip { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--seam); border-radius: var(--r-panel);
  background: var(--graphite); margin-bottom: 22px; }
.strip > a, .strip > div { padding: 18px 22px; text-decoration: none; border-right: 1px solid var(--seam); }
.strip > :last-child { border-right: 0; }
.strip .k { color: var(--fog); font-size: 14px; }
.strip .v { font-size: 34px; font-weight: 700; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.strip .v.green { color: var(--brand-ui); }
.strip .v.red { color: var(--red); }
.strip a:hover { background: var(--raised); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

/* ================= lead page ================= */
.back { display: inline-flex; gap: 6px; align-items: center; margin-bottom: 18px; color: var(--fog); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--paper); }
.lead-hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; padding-bottom: 26px; margin-bottom: 26px;
  border-bottom: 1px solid var(--seam); }
.lead-hero h1 { margin: 0; font-size: 40px; letter-spacing: -0.02em; line-height: 1.1; }
.lead-hero .sub { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--fog); margin-top: 10px; font-size: 16px; }
.lead-hero .btns { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.scorebox { text-align: right; }
.scorebox .big { font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.scorebox .big small { font-size: 20px; color: var(--mist); font-weight: 400; }
.scorebox .muted { margin-bottom: 6px; }
.lead-cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 22px; align-items: start; }
.sticky { position: sticky; top: 24px; }
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 12px 16px; margin: 0; }
dl.kv dt { color: var(--mist); }
dl.kv dd { margin: 0; font-weight: 700; }
.answer { display: grid; grid-template-columns: 150px 1fr 70px; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--seam); align-items: start; }
.answer:last-of-type { border-bottom: 0; }
.answer .q { color: var(--mist); }
.answer .a { font-weight: 700; }
.answer .raw { color: var(--fog); font-size: 14px; margin-top: 3px; font-style: italic; }
.answer .pts { text-align: right; }
.answer .pts b { color: var(--brand-ui); }
.meter { height: 4px; background: var(--raised); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand-ui); border-radius: 4px; }
.summary { margin: 18px 0 0; padding: 16px 18px; border-radius: 14px; background: var(--raised); color: var(--paper); }
.form-row { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.form-row label { font-size: 14px; color: var(--fog); }
.form-row textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.form-row input[type=datetime-local] { color-scheme: dark; }
.status-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-pick label { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--seam); border-radius: var(--r-control);
  cursor: pointer; font-size: 14px; color: var(--paper); }
.status-pick input { accent-color: var(--brand); margin: 0; }
.status-pick label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.notice { padding: 10px 14px; border-radius: var(--r-control); font-size: 14px; margin-bottom: 14px; }
.notice.ok { background: var(--brand-soft); color: var(--brand-ui); }
.notice.err { background: var(--red-soft); color: var(--red); }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.timeline li { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--seam); }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { color: var(--mist); font-variant-numeric: tabular-nums; }
.htmx-request .btn { opacity: .6; }

/* ================= conversation ================= */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 620px; overflow-y: auto; padding: 4px 4px 4px 0; }
.chat-day { text-align: center; margin: 10px 0 4px; }
.chat-day span { font-size: 12px; color: var(--fog); background: var(--raised); padding: 4px 12px; border-radius: 999px; }
.bubble-row { display: flex; }
.bubble-row.out { justify-content: flex-end; }
.bubble { max-width: 78%; padding: 10px 14px 8px; border-radius: 16px; background: var(--raised); border: 1px solid var(--seam); }
.bubble-row.in .bubble { border-bottom-left-radius: 4px; }
.bubble-row.out .bubble { border-bottom-right-radius: 4px; background: #0f2a17; border-color: #1d4a2a; }
.bubble-row.out .bubble.business { background: #10213a; border-color: #23406b; }
.bubble .who { font-size: 12px; font-weight: 700; color: var(--brand-ui); margin-bottom: 3px; }
.bubble.business .who { color: var(--blue); }
.bubble .txt { white-space: normal; overflow-wrap: anywhere; }
.bubble .opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bubble .opts span { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--seam-2); color: var(--fog); }
.bubble .meta { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; font-size: 11.5px; color: var(--mist);
  font-variant-numeric: tabular-nums; }
.tick.read { color: #53bdeb; }
.tick.failed { color: var(--red); font-weight: 700; }
.convos { list-style: none; margin: 0; padding: 0; }
.convos li + li { border-top: 1px solid var(--seam); }
.convos a { display: flex; gap: 14px; align-items: center; padding: 16px 24px; text-decoration: none; }
.convos a:hover { background: var(--raised); }
.convos .avatar { width: 40px; height: 40px; font-size: 14px; }
.c-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.c-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.c-last { color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.c-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 13px; white-space: nowrap; }
.badge-n { min-width: 26px; padding: 2px 8px; border-radius: 999px; background: var(--raised); text-align: center; font-weight: 700; font-size: 12px; }

/* ================= KPI ================= */
.kgrid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 20px; }
.kgrid3 { display: grid; grid-template-columns: 1fr 1.25fr .95fr; gap: 20px; margin-bottom: 20px; }
.kgrid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.kcard { background: var(--graphite); border: 1px solid var(--seam); border-radius: 22px; padding: 24px 26px; }
.kcard .lbl { display: flex; align-items: center; gap: 10px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: #b9beb9; }
.kcard .lbl svg { color: var(--brand-ui); flex: none; }
.kcard .big { font-size: 50px; font-weight: 700; margin: 16px 0 8px; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.kcard .sub { color: var(--fog); }
.kcard h3 { margin: 0 0 22px; font-size: 17px; display: flex; gap: 10px; align-items: center; }
.kcard h3 svg { color: var(--brand-ui); }
.funnel { display: grid; grid-template-columns: 110px 1fr; gap: 12px 16px; align-items: center; }
.funnel .l { color: var(--fog); }
.funnel .bar { height: 42px; background: var(--brand-ui); border-radius: 8px; color: #08200a; font-weight: 700; display: flex;
  align-items: center; justify-content: flex-end; padding: 0 14px; min-width: 60px; font-variant-numeric: tabular-nums; }
.donut-wrap { display: flex; gap: 22px; align-items: center; }
.donut { width: 172px; height: 172px; flex: none; position: relative; }
.donut svg { width: 100%; height: 100%; }
.donut .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut .c b { font-size: 30px; display: block; line-height: 1; }
.donut .c span { color: var(--fog); font-size: 12px; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; }
.legend li { display: flex; align-items: center; gap: 10px; padding: 6px 0; white-space: nowrap; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.legend .n { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.hbars .row { margin-bottom: 15px; }
.hbars .top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: #e4e7e4; font-size: 14px; }
.hbars .track { height: 9px; background: #2a2d2a; border-radius: 999px; overflow: hidden; }
.hbars .fill { height: 100%; background: #8c928c; border-radius: 999px; }
.hbars.green .fill { background: var(--brand-ui); }
.tiles-in { display: flex; gap: 12px; }
.tiles-in div { flex: 1; background: var(--raised); border-radius: 14px; padding: 14px; text-align: center; }
.tiles-in b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.tiles-in span { color: var(--fog); font-size: 13px; }
.note { color: var(--mist); font-size: 13px; margin-top: 12px; }
.profile { display: grid; grid-template-columns: repeat(5, 1fr); gap: 26px; }
.profile h4 { margin: 0 0 14px; font-size: 14px; color: var(--fog); font-weight: 400; }

/* ================= login ================= */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; border-right: 1px solid var(--seam); padding: 48px; display: flex; flex-direction: column;
  justify-content: space-between; }
.login-art::after { content: ""; position: absolute; left: -160px; bottom: -160px; width: 560px; height: 560px; border-radius: 50%;
  border: 90px solid var(--brand); opacity: .09; }
.login-art h2 { font-size: 44px; line-height: 1.1; letter-spacing: -0.02em; margin: 0; max-width: 520px; position: relative; z-index: 1; }
.login-art p { color: var(--fog); max-width: 440px; position: relative; z-index: 1; }
.login-form { display: grid; place-items: center; padding: 40px; }
.login-form form { width: 100%; max-width: 380px; }
.login-form h1 { margin: 0 0 6px; font-size: 26px; }
.login-form p { margin: 0 0 26px; color: var(--fog); }
.login-form .form-row input { height: 46px; }
.login-form .btn { width: 100%; height: 48px; margin-top: 6px; }

@media (max-width: 1100px) {
  .kgrid4, .strip { grid-template-columns: repeat(2, 1fr); }
  .kgrid3, .kgrid2, .grid-2, .lead-cols, .profile { grid-template-columns: 1fr; }
  .strip > a, .strip > div { border-bottom: 1px solid var(--seam); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; border-right: 0;
    border-bottom: 1px solid var(--seam); }
  .brand { padding: 0 8px 0 0; }
  .brand-text { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .nav a { padding: 8px 10px; white-space: nowrap; }
  .nav a.on::before { display: none; }
  .side-foot { display: none; }
  .main { padding: 20px 16px 40px; }
  .next { grid-template-columns: 1fr; }
  .next-side { text-align: left; }
  .next-side .btns { justify-content: flex-start; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
