/* ==========================================================================
   admin-crm.css — the CRM, in the admin panel's own voice: "The Marked Script",
   an examiner's desk. Hairline rules, small-caps labels, Fraunces numerals,
   one accent that does all the pointing.

   THE RULE THAT WAS BROKEN (2026-08-28): --soft-green/-amber/-red are LIGHT
   creams that are NOT redefined in dark mode, while --ink flips to cream. Any
   surface painted with them and written in --ink is invisible on the night
   desk — which is exactly how the chat history disappeared. So this file
   defines its OWN pair-tokens below, each with an explicit foreground, and
   redefines both halves per theme. Never paint a surface here without also
   setting its ink.
   ========================================================================== */

.apx-crm {
  max-width: 760px;
  margin: 0 auto;

  /* surfaces that carry text always ship with their own ink */
  --crm-sent-bg: color-mix(in srgb, var(--accent) 10%, transparent);
  --crm-sent-ink: var(--ink);
  --crm-sent-edge: color-mix(in srgb, var(--accent) 55%, transparent);
  --crm-recv-bg: transparent;
  --crm-recv-ink: var(--ink);
  --crm-recv-edge: var(--line-strong, var(--line));
  --crm-quiet: color-mix(in srgb, var(--line) 45%, transparent);
}
/* the [hidden] contract must outrank our display rules */
.apx-crm [hidden] { display: none !important; }

/* ---- tabs: quiet underline, not buttons ---- */
.apx-crm-tabs { display: flex; gap: 1.5rem; margin: 0 0 1.2rem; border-bottom: 1px solid var(--line); }
.apx-crm-tab {
  font: inherit; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 0.65rem 0.1rem; min-height: 44px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.apx-crm-tab.is-on { color: var(--ink); border-bottom-color: var(--accent); }
.apx-crm-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* ---- today's five ----------------------------------------------------------
   Built on the Today surface's idiom (admin-today.css): hairline-ruled rows on
   bare ground, a Fraunces numeral, title/sub type sizes, an inset accent rule
   marking the focused row, and underline-quiet actions. The tile answers four
   questions in order: WHO · WHY NOW · WHAT THEY LAST SAID · WHAT'S NEXT.
   -------------------------------------------------------------------------- */
.apx-crm-five { display: flex; flex-direction: column; }
.apx-crm-card {
  display: flex; align-items: flex-start; gap: 0.85rem;
  padding: 1.1rem 0.55rem 1.2rem 0.7rem;
  border-top: 1px solid var(--line);
  cursor: pointer;
  animation: apx-crm-in 0.3s ease-out both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.apx-crm-card:last-child { border-bottom: 1px solid var(--line); }
/* the top of the queue is marked the way Today marks its focus row */
.apx-crm-card.is-focus { background: var(--surface-soft); box-shadow: inset 3px 0 0 0 var(--accent); }
.apx-crm-card:hover { background: var(--surface-soft); }
@keyframes apx-crm-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .apx-crm-card { animation: none; } }

.apx-crm-rank {
  flex: 0 0 auto; width: 1.4rem; text-align: right;
  font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.35rem;
  line-height: 1.25; color: var(--accent); font-variant-numeric: tabular-nums;
}
.apx-crm-body { flex: 1 1 auto; min-width: 0; }

.apx-crm-card-top { display: flex; align-items: baseline; gap: 0.55rem; flex-wrap: wrap; }
.apx-crm-name { margin: 0; font-size: 1.02rem; font-weight: 600; line-height: 1.3; color: var(--ink); }
.apx-crm-handle { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.apx-crm-reason {
  margin-left: auto; font-size: 0.7rem; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.apx-crm-reason.is-owes_reply { color: var(--accent); font-weight: 700; }
.apx-crm-reason.is-overdue { color: var(--warn, var(--accent)); font-weight: 700; }

/* the last thing said — the context that lets you act without opening */
.apx-crm-quote {
  margin: 0.6rem 0 0; padding: 0 0 0 0.75rem;
  border-left: 2px solid var(--line-strong, var(--line));
}
.apx-crm-quote.is-them { border-left-color: var(--accent); }
.apx-crm-quote p {
  margin: 0; font-size: 0.9rem; line-height: 1.45; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.apx-crm-quote cite {
  display: block; margin-top: 0.2rem; font-style: normal;
  font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.apx-crm-quote.is-empty { border-left-color: var(--line); color: var(--muted); font-size: 0.88rem; }

/* labelled facts: the examiner's-desk small-caps label + value */
.apx-crm-facts {
  display: grid; grid-template-columns: 3.1rem minmax(0, 1fr);
  gap: 0.12rem 0.7rem; margin: 0.7rem 0 0;
}
.apx-crm-facts dt {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); padding-top: 0.15rem;
}
.apx-crm-facts dd { margin: 0; font-size: 0.85rem; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.apx-crm-facts dd.is-none { color: var(--muted); font-style: italic; }
.apx-crm-when { color: var(--muted); font-variant-numeric: tabular-nums; }

.apx-crm-card-actions { display: flex; justify-content: flex-end; gap: 1.1rem; margin-top: 0.8rem; align-items: center; }

/* ---- buttons: text-weight by default; the accent is earned ---- */
.apx-crm-btn {
  font: inherit; font-size: 0.85rem; font-weight: 600;
  padding: 0.45rem 0; border: none; background: none;
  color: var(--muted); cursor: pointer; min-height: 44px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease-out, border-color 0.15s ease-out;
}
.apx-crm-btn:hover { color: var(--ink); border-bottom-color: var(--line-strong, var(--line)); }
.apx-crm-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.apx-crm-btn:disabled { opacity: 0.4; cursor: default; }
.apx-crm-btn.is-primary { color: var(--accent); }
.apx-crm-btn.is-primary:hover { color: var(--accent-strong, var(--accent)); border-bottom-color: currentColor; }
/* the few places that genuinely need a box */
.apx-crm-btn.is-boxed {
  padding: 0.5rem 0.95rem; border: 1px solid var(--line-strong, var(--line));
  border-radius: 6px; color: var(--ink);
}
.apx-crm-btn.is-boxed:hover { border-color: var(--ink); }
.apx-crm-btn.is-mini { min-height: 34px; font-size: 0.78rem; }
@media (prefers-reduced-motion: reduce) { .apx-crm-btn { transition: none; } }

.apx-crm-nextform { margin-top: 0.7rem; display: flex; flex-direction: column; gap: 0.5rem; }
.apx-crm-nextform input,
.apx-crm-search input,
.apx-crm-new input,
.apx-crm-field input {
  font: inherit; font-size: 0.95rem; padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-strong, var(--line)); border-radius: 6px;
  background: var(--surface); color: var(--ink); width: 100%; min-height: 44px;
}
.apx-crm-nextform input:focus-visible,
.apx-crm-search input:focus-visible,
.apx-crm-new input:focus-visible,
.apx-crm-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.apx-crm-nextform-row { display: flex; gap: 1.1rem; align-items: center; }

/* ---- done for today ---- */
.apx-crm-done { text-align: center; padding: 4.5rem 1rem 5rem; }
.apx-crm-done-mark {
  font-family: "Fraunces", Georgia, serif; font-size: 3rem; line-height: 1;
  color: var(--accent); margin: 0 0 0.5rem;
}
.apx-crm-done-big { font-family: "Fraunces", Georgia, serif; font-size: 1.6rem; font-weight: 600; margin: 0 0 0.35rem; }
.apx-crm-done-sub { color: var(--muted); margin: 0; font-size: 0.93rem; }

/* ---- leads list ---- */
.apx-crm-list { display: flex; flex-direction: column; gap: 0.85rem; }
.apx-crm-filters { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.apx-crm-filter {
  font: inherit; font-size: 0.78rem; font-weight: 600; padding: 0.35rem 0;
  border: none; border-bottom: 1px solid transparent; background: none;
  color: var(--muted); cursor: pointer; min-height: 36px;
}
.apx-crm-filter.is-on { color: var(--ink); border-bottom-color: var(--accent); }
.apx-crm-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.apx-crm-new { display: flex; gap: 0.8rem; align-items: center; }
.apx-crm-new input { border-style: dashed; }
.apx-crm-rows { display: flex; flex-direction: column; }
.apx-crm-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.18rem;
  text-align: left; font: inherit; background: none; border: none;
  border-bottom: 1px solid var(--line); padding: 0.8rem 0.15rem; cursor: pointer;
  color: var(--ink); width: 100%; min-height: 44px;
  transition: background 0.14s ease-out;
}
.apx-crm-row:hover { background: var(--crm-quiet); }
.apx-crm-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.apx-crm-row-main { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.apx-crm-row-note { color: var(--ink); font-size: 0.86rem; }
.apx-crm-row-meta { color: var(--muted); font-size: 0.77rem; font-variant-numeric: tabular-nums; }
.apx-crm-badge {
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.apx-crm-badge.is-paid { color: var(--good, var(--accent)); }
.apx-crm-badge.is-owe { color: var(--accent); }
.apx-crm-empty { color: var(--muted); padding: 1.2rem 0.2rem; font-size: 0.9rem; }
.apx-crm-h3 {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--muted); margin: 1.6rem 0 0.6rem;
}
.apx-crm-unlinked { display: flex; flex-direction: column; }
.apx-crm-unlinked-row {
  display: flex; justify-content: space-between; align-items: center; gap: 0.7rem;
  border-bottom: 1px solid var(--line); padding: 0.5rem 0.1rem;
}

/* ---- lead detail ---- */
.apx-crm-lead { display: flex; flex-direction: column; gap: 1.1rem; }
.apx-crm-back {
  align-self: flex-start; font: inherit; font-size: 0.83rem; background: none; border: none;
  color: var(--muted); cursor: pointer; padding: 0.5rem 0.2rem 0.2rem; min-height: 40px;
}
.apx-crm-back:hover { color: var(--ink); }
.apx-crm-lead-head h2 {
  margin: 0; font-family: "Fraunces", Georgia, serif; font-size: 1.6rem; font-weight: 600;
  letter-spacing: -0.01em;
}
.apx-crm-lead-flags { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 0.6rem; }
.apx-crm-opt { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); min-height: 36px; }
.apx-crm-optout-note {
  border-left: 2px solid var(--accent); padding: 0.5rem 0 0.5rem 0.8rem;
  color: var(--accent); font-size: 0.86rem; margin: 0;
}

/* quick-add: the most-used control, so it gets the one visible frame */
.apx-crm-quickadd {
  display: flex; flex-direction: column; gap: 0.55rem;
  border: 1px solid var(--line-strong, var(--line)); border-radius: 8px;
  padding: 0.85rem; background: var(--surface);
}
.apx-crm-typechips { display: flex; gap: 1.2rem; }
.apx-crm-typechip input { position: absolute; opacity: 0; pointer-events: none; }
.apx-crm-typechip span {
  display: inline-flex; align-items: center; min-height: 36px;
  font-size: 0.8rem; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 1px solid transparent;
}
.apx-crm-typechip input:checked + span { color: var(--ink); border-bottom-color: var(--accent); }
.apx-crm-typechip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.apx-crm-quickadd textarea {
  font: inherit; font-size: 0.95rem; padding: 0.55rem 0.7rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--ink); resize: vertical; width: 100%;
  min-height: 4.4rem; line-height: 1.5;
}
.apx-crm-quickadd textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.apx-crm-quickadd-row { display: flex; align-items: center; gap: 1.1rem; }
.apx-crm-photo {
  font-size: 1.1rem; cursor: pointer; min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
.apx-crm-photo-name { flex: 1; font-size: 0.74rem; color: var(--muted); overflow-wrap: anywhere; }

/* sort preview */
.apx-crm-sortpreview { display: flex; flex-direction: column; gap: 0.45rem; border-top: 1px dashed var(--line); padding-top: 0.7rem; }
.apx-crm-sortmsg { display: flex; gap: 0.55rem; align-items: flex-start; }
.apx-crm-sortmsg.is-me { flex-direction: row-reverse; }
.apx-crm-sidechip {
  flex: 0 0 auto; font: inherit; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0.3rem 0; min-height: 32px;
  border: none; border-bottom: 1px solid transparent; background: none;
  color: var(--muted); cursor: pointer;
}
.apx-crm-sortmsg.is-me .apx-crm-sidechip { color: var(--accent); border-bottom-color: currentColor; }
.apx-crm-sortbody { display: flex; flex-direction: column; gap: 0.15rem; max-width: 85%; }
.apx-crm-sortmsg.is-me .apx-crm-sortbody { align-items: flex-end; }
.apx-crm-sortts {
  font-size: 0.66rem; letter-spacing: 0.06em; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.apx-crm-sortts.is-none { font-style: italic; opacity: 0.75; }
.apx-crm-sorttext {
  font-size: 0.88rem; white-space: pre-wrap; border-radius: 10px; padding: 0.45rem 0.7rem;
  max-width: 100%; line-height: 1.45;
  background: var(--crm-recv-bg); color: var(--crm-recv-ink);
  box-shadow: inset 0 0 0 1px var(--crm-recv-edge);
}
.apx-crm-sortmsg.is-me .apx-crm-sorttext {
  background: var(--crm-sent-bg); color: var(--crm-sent-ink);
  box-shadow: inset 0 0 0 1px var(--crm-sent-edge);
}
.apx-crm-removeshot {
  display: flex; align-items: center; gap: 0.45rem; font-size: 0.8rem; color: var(--muted);
  padding: 0.2rem 0; min-height: 36px;
}

/* fields */
.apx-crm-fieldrow { display: flex; gap: 0.7rem; }
.apx-crm-field { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.apx-crm-field.is-date { flex: 0 0 40%; }
.apx-crm-field span {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--muted);
}
.apx-crm-usage { border-top: 1px solid var(--line); padding-top: 0.2rem; }

/* ---- the chat history: reads like the thread it came from ---- */
.apx-crm-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.apx-crm-entry { display: flex; flex-direction: column; max-width: 82%; gap: 0.15rem; }
.apx-crm-entry.is-dm_sent { align-self: flex-end; align-items: flex-end; }
.apx-crm-entry.is-dm_received { align-self: flex-start; }
.apx-crm-entry.is-note, .apx-crm-entry.is-screenshot { align-self: stretch; max-width: 100%; }
.apx-crm-entry.is-system { align-self: center; max-width: 100%; text-align: center; }
.apx-crm-entry-meta {
  font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 0.4rem; font-variant-numeric: tabular-nums;
}
.apx-crm-entry.is-dm_sent .apx-crm-entry-meta { flex-direction: row-reverse; }
.apx-crm-timebtn {
  font: inherit; font-size: inherit; letter-spacing: inherit; text-transform: inherit;
  background: none; border: none; padding: 0.2rem 0; cursor: pointer;
  color: var(--muted); border-bottom: 1px dotted var(--line-strong, var(--line));
}
.apx-crm-timebtn:hover { color: var(--accent); border-bottom-color: currentColor; }
.apx-crm-timebtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.apx-crm-edited { font-style: italic; text-transform: none; letter-spacing: 0; opacity: 0.7; }

/* Both bubble kinds set background AND colour together — this is the pairing
   whose absence made the history invisible on the night desk. */
.apx-crm-entry-body {
  margin: 0; white-space: pre-wrap; font-size: 0.92rem; line-height: 1.55;
  border-radius: 12px; padding: 0.55rem 0.8rem;
}
.apx-crm-entry.is-dm_sent .apx-crm-entry-body {
  background: var(--crm-sent-bg); color: var(--crm-sent-ink);
  box-shadow: inset 0 0 0 1px var(--crm-sent-edge);
  border-bottom-right-radius: 3px;
}
.apx-crm-entry.is-dm_received .apx-crm-entry-body {
  background: var(--crm-recv-bg); color: var(--crm-recv-ink);
  box-shadow: inset 0 0 0 1px var(--crm-recv-edge);
  border-bottom-left-radius: 3px;
}
.apx-crm-entry.is-note .apx-crm-entry-body {
  border-left: 2px solid var(--line-strong, var(--line));
  border-radius: 0; padding: 0.1rem 0 0.1rem 0.75rem; color: var(--muted);
  background: none;
}
.apx-crm-entry.is-system .apx-crm-entry-body {
  color: var(--muted); font-size: 0.78rem; background: none; padding: 0.1rem 0;
}
.apx-crm-entry-body[contenteditable]:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.apx-crm-entry-body[contenteditable]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.apx-crm-entry-img { max-width: 100%; border-radius: 8px; margin-top: 0.35rem; box-shadow: inset 0 0 0 1px var(--line); }

/* ---- phone drop / invite ---- */
.apx-crm-qr {
  margin-top: 0.7rem; padding: 0.9rem; border: 1px solid var(--line-strong, var(--line));
  border-radius: 8px; display: flex; flex-direction: column; align-items: center; gap: 0.55rem;
  background: var(--surface);
}
.apx-crm-qr svg { background: #fff; border-radius: 6px; max-width: 220px; height: auto; }
.apx-crm-invitebox {
  margin-top: 0.55rem; padding: 0.65rem 0.8rem; border-left: 2px solid var(--accent);
  display: flex; flex-direction: column; gap: 0.15rem;
}
.apx-crm-invitelink { font-size: 0.86rem; font-weight: 600; overflow-wrap: anywhere; user-select: all; }

/* destructive, spatially separated and quiet until engaged */
.apx-crm-deletelead {
  align-self: flex-start; margin-top: 2.4rem; font: inherit; font-size: 0.78rem;
  background: none; border: none; color: var(--muted); cursor: pointer;
  text-decoration: underline dotted; min-height: 44px; padding: 0.4rem 0.2rem;
}
.apx-crm-deletelead:hover { color: var(--accent); }

@media (min-width: 700px) {
  .apx-crm-card { grid-template-columns: 2.4rem 1fr; padding: 1.15rem 0.2rem 1.25rem; }
  .apx-crm-nextform { flex-direction: row; }
  .apx-crm-nextform input[name="next_action"] { flex: 1; }
  .apx-crm-entry { max-width: 70%; }
}
/* the meta line reverses on sent rows, so the separator has to come from the
   layout (a gap), never a literal "·" that ends up stranded at the end */
.apx-crm-entry-kind { opacity: 0.8; }
.apx-crm-entry-kind::after { content: " ·"; opacity: 0.5; }
/* sent rows reverse, so the separator must move to the other side of the word */
.apx-crm-entry.is-dm_sent .apx-crm-entry-kind::after { content: none; }
.apx-crm-entry.is-dm_sent .apx-crm-entry-kind::before { content: "· "; opacity: 0.5; }

/* ---- date picker: a real calendar, not a browser prompt ---- */
.apx-cal {
  position: absolute; z-index: 1200; width: 268px;
  background: var(--surface); border: 1px solid var(--line-strong, var(--line));
  border-radius: 10px; padding: 0.7rem; box-shadow: 0 12px 32px rgba(0,0,0,0.28);
}
.apx-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.apx-cal-head strong { font-family: "Fraunces", Georgia, serif; font-size: 0.95rem; font-weight: 600; }
.apx-cal-nav {
  font: inherit; font-size: 1.1rem; line-height: 1; background: none; border: none;
  color: var(--muted); cursor: pointer; min-width: 34px; min-height: 34px; border-radius: 6px;
}
.apx-cal-nav:hover { color: var(--ink); background: var(--surface-soft); }
.apx-cal-nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.apx-cal-dow, .apx-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.apx-cal-dow span {
  text-align: center; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em;
  color: var(--muted); padding-bottom: 0.2rem;
}
.apx-cal-day {
  font: inherit; font-size: 0.8rem; min-height: 32px; border: none; border-radius: 6px;
  background: none; color: var(--ink); cursor: pointer; font-variant-numeric: tabular-nums;
}
.apx-cal-day:hover { background: var(--surface-soft); }
.apx-cal-day.is-today { box-shadow: inset 0 0 0 1px var(--line-strong, var(--line)); }
.apx-cal-day.is-on { background: var(--accent); color: var(--on-accent, #fff); font-weight: 700; }
.apx-cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.apx-cal-time { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.6rem; }
.apx-cal-time label {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin-right: auto;
}
.apx-cal-time input {
  width: 3rem; font: inherit; font-size: 0.9rem; text-align: center; padding: 0.35rem 0.2rem;
  border: 1px solid var(--line-strong, var(--line)); border-radius: 6px;
  background: var(--bg); color: var(--ink); font-variant-numeric: tabular-nums;
}
.apx-cal-time input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.apx-cal-acts { display: flex; justify-content: space-between; align-items: center; margin-top: 0.5rem; }
.apx-cal-acts .apx-crm-btn { min-height: 36px; }

/* note removal: invisible until the entry is hovered, never loud */
.apx-crm-entry { position: relative; }
.apx-crm-delnote {
  position: absolute; top: 0; right: -1.6rem; font: inherit; font-size: 0.8rem;
  background: none; border: none; color: var(--muted); cursor: pointer;
  opacity: 0; min-width: 32px; min-height: 32px; transition: opacity 0.15s ease-out;
}
.apx-crm-entry.is-system .apx-crm-delnote { right: auto; left: -1.9rem; }
.apx-crm-entry:hover .apx-crm-delnote, .apx-crm-delnote:focus-visible { opacity: 1; }
.apx-crm-delnote:hover { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .apx-crm-delnote { transition: none; } }

.apx-crm-fivenote {
  margin: 0 0 0.8rem; font-size: 0.8rem; color: var(--muted);
  border-left: 2px solid var(--accent); padding-left: 0.7rem;
}

/* --- inline insert (Vedang, 2026-08-29): slot a missed message in place --- */
.apx-crm-insbtn {
  position: absolute; bottom: -0.72rem; left: 50%; transform: translateX(-50%);
  font: inherit; font-size: 0.68rem; letter-spacing: 0.04em;
  background: var(--paper, var(--bg)); border: 1px solid var(--rule, var(--muted));
  border-radius: 999px; padding: 0.05rem 0.55rem; color: var(--muted);
  cursor: pointer; opacity: 0; z-index: 2; transition: opacity 0.15s ease-out;
}
.apx-crm-entry:hover .apx-crm-insbtn, .apx-crm-insbtn:focus-visible { opacity: 1; }
.apx-crm-insbtn:hover { color: var(--accent); border-color: var(--accent); }
.apx-crm-insform {
  list-style: none; margin: 0.35rem 0 0.6rem; padding: 0.6rem 0.7rem;
  border: 1px dashed var(--rule, var(--muted)); border-radius: 8px;
}
.apx-crm-insrow { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.apx-crm-insrow + .apx-crm-instext, .apx-crm-instext { margin: 0.45rem 0; width: 100%;
  font: inherit; padding: 0.45rem 0.55rem; border: 1px solid var(--rule, var(--muted));
  border-radius: 6px; background: var(--paper, transparent); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .apx-crm-insbtn { transition: none; } }

/* --- the task list (2026-08-30: "Today's five" -> plain worklist) --------- */
.apx-crm-tasks { margin-top: 0.3rem; }
.apx-crm-taskhead {
  margin: 1.5rem 0 0.35rem; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.apx-crm-taskhead span { font-weight: 400; opacity: 0.7; margin-left: 0.3rem; }
.apx-crm-task {
  display: flex; gap: 0.75rem; align-items: flex-start; position: relative;
  padding: 0.7rem 0.35rem 0.75rem 0.1rem; border-top: 1px solid var(--rule, rgba(127,127,127,0.25));
  flex-wrap: wrap;
}
.apx-crm-task:hover { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.apx-crm-tick {
  flex: 0 0 auto; width: 22px; height: 22px; margin-top: 0.15rem; cursor: pointer;
  border: 1.5px solid var(--muted); border-radius: 50%; background: none;
  color: transparent; font-size: 13px; line-height: 1; display: grid; place-items: center;
}
.apx-crm-tick::before { content: "✓"; }
.apx-crm-tick:hover, .apx-crm-tick:focus-visible { border-color: var(--accent); color: var(--accent); }
.apx-crm-task.is-ticked .apx-crm-tick { background: var(--accent); border-color: var(--accent); color: var(--paper, #fff); }
.apx-crm-task.is-ticked .apx-crm-task-action { text-decoration: line-through; opacity: 0.55; }
.apx-crm-task-main { flex: 1 1 0; min-width: 0; cursor: pointer; }
.apx-crm-task-action {
  margin: 0 0 0.15rem; font-size: 0.95rem; font-weight: 600; color: var(--ink);
  display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap;
}
.apx-crm-task-due {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.03em;
  padding: 0.06rem 0.5rem; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--rule, currentColor); color: var(--muted);
}
.apx-crm-task-due.is-overdue { color: var(--accent); border-color: var(--accent); }
.apx-crm-task-due.is-due_today { color: var(--ink); border-color: var(--ink); }
.apx-crm-task-who { margin: 0 0 0.1rem; font-size: 0.79rem; color: var(--muted); }
.apx-crm-task-who strong { color: var(--ink); font-weight: 600; }
.apx-crm-task-quote {
  margin: 0.1rem 0 0; font-size: 0.79rem; color: var(--ink);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}
.apx-crm-task-quote span { color: var(--muted); }
.apx-crm-task-state {
  margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--muted); line-height: 1.45;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.apx-crm-task.is-open .apx-crm-task-state, .apx-crm-task.is-open .apx-crm-task-quote {
  -webkit-line-clamp: unset; }
.apx-crm-task-inline {
  flex-basis: 100%; margin: 0.4rem 0 0.15rem 2.1rem; padding: 0.55rem 0.7rem;
  border: 1px dashed var(--rule, var(--muted)); border-radius: 8px;
}
.apx-crm-task-donenote { margin: 0 0 0.35rem; font-size: 0.78rem; color: var(--muted); }
.apx-crm-instext.is-date { width: auto; }

/* ══════════════════════════════════════════════════════════════════════════
   2026-09-04 — the task list, quieter. One bold line per row; the quote, the
   state and the Open button live behind a tap. Signal bands (call the parent,
   buying signals, struggling, about to lapse) sit above the DM bands.
   ══════════════════════════════════════════════════════════════════════════ */
.apx-crm-task-action {
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 0.98rem; line-height: 1.35; margin: 0 0 0.15rem;
}
.apx-crm-task.is-open .apx-crm-task-action { display: block; -webkit-line-clamp: unset; }
.apx-crm-task-who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apx-crm-task.is-open .apx-crm-task-who { white-space: normal; }
.apx-crm-task-bits { color: var(--muted); }
.apx-crm-task-more { display: none; margin-top: 0.5rem; }
.apx-crm-task.is-open .apx-crm-task-more { display: block; }
.apx-crm-task-more .apx-crm-task-quote, .apx-crm-task-more .apx-crm-task-state { display: block; -webkit-line-clamp: unset; }
.apx-crm-task-openbtn { margin-top: 0.2rem; }
.apx-crm-task-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* signal rows: the accent rule says "this is a fact from the site, not a DM" */
.apx-crm-task.is-parent_call { box-shadow: inset 3px 0 0 0 var(--accent); padding-left: 0.6rem; }
.apx-crm-task.is-parent_call .apx-crm-task-action { color: var(--accent); }
.apx-crm-task.is-money .apx-crm-task-action { color: var(--ink); }
.apx-crm-task.is-money::before, .apx-crm-task.is-struggling::before, .apx-crm-task.is-churn::before { content: none; }
.apx-crm-taskhead.is-signal { color: var(--accent); }
.apx-crm-row-meta.is-err { color: var(--accent); }

/* ---- the site, in words ---- */
.apx-crm-site { display: grid; gap: 0.55rem; }
.apx-crm-site-id { margin: 0; font-size: 0.86rem; color: var(--muted); }
.apx-crm-site-id strong { color: var(--ink); }
.apx-crm-site-access { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }
.apx-crm-site-access.is-paid { color: var(--good, var(--accent)); font-weight: 600; }
.apx-crm-site-lab { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-right: 0.3rem; }
.apx-crm-site-lab.is-bad { color: var(--accent); }
.apx-crm-sitefacts { display: grid; gap: 0.5rem; margin: 0.2rem 0 0; }
.apx-crm-sitefacts > div { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr); gap: 0.2rem 0.7rem; align-items: start; }
@media (max-width: 560px) { .apx-crm-sitefacts > div { grid-template-columns: 1fr; } }
.apx-crm-sitefacts dt { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); padding-top: 0.3rem; }
.apx-crm-sitefacts dt small { display: block; letter-spacing: 0.02em; text-transform: none; font-weight: 500; font-size: 0.72rem; }
.apx-crm-sitefacts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.apx-crm-lchip {
  display: inline-flex; align-items: center; gap: 0.3rem; font: inherit; font-size: 0.8rem; line-height: 1.3;
  padding: 0.25rem 0.55rem; border: 1px solid var(--line-strong, var(--line)); border-radius: 999px; color: var(--ink); background: none;
}
.apx-crm-lchip small { color: var(--muted); font-size: 0.7rem; }
.apx-crm-lchip.is-done { border-color: color-mix(in srgb, var(--good, var(--accent)) 55%, transparent); }
.apx-crm-lchip.is-bad { border-color: var(--accent); color: var(--accent); }
.apx-crm-lchip.is-paper b { font-family: "Fraunces", Georgia, serif; font-weight: 600; }
.apx-crm-lchip.is-more { cursor: pointer; color: var(--muted); border-style: dashed; min-height: 32px; }
.apx-crm-lchip.is-more:hover { color: var(--ink); border-color: var(--ink); }
.apx-crm-lchips-rest { display: contents; }
.apx-crm-none { color: var(--muted); font-size: 0.82rem; font-style: italic; }
.apx-crm-siteacts { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; align-items: center; margin-top: 0.3rem; padding-top: 0.4rem; border-top: 1px dashed var(--line); }
.apx-crm-siteacts-sep { flex: 0 0 1px; height: 18px; background: var(--line-strong, var(--line)); }
.apx-crm-btn.is-danger { color: var(--accent); }
.apx-crm-confirm { font-size: 0.82rem; color: var(--ink); display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

/* ---- links ---- */
.apx-crm-links { display: grid; gap: 0.8rem; }
.apx-crm-linkform { display: grid; gap: 0.6rem; padding: 0.8rem 0 0.4rem; border-top: 1px solid var(--line); }
.apx-crm-field select {
  font: inherit; font-size: 0.95rem; padding: 0.55rem 0.7rem; min-height: 44px;
  border: 1px solid var(--line-strong, var(--line)); border-radius: 6px; background: var(--surface); color: var(--ink);
}
.apx-crm-links .apx-ld-invite-table-wrap { overflow-x: auto; }
.apx-crm-links .apx-ld-invite-table td:nth-child(2), .apx-crm-links .apx-ld-invite-table td:nth-child(8) { white-space: nowrap; }
.apx-crm-links .apx-ld-invite-table td:nth-child(7) { max-width: 16rem; overflow-wrap: anywhere; }
