/* Luke's App: the CRM screens, in the "soft" skin of the Canvas design: a light, warm gradient
   page, white cards, one teal accent, rounded pills, hairline grids, tabular numbers.
   Everything is scoped to :root[data-view="crm"] (set by lib/crm/index.js), so the board keeps its look. */

:root[data-view="crm"] {
  --bg: #edf2f0; --bg-2: #e3eae7; --card: #ffffff; --card-2: #f2f6f4;
  --line: #dde6e2; --line-soft: #e9efec; --hover: #f5f9f7;
  --ink: #20302d; --ink-2: #566864; --ink-3: #7f8f8b;
  --accent: #0b7a6e; --accent-ink: #ffffff; --accent-soft: #e2f2ef;
  --good: #17794a; --warn: #8c5a10; --bad: #c0392f; --live: #d23c2f;
  --tint-s: 78%; --tint-l: 92%; --tone-s: 55%; --tone-l: 27%;
  --shadow: 0 1px 2px rgba(20, 40, 35, .06), 0 14px 34px rgba(20, 40, 35, .08);
  --shadow-lg: 0 18px 50px rgba(20, 40, 35, .18);
  --radius: 18px; --radius-s: 12px; --pill: 999px;
  --gap: clamp(12px, 1vw, 22px);
  color-scheme: light;
  /* a calmer rem than the board: 16px on a phone (iOS never zooms inputs), ~17px on a laptop, bigger on a TV */
  font-size: clamp(16px, 0.3vw + 11px, 26px);
}
:root[data-view="crm"] body {
  background:
    radial-gradient(60rem 40rem at 8% -12%, rgba(255, 198, 168, .55), transparent 62%),
    radial-gradient(52rem 40rem at 98% 4%, rgba(168, 214, 255, .5), transparent 62%),
    var(--bg);
  background-attachment: fixed;
}
:root[data-view="crm"] .btn { border-radius: var(--pill); background: var(--card); border-color: var(--line); color: var(--ink); font-weight: 600; }
:root[data-view="crm"] .btn:hover { border-color: var(--ink-3); }
:root[data-view="crm"] .btn.solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
:root[data-view="crm"] .btn.quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
:root[data-view="crm"] .btn.quiet:hover { color: var(--ink); border-color: var(--line); }
:root[data-view="crm"] .btn.has { border-color: var(--ink); }
:root[data-view="crm"] .btn[aria-pressed="true"] { background: var(--card-2); border-color: var(--ink); }
:root[data-view="crm"] .field { background: var(--card); border-color: var(--line); color: var(--ink); border-radius: var(--radius-s); font-size: 1rem; }
:root[data-view="crm"] .field:focus { border-color: var(--accent); }
:root[data-view="crm"] .toast { background: var(--ink); color: #fff; border-radius: var(--pill); padding: .65rem .8rem .65rem 1.2rem; z-index: 60; }
:root[data-view="crm"] .toast button { color: #fff; border-radius: var(--pill); }
.btn.sm { min-height: 2.5rem; padding: .35rem .85rem; font-size: .92rem; display: inline-flex; align-items: center; gap: .4rem; }
.field.sm { min-height: 2.5rem; padding: .4rem .7rem; }
.btn .ic, .ibtn .ic { width: 1.05rem; height: 1.05rem; flex: none; }
.ic { width: 1.15rem; height: 1.15rem; flex: none; }
.ic.sm { width: .95rem; height: .95rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- the top-level switch (also on the board) ---------- */
.appnav { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 70%, transparent); }
.appnav button {
  min-height: 2.4rem; padding: .3rem 1rem; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2);
  font-weight: 650; cursor: pointer;
}
.appnav button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- frame ---------- */
.crm {
  height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: flex; flex-direction: column; min-width: 0; max-width: 2400px; margin: 0 auto;
  padding: 10px 16px 0;
}
@media (min-width: 721px) { .crm { padding: 14px clamp(16px, 2vw, 48px) 14px; } }
.crm-top { display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; padding-bottom: .7rem; }
.crm-top .brand { margin-right: 0; font-size: 1.15rem; }
.crm-top .brand img { width: 1.9rem; height: 1.9rem; border-radius: 8px; }
.crm-top .status { margin-left: auto; }
.crm-tabs.top { display: flex; gap: .2rem; }
.crm-tabs button {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 2.6rem; padding: .35rem .95rem; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer;
}
.crm-tabs button:hover { color: var(--ink); }
.crm-tabs button[aria-current="page"] { background: var(--ink); color: #fff; }
.crm-tabs.bottom { display: none; }
.crm-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; min-width: 0; }
.crm-loading { display: grid; place-items: center; flex: 1; }

@media (max-width: 720px) {
  .crm-top { padding-bottom: .5rem; gap: .5rem; }
  .crm-top .brand-name { display: none; }
  .crm-tabs.top { display: none; }
  .crm-tabs.bottom {
    display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 -16px; padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--card) 92%, transparent); border-top: 1px solid var(--line);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .crm-tabs.bottom button { flex-direction: column; gap: .15rem; min-height: 3.4rem; padding: .3rem 0; font-size: .74rem; border-radius: 14px; }
  .crm-tabs.bottom button .ic { width: 1.4rem; height: 1.4rem; }
  .crm-tabs.bottom button[aria-current="page"] { background: transparent; color: var(--accent); }
}

/* ---------- pills ---------- */
.tp {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none;
  padding: .18rem .6rem; border-radius: 999px; font: 600 .8rem/1.25 var(--font);
  background: hsl(var(--h, 200) var(--tint-s) var(--tint-l)); color: hsl(var(--h, 200) var(--tone-s) var(--tone-l));
}
.tp.plain { background: var(--card-2); color: var(--ink-2); }
.tp.tag { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); flex: 0 1 auto; font-weight: 500; }
.score { font: 600 .9rem/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.tb-dot { width: .65rem; height: .65rem; border-radius: 50%; border: 1.5px solid var(--ink-3); flex: none; }
.tb-dot.on { background: var(--good); border-color: var(--good); }
.tx.due { color: var(--bad); font-weight: 600; }

/* ---------- table: views, bar, panel ---------- */
.tb { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.tb-views { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .6rem; border-bottom: 1px solid var(--line); min-width: 0; }
.vtabs { display: flex; gap: .1rem; overflow-x: auto; min-width: 0; flex: 0 1 auto; scrollbar-width: none; }
.vtab {
  font: 500 .95rem/1.2 var(--font); padding: .65rem .8rem .6rem; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.vtab:hover { color: var(--ink); }
.vtab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 650; }
.vtab .edited { color: var(--accent); }
.tb-vtools, .tb-vname { display: flex; gap: .3rem; align-items: center; margin-left: auto; padding: .25rem 0; flex-wrap: wrap; }
.tb-vname .field { width: 13rem; }
.tb-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; min-width: 0; }
.tb-search { position: relative; flex: 1 1 14rem; max-width: 26rem; display: flex; align-items: center; min-width: 0; }
.tb-search .ic { position: absolute; left: .85rem; color: var(--ink-3); pointer-events: none; }
.tb-search .field { padding-left: 2.5rem; min-height: 2.6rem; border-radius: 999px; }
.tb-btns { display: flex; flex-wrap: wrap; gap: .35rem; }
.bn { display: inline-grid; place-items: center; min-width: 1.3rem; height: 1.3rem; padding: 0 .3rem; border-radius: 99px; background: var(--accent); color: #fff; font: 650 .72rem/1 var(--mono); }
.tb-count { min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 500 .88rem/1.2 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tb-right { margin-left: auto; display: flex; gap: .45rem; align-items: center; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); }
.seg button {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 2.2rem; padding: .25rem .8rem; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer; font-size: .9rem;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg.sm button { min-height: 2rem; font-size: .84rem; }

.tb-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1.1rem 1rem; max-height: 46vh; overflow: auto; flex: none; }
.tb-ph { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.tb-ph .lab { font-weight: 700; }
.tb-sec { display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
.tb-f { display: flex; flex-direction: column; gap: .5rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.tb-fh, .tb-srow { display: flex; align-items: center; gap: .6rem; min-width: 0; flex-wrap: wrap; }
.tb-fh .lab { flex: 1 1 auto; font-weight: 650; font-size: .92rem; }
.tb-srow .lab { flex: 0 1 11rem; min-width: 0; font-weight: 600; font-size: .92rem; }
.tb-srow select.add { flex: 0 1 16rem; width: auto; }
.tb-fcol { display: flex; flex-direction: column; gap: .5rem; }
.tb-fcol > .field { max-width: 22rem; }
.tb-chips { display: flex; flex-wrap: wrap; gap: .35rem; min-width: 0; align-items: center; }
.tchip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .75rem; min-height: 2.3rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink); cursor: pointer; font: 550 .88rem/1.1 var(--font); max-width: 100%;
}
.tchip .n { font: 500 .76rem/1 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tchip:hover { border-color: var(--ink-3); }
.tchip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tchip[aria-pressed="true"] .n { color: inherit; opacity: .75; }
.tchip.add { border-style: dashed; color: var(--ink-2); }
.tchip.stage[aria-pressed="true"] { background: hsl(var(--h) 55% 32%); border-color: transparent; }
.cdot { width: .6rem; height: .6rem; border-radius: 50%; background: hsl(var(--h) 60% 48%); flex: none; }
.tb-range { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tb-range .field { width: 8.5rem; }
.tb-dl { display: flex; gap: .4rem; align-items: center; }
.tb-dl .field { width: 10.5rem; }
.tb-cols { display: flex; flex-direction: column; max-height: 22rem; overflow: auto; }
.tb-colrow { display: flex; align-items: center; gap: .6rem; padding: .25rem 0; border-bottom: 1px solid var(--line-soft); min-height: 2.6rem; }
.tb-colrow.off .grow { color: var(--ink-2); }
.tb-colrow .grow { flex: 1 1 auto; min-width: 0; }
.tb-check {
  flex: none; width: 1.5rem; height: 1.5rem; display: inline-grid; place-items: center; padding: 0; border: 1.5px solid var(--ink-3);
  border-radius: 6px; background: transparent; color: #fff; font: 700 .85rem/1 var(--font); cursor: pointer;
}
.tb-check[aria-pressed="true"], [aria-selected="true"] > .tb-check { background: var(--ink); border-color: var(--ink); }
.tb-check:disabled { opacity: .45; cursor: default; }
.x {
  flex: none; width: 2.4rem; height: 2.4rem; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 999px;
  background: none; color: var(--ink-2); cursor: pointer; padding: 0; font: 600 1rem/1 var(--font);
}
.x:hover:not(:disabled) { border-color: var(--line); color: var(--ink); }
.x:disabled { opacity: .25; cursor: default; }
.x .ic { width: 1.05rem; height: 1.05rem; }

/* ---------- table: the grid ---------- */
.tb-wrap { flex: 1 1 auto; min-height: 0; display: flex; min-width: 0; }
.tb-wrap.card { padding: 0; overflow: hidden; }
.tb-scroll { position: relative; flex: 1; min-width: 0; overflow: auto; overscroll-behavior: contain; outline: none; font-variant-numeric: tabular-nums; -webkit-overflow-scrolling: touch; }
.tb-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.tb-grid { position: relative; min-height: 100%; }
.tb-head { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: var(--cols); background: var(--card); border-bottom: 1px solid var(--line); }
.tb-th {
  display: flex; align-items: center; gap: .3rem; min-width: 0; height: 2.3rem; padding: 0 .75rem; border: 0; border-right: 1px solid var(--line-soft);
  background: var(--card); color: var(--ink-2); font: 550 .8rem/1 var(--font); text-align: left; cursor: pointer; white-space: nowrap;
}
.tb-th .tx { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-th:hover { color: var(--ink); background: var(--hover); }
.tb-th[aria-sort] { color: var(--ink); }
.tb-th .sa { font: 650 .78rem/1 var(--mono); color: var(--accent); }
.tb-th.num { justify-content: flex-end; }
.tb-th:first-child { position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 var(--line); }
.tb-th:last-child, .tb-td:last-child { border-right: 0; }
.tb-body { position: relative; }
.tb-row { position: absolute; left: 0; right: 0; height: 2.3rem; display: grid; grid-template-columns: var(--cols); }
.tb-td {
  display: flex; align-items: center; gap: .3rem; min-width: 0; overflow: hidden; white-space: nowrap; padding: 0 .75rem;
  background: var(--card); border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); font-size: .93rem; cursor: default;
}
.tb-td .tx { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-td:first-child { position: sticky; left: 0; z-index: 1; font-weight: 650; box-shadow: 1px 0 0 var(--line); cursor: pointer; }
.tb-td:first-child:hover .nm { text-decoration: underline; text-decoration-color: var(--ink-3); text-underline-offset: .2em; }
.tb-row:hover .tb-td { background: var(--hover); }
.tb-row.open .tb-td { background: var(--accent-soft); }
.tb-td.num { justify-content: flex-end; }
.tb-td.sel { box-shadow: inset 0 0 0 2px var(--accent); z-index: 2; }
.tb-td:first-child.sel { box-shadow: inset 0 0 0 2px var(--accent), 1px 0 0 var(--line); }
.tb-a { color: var(--accent); text-decoration: none; overflow: hidden; text-overflow: ellipsis; min-width: 0; white-space: nowrap; }
.tb-a:hover { text-decoration: underline; }
.tb-rel { border: 0; background: none; padding: 0; color: var(--ink); font: inherit; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: .2em; }
.tb-rel:hover { text-decoration-color: currentColor; }
.tb-grp { position: absolute; left: 0; right: 0; height: 2.3rem; display: flex; align-items: flex-end; background: var(--card-2); border-bottom: 1px solid var(--line); }
.tb-gbtn { position: sticky; left: 0; display: inline-flex; align-items: center; gap: .55rem; height: 100%; padding: 0 .8rem; border: 0; background: none; color: var(--ink); cursor: pointer; font: 650 .9rem/1 var(--font); }
.tb-gbtn .car { width: .8rem; color: var(--ink-2); }
.tb-gbtn .n { font: 500 .8rem/1 var(--mono); color: var(--ink-2); }
.tb-none { padding: 3rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .8rem; color: var(--ink-2); }

/* inline editor */
.tb-ed { position: absolute; z-index: 6; width: var(--cw); height: var(--ch); background: var(--card); box-shadow: 0 0 0 2px var(--accent), 0 10px 26px rgba(0, 0, 0, .14); border-radius: 3px; }
.tb-ed.long { height: auto; width: max(var(--cw), 24rem); }
.tb-ed.picking { background: transparent; box-shadow: 0 0 0 2px var(--accent); }
.tb-in { display: block; width: 100%; height: 100%; border: 0; padding: 0 .75rem; background: transparent; color: var(--ink); font: inherit; font-size: .93rem; outline: none; }
.tb-in.long { padding: .6rem .75rem; resize: vertical; min-height: 8rem; }
.tb-pickbox {
  position: absolute; top: calc(100% + 4px); left: -2px; min-width: calc(100% + 4px); width: max-content; max-width: 22rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: .35rem; display: flex; flex-direction: column; gap: .3rem;
}
.tb-pick { max-height: 18rem; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.tb-pick button { display: flex; align-items: center; gap: .55rem; padding: .4rem .55rem; border: 0; border-radius: 9px; background: none; color: var(--ink); cursor: pointer; text-align: left; min-height: 2.4rem; font: inherit; }
.tb-pick button:hover, .tb-pick button:focus-visible { background: var(--hover); outline: none; }
.tb-pick button[aria-selected="true"]:not(:has(.tb-check)) { background: var(--card-2); }
.tb-pick .clr { color: var(--ink-2); font-size: .88rem; }

/* phone cards */
.tb-wrap.cards .tb-scroll { background: var(--card); }
.tb-crow { position: absolute; left: 0; right: 0; height: 4.6rem; display: flex; align-items: center; border-bottom: 1px solid var(--line-soft); background: var(--card); min-width: 0; }
.tb-crow.open { background: var(--accent-soft); }
.tb-copen {
  flex: 1 1 auto; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: .35rem; padding: 0 0 0 1rem;
  border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit;
}
.tb-copen:active { background: var(--hover); }
.tb-crow .nm { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-size: 1.02rem; }
.tb-crow .kv { display: flex; gap: .35rem .6rem; align-items: center; min-width: 0; overflow: hidden; color: var(--ink-2); font-size: .86rem; white-space: nowrap; }
.kvi { display: inline-flex; align-items: center; gap: .3rem; min-width: 0; flex: 0 1 auto; overflow: hidden; }
.kvi .tx { overflow: hidden; text-overflow: ellipsis; }
.tb-ccall {
  flex: none; width: 3rem; height: 3rem; margin: 0 .8rem 0 .4rem; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
}
.tb-ccall .ic { width: 1.3rem; height: 1.3rem; }

/* board */
.tb-wrap.board { overflow: hidden; }
.tb-kan { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(16rem, 1fr); gap: .8rem; overflow-x: auto; overflow-y: hidden; padding-bottom: .3rem; overscroll-behavior-x: contain; min-width: 0; }
.tb-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-radius: var(--radius); background: color-mix(in srgb, var(--bg-2) 75%, transparent); border: 1.5px solid transparent; }
.tb-col.over { border-color: var(--accent); background: var(--accent-soft); }
.tb-colh { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem .8rem .55rem; }
.tb-colh .n { font: 500 .82rem/1 var(--mono); color: var(--ink-2); }
.tb-colb { display: flex; flex-direction: column; gap: .5rem; padding: 0 .55rem .7rem; overflow: auto; min-height: 4rem; flex: 1; }
.tb-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .65rem .8rem; display: flex; flex-direction: column; gap: .45rem; min-width: 0; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); cursor: grab; }
.tb-card.open { border-color: var(--accent); }
.tb-card.dragging { opacity: .45; }
.tb-cname { border: 0; background: none; padding: 0; text-align: left; font: 650 1rem/1.25 var(--font); color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.tb-cname:hover { text-decoration: underline; text-underline-offset: .2em; }
.tb-cmeta { display: flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: center; color: var(--ink-2); font-size: .86rem; min-width: 0; }
.stage-pick {
  appearance: none; -webkit-appearance: none; align-self: flex-start; min-height: 2.5rem; padding: .3rem 1rem; border-radius: 999px; border: 0;
  background: hsl(var(--h, 200) var(--tint-s) var(--tint-l)); color: hsl(var(--h, 200) var(--tone-s) var(--tone-l)); font: 650 .9rem/1 var(--font);
}
.tb-drop { padding: .3rem .4rem; }
.tb-more { align-self: center; }

/* bottom sheet (phone) and modal */
.sheet-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(15, 30, 28, .36); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 86dvh; overflow: auto; display: flex; flex-direction: column; gap: 1.1rem;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 0 1rem calc(1.4rem + env(safe-area-inset-bottom)); box-shadow: 0 -14px 40px rgba(0, 0, 0, .2);
  overscroll-behavior: contain;
}
.sheet-head { position: sticky; top: 0; z-index: 1; background: var(--card); margin: 0 -1rem; padding: .9rem 1rem .7rem; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sheet-sec { display: flex; flex-direction: column; gap: .6rem; }
.sheet-h { margin: 0; font: 700 1.05rem/1.2 var(--font); }
.sheet .tb-srow .lab { flex-basis: 100%; }
.sheet.modal { gap: .8rem; }
@media (min-width: 721px) {
  .sheet.modal { left: 50%; right: auto; bottom: auto; top: 12vh; transform: translateX(-50%); width: min(30rem, calc(100vw - 32px)); border-radius: 22px; padding-bottom: 1.2rem; }
}
.modal-form { display: flex; flex-direction: column; gap: .7rem; }
.fieldrow { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.flab { font-size: .82rem; font-weight: 650; color: var(--ink-2); }
.row-btns { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- company page ---------- */
.cp {
  position: fixed; z-index: 30; top: 0; right: 0; bottom: 0; width: min(38rem, 46vw); display: flex; flex-direction: column;
  background: var(--card); box-shadow: -18px 0 50px rgba(20, 40, 35, .14); border-left: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
@media (max-width: 720px) { .cp { width: 100%; border-left: 0; } }
.cp-scroll { flex: 1; overflow: auto; overscroll-behavior: contain; padding: .8rem 1.3rem calc(2rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 1.1rem; }
@media (max-width: 720px) { .cp-scroll { padding: .5rem 1rem calc(2rem + env(safe-area-inset-bottom)); } }
.cp-head { display: flex; flex-direction: column; gap: .6rem; }
.cp-bar { display: flex; align-items: center; gap: .6rem; margin-left: -.6rem; }
.cp-crumb { font-weight: 600; color: var(--ink-2); font-size: .9rem; margin-right: auto; }
.cp-name { font: 800 clamp(1.6rem, 1.2rem + 1vw, 2.3rem)/1.08 var(--font); letter-spacing: -.025em; overflow-wrap: anywhere; }
.cp-tags { display: flex; flex-wrap: wrap; gap: .45rem .6rem; align-items: center; }
.stage-btn { display: inline-flex; align-items: center; gap: .25rem; border: 0; background: none; padding: .3rem 0; cursor: pointer; color: var(--ink-2); min-height: 2.4rem; }
.stage-btn .tp { font-size: .9rem; padding: .3rem .8rem; }
.cp-owner { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-2); font-size: .92rem; }
.cp-next { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--ink-2); font-size: .92rem; }
.cp-next.due { color: var(--bad); }
.cp-reach { display: flex; flex-direction: column; gap: .6rem; }
.callbtn, .bigcall {
  display: flex; align-items: center; justify-content: center; gap: .7rem; min-height: 3.6rem; padding: .7rem 1.2rem; border-radius: 999px;
  background: var(--accent); color: #fff; text-decoration: none; font-size: 1.15rem; font-weight: 600; box-shadow: 0 8px 20px rgba(11, 122, 110, .25);
}
.callbtn b, .bigcall b { font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.callbtn .ic, .bigcall .ic { width: 1.4rem; height: 1.4rem; }
.callbtn:active, .bigcall:active { transform: translateY(1px); }
.reach-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.rbtn {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 2.6rem; padding: .35rem .95rem; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-weight: 550; font-size: .92rem; max-width: 100%; min-width: 0;
}
.rbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rbtn:hover { border-color: var(--ink-3); }
.cp-sec { display: flex; flex-direction: column; gap: .6rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); }
.cp-h { display: flex; align-items: center; gap: .5rem; font: 700 1.02rem/1.2 var(--font); margin: 0; }
.cp-h .n { font: 500 .8rem/1 var(--mono); color: var(--ink-3); }
.cp-h .btn { margin-left: auto; }
details.cp-group > summary { cursor: pointer; list-style: none; min-height: 2.2rem; }
details.cp-group > summary::-webkit-details-marker { display: none; }
details.cp-group > summary::after { content: '▾'; color: var(--ink-3); font-size: .8rem; }
details.cp-group:not([open]) > summary::after { content: '▸'; }
.cp-fields { display: flex; flex-direction: column; gap: 1.1rem; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: .75rem 1rem; align-items: start; }
.rgrid .fieldrow.wide { grid-column: 1 / -1; }
.rgrid .seg { align-self: flex-start; }
.rro { margin: 0; padding: .55rem 0; color: var(--ink-2); }
.tagadd { width: 8.5rem; }
textarea.field { resize: vertical; line-height: 1.4; }

/* contacts on the company page */
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.person { display: flex; align-items: flex-start; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--line-soft); }
.p-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.p-name { font-weight: 650; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.p-links { display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .92rem; }
.ct-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); gap: .5rem; }
.ct-form .check-row, .ct-form .row-btns { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; gap: .55rem; min-height: 2.4rem; font-size: .92rem; }
.check-row input { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }

/* timeline + feed rows */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.act-item { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.act-item:last-child { border-bottom: 0; }
.act-ic { flex: none; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); color: var(--ink-2); }
.act-ic[data-tone="good"] { background: #ddf3e6; color: var(--good); }
.act-ic[data-tone="bad"] { background: #fbe3e0; color: var(--bad); }
.act-ic .ic { width: 1.05rem; height: 1.05rem; }
.act-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.act-top { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .55rem; }
.act-what { font-weight: 650; }
.act-co { border: 0; background: none; padding: 0; font: 700 1rem/1.3 var(--font); color: var(--ink); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: .2em; }
.act-text { margin: 0; color: var(--ink); font-size: .95rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.act-meta { font-size: .82rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.oc-pill { display: inline-flex; align-items: center; padding: .12rem .55rem; border-radius: 999px; background: var(--card-2); color: var(--ink-2); font-size: .8rem; font-weight: 650; }
.oc-pill[data-tone="good"] { background: #ddf3e6; color: var(--good); }
.oc-pill[data-tone="bad"] { background: #fbe3e0; color: var(--bad); }

/* ---------- the logger (company page + call mode) ---------- */
.logger { display: flex; flex-direction: column; gap: .7rem; }
.logger.busy { opacity: .6; pointer-events: none; }
.log-types { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .3rem; padding: 3px; border-radius: 16px; background: var(--card-2); }
.ltype {
  display: flex; flex-direction: column; align-items: center; gap: .2rem; min-height: 3.1rem; padding: .35rem .2rem; border: 0; border-radius: 13px;
  background: transparent; color: var(--ink-2); font: 600 .8rem/1.1 var(--font); cursor: pointer;
}
.ltype[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.outcomes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: .4rem; }
.oc {
  min-height: 2.9rem; padding: .45rem .7rem; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: 600 .95rem/1.15 var(--font); cursor: pointer; text-align: center;
}
.oc:hover { border-color: var(--ink-3); }
.oc:active { transform: translateY(1px); }
.oc[data-tone="good"] { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); color: var(--good); }
.oc[data-tone="bad"] { color: var(--bad); }
.oc[data-outcome="meeting_booked"] { background: var(--good); border-color: var(--good); color: #fff; }
.log-extra { display: flex; flex-direction: column; gap: .5rem; }
.next-row { display: flex; align-items: center; gap: .5rem .7rem; flex-wrap: wrap; }
.next-row .lab { display: inline-flex; align-items: center; gap: .35rem; font-weight: 650; font-size: .88rem; color: var(--ink-2); min-width: 5.5rem; }
.next-row > .field { flex: 1 1 12rem; }
.next-row .date { width: 10.5rem; }
.oncall { display: flex; align-items: center; gap: .5rem; font-weight: 650; color: var(--live); font-variant-numeric: tabular-nums; margin: 0; }
.rec { width: .7rem; height: .7rem; border-radius: 50%; background: var(--live); animation: pulse 1.4s ease-in-out infinite; }

/* ---------- call mode ---------- */
.cm { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .6rem; }
.cm-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr); gap: var(--gap); }
.cm-side { display: flex; flex-direction: column; gap: .6rem; min-height: 0; overflow: hidden; }
.cm.phone .cm-side { flex: 1; overflow: auto; }
.cm-head { display: flex; gap: .5rem; align-items: center; }
.qpick { flex: 1; min-width: 0; font-weight: 650; border-radius: 999px !important; }
.qlist { list-style: none; margin: 0; padding: .3rem; overflow: auto; flex: 1; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.qitem {
  width: 100%; display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); grid-template-rows: auto auto; column-gap: .4rem; align-items: center;
  padding: .45rem .55rem; min-height: 3rem; border: 0; border-radius: 12px; background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit;
}
.qitem:hover { background: var(--hover); }
.qitem[aria-current="true"] { background: var(--accent-soft); }
.qtick { grid-row: 1 / 3; width: 1.35rem; height: 1.35rem; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; color: #fff; }
.qtick .ic { width: .85rem; height: .85rem; }
.qitem[data-state="done"] .qtick { background: var(--good); border-color: var(--good); }
.qitem[data-state="done"] .qname { color: var(--ink-3); text-decoration: line-through; }
.qitem[data-state="skipped"] .qname { color: var(--ink-2); }
.qname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qmeta { grid-column: 2; font-size: .8rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-main { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: .7rem; align-items: center; padding-bottom: 1.5rem; overscroll-behavior: contain; }
.cm-main > * { width: min(100%, 44rem); }
.cm-progress { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; align-items: center; }
.cm-count { font: 500 .95rem/1 var(--font); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cm-count b { color: var(--ink); font-size: 1.15rem; }
.meter { height: .45rem; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.cm-stats { grid-column: 1 / -1; display: flex; gap: 1rem; color: var(--ink-2); font-size: .88rem; font-variant-numeric: tabular-nums; }
.cm-stats b { color: var(--ink); }
.cm-card { background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 1.2rem 1.3rem 1rem; display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
@media (max-width: 720px) { .cm-card { padding: 1rem 1rem .8rem; border-radius: 20px; } }
.cm-top { display: flex; flex-wrap: wrap; gap: .4rem .5rem; align-items: center; }
.due-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: 999px; background: #fbe3e0; color: var(--bad); font-weight: 700; font-size: .82rem; }
.cm-name {
  border: 0; background: none; padding: 0; text-align: left; color: var(--ink); cursor: pointer;
  font: 800 clamp(1.9rem, 1.3rem + 2vw, 3rem)/1.04 var(--font); letter-spacing: -.03em; overflow-wrap: anywhere;
}
.cm-who { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: 0; font-size: 1.02rem; }
.cm-who span { display: inline-flex; align-items: center; gap: .3rem; }
.cm-hooks { display: flex; flex-wrap: wrap; gap: .4rem; }
.hook { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: 999px; background: var(--card-2); color: var(--ink); font-size: .85rem; font-weight: 550; }
.cm-notes { margin: 0; padding: .6rem .8rem; border-radius: 14px; background: #fff7ec; color: #4d3a1c; font-size: .95rem; overflow-wrap: anywhere; }
.cm-last { display: flex; align-items: center; gap: .4rem; margin: 0; color: var(--ink-2); font-size: .9rem; }
.bigcall { min-height: 4.4rem; font-size: 1.3rem; }
.bigcall.live { background: var(--live); box-shadow: 0 8px 20px rgba(210, 60, 47, .25); }
.cm-alt { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: -.2rem 0 0; font-size: .92rem; justify-content: center; }
.logger.big .outcomes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
@media (min-width: 721px) { .logger.big .outcomes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.logger.big .oc { min-height: 3.5rem; font-size: 1rem; border-radius: 16px; }
.cm-foot { display: flex; justify-content: space-between; gap: .5rem; border-top: 1px solid var(--line-soft); padding-top: .6rem; }
.cm-foot .btn { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.9rem; }
.cm-empty { align-items: flex-start; }
.cm-empty h2 { font: 800 1.6rem/1.1 var(--font); }

/* ---------- activity feed ---------- */
.feed { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 1.1rem; padding-bottom: 2rem; }
.feed > * { width: min(100%, 52rem); margin: 0 auto; }
.feed-today { padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .7rem; }
.ft-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ft-head h2 { font: 800 1.5rem/1.1 var(--font); letter-spacing: -.02em; }
.ft-types { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.ft-type { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-2); }
.ft-type b { color: var(--ink); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.feed-day { display: flex; flex-direction: column; gap: .2rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem .4rem; }
.empty-note { text-align: center; padding: 2rem 1rem; }

:root.cp-open[data-view="crm"] .crm-tabs.bottom { visibility: hidden; }
@media (min-width: 721px) {
  /* leave room for the side panel so the table stays usable beside it */
  :root.cp-open[data-view="crm"] .crm-main { margin-right: min(38rem, 46vw); }
}
@media (prefers-reduced-motion: reduce) { .rec { animation: none; } .meter i { transition: none; } }

/* ---------- phone tidy-ups ---------- */
:root[data-view="crm"] textarea, :root[data-view="crm"] select { font: inherit; color: inherit; }
.tb-crow .kvi + .kvi::before { content: '·'; color: var(--ink-3); margin-right: .1rem; }
@media (max-width: 720px) {
  .tb { gap: .45rem; }
  .tb-views [data-k="view-new"] { display: none; }
  .tb-search { flex-basis: 100%; max-width: none; }
  .tb-bar { gap: .45rem; flex-wrap: nowrap; }
  .tb-bar .tb-search { display: none; }
  .tb-count .lbl { display: none; }
  .tb-right .seg button { padding: .25rem .6rem; }
  .tb-right [data-k="new"] { padding: .35rem .7rem; }
  .tb-right [data-k="new"] span { display: none; }
}
.oc-pill { gap: .3rem; }
.stage-wrap { position: relative; align-self: flex-start; display: inline-flex; }
.stage-wrap::after { content: '▾'; position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: hsl(var(--h, 200) var(--tone-s) var(--tone-l)); }
.stage-wrap .stage-pick { padding-right: 2.1rem; }
@media (max-width: 720px) {
  .tb-kan { scroll-snap-type: x mandatory; grid-auto-columns: minmax(16rem, 82%); }
  .tb-col { scroll-snap-align: start; }
  :root[data-view="crm"] .toast { bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
  :root.cp-open[data-view="crm"] .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
}
