/* Home's CRM tab (web/lib/ui/crm-tab.js): Companies table, Pipeline, company page. Phone first: rows stack
   into two lines under 900px; 900px and up the table has real columns and the pipeline is columns. Scoped .la .crt. */

.la .crt {
  --crt-ink: #1d1d1f; --crt-ink-2: #6e6e73; --crt-line: rgba(60, 60, 67, .14); --crt-blue: #0a84ff; --crt-soft: rgba(118, 118, 128, .1);
  width: 100%; max-width: 84rem; margin: 0 auto; min-width: 0; padding: .4rem 12px 3rem; color: var(--crt-ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, Arial, sans-serif;
}
.la .crt-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin: .3rem 0 .5rem; }
.la .crt-segs { display: flex; gap: .2rem; padding: .18rem; border-radius: 10px; background: var(--crt-soft); }
.la .crt-seg { min-height: 2.2rem; padding: .25rem 1rem; border: 0; border-radius: 8px; background: none; font: inherit; font-weight: 600; font-size: .95rem; color: var(--crt-ink-2); cursor: pointer; }
.la .crt-seg[aria-pressed="true"] { background: #fff; color: var(--crt-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.la .crt-listsel {
  flex: none; min-height: 2.4rem; padding: .3rem 2rem .3rem .85rem; border: 1px solid var(--crt-line); border-radius: 10px; background: #fff; color: var(--crt-ink);
  font: 600 1.05rem/1 inherit; cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 12 12'><path d='M3 4.5 6 8l3-3.5' fill='none' stroke='%236e6e73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right .6rem center;
}
.la .crt-sync { color: var(--crt-ink-2); font-size: .8rem; white-space: nowrap; }
.la .crt-segf { display: inline-flex; margin: .1rem 0 .2rem; }
.la .crt-segf .crt-seg { min-height: 2rem; padding: .2rem .9rem; font-size: .88rem; }
.la .crt-seg { white-space: nowrap; }
@media (max-width: 420px) { .la .crt-top { flex-wrap: wrap; row-gap: .2rem; } .la .crt-top .crt-seg { padding: .25rem .7rem; } }
.la .crt-d100 + .crt-d100 { margin-top: .4rem; }
.la .crt-tools { display: flex; gap: .4rem; }
.la .crt-q { flex: 1 1 auto; min-width: 0; min-height: 2.6rem; padding: .4rem .75rem; border: 1px solid var(--crt-line); border-radius: 10px; font: inherit; font-size: 1rem; background: #fff; color: inherit; }
.la .crt-sort { flex: none; min-height: 2.6rem; padding: 0 .5rem; border: 1px solid var(--crt-line); border-radius: 10px; font: inherit; font-size: .9rem; background: #fff; color: inherit; }
.la .crt-sub { color: var(--crt-ink-2); font-size: .85rem; margin: .45rem .1rem .35rem; }
.la .crt-empty { color: var(--crt-ink-2); margin: 1.2rem .2rem; }
.la .crt-h3 { font-size: 1rem; font-weight: 700; margin: 1.1rem .1rem .45rem; display: flex; align-items: center; gap: .35rem; }
.la .crt-dim { color: var(--crt-ink-2); }

/* stage colours */
.la [data-stage="New"]         { --st: #8e8e93; }
.la [data-stage="Contacted"]   { --st: #5e5ce6; }
.la [data-stage="Replied"]     { --st: #e08600; }
.la [data-stage="Talking"]     { --st: #ff5e00; }
.la [data-stage="Booked call"] { --st: #0a84ff; }
.la [data-stage="Pilot"]       { --st: #a53fd6; }
.la [data-stage="Won"]         { --st: #22a04b; }
.la [data-stage="Lost"]        { --st: #c0392f; }
.la .crt-stage { display: inline-block; padding: .08rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap;
  color: var(--st, #8e8e93); background: color-mix(in srgb, var(--st, #8e8e93) 13%, transparent); }

/* the table: phone = two-line rows */
.la .crt-table { display: flex; flex-direction: column; min-width: 0; }
.la .crt-thead { display: none; }
.la .crt-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name st" "sub last"; column-gap: .6rem; row-gap: .15rem;
  width: 100%; min-width: 0; padding: .6rem .2rem; border: 0; border-bottom: 1px solid var(--crt-line); background: none; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
@media (hover: hover) { .la .crt-row:hover, .la .crt-card:hover { background: rgba(118, 118, 128, .06); } }
.la .crt-c { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.la .crt-name { grid-area: name; font-weight: 600; font-size: 1rem; }
.la .crt-st { grid-area: st; justify-self: end; }
.la .crt-last { grid-area: last; justify-self: end; color: var(--crt-ink-2); font-size: .85rem; }
.la .crt-last[data-dir="in"] { color: #b45f00; font-weight: 600; }
.la .crt-row .crt-mob { grid-area: sub; color: var(--crt-ink-2); font-size: .85rem; }
.la .crt-row .crt-mail, .la .crt-row .crt-web, .la .crt-row .crt-ppl, .la .crt-row .crt-place { display: none; }
.la .crt-row:has(.crt-mob:empty) .crt-place { display: block; grid-area: sub; color: var(--crt-ink-2); font-size: .85rem; }
.la .crt-row:has(.crt-mob:empty) .crt-mob { display: none; }
.la .crt-more { display: block; margin: .8rem auto; min-height: 2.4rem; padding: .3rem 1rem; border: 1px solid var(--crt-line); border-radius: 10px; background: #fff; font: inherit; cursor: pointer; }

@media (min-width: 900px) {
  .la .crt-thead, .la .crt-row {
    display: grid; grid-template-areas: none;
    grid-template-columns: minmax(10rem, 2fr) 7rem 7.5rem minmax(8rem, 1.6fr) minmax(7rem, 1.2fr) minmax(7rem, 1.1fr) 5rem 8.5rem; column-gap: .75rem;
  }
  .la .crt-thead { padding: .3rem .2rem; border-bottom: 1px solid var(--crt-line); color: var(--crt-ink-2); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
  .la .crt-row > .crt-c, .la .crt-row:has(.crt-mob:empty) .crt-mob { grid-area: auto; display: block; justify-self: stretch; font-size: .9rem; }
  .la .crt-row .crt-st { justify-self: start; }
  .la .crt-row .crt-mob, .la .crt-row .crt-place, .la .crt-row .crt-mail, .la .crt-row .crt-web, .la .crt-row .crt-ppl { color: var(--crt-ink-2); }
}

/* pipeline */
.la .crt-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
.la .crt-stchip {
  display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; min-width: 0; padding: .45rem .55rem; border: 1px solid var(--crt-line); border-left: 4px solid var(--st);
  border-radius: 10px; background: #fff; font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.la .crt-stchip span { font-size: .78rem; color: var(--crt-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.la .crt-n { font-size: 1.25rem; line-height: 1.1; }
.la .crt-stchip[aria-pressed="true"] { background: color-mix(in srgb, var(--st) 12%, #fff); border-color: var(--st); }
.la .crt-cols { display: flex; flex-direction: column; gap: .2rem; }
.la .crt-col .crt-h3 { margin-top: .9rem; }
.la .crt-card { display: flex; flex-direction: column; gap: .1rem; width: 100%; min-width: 0; padding: .5rem .55rem; margin-bottom: .3rem; border: 1px solid var(--crt-line); border-radius: 10px; background: #fff; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.la .crt-card b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.la .crt-card-sub { color: var(--crt-ink-2); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.la .crt-none { color: var(--crt-ink-2); margin: 0 .2rem; }
@media (min-width: 900px) {
  .la .crt-strip { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .la .crt-cols { display: grid; grid-template-columns: repeat(7, minmax(9rem, 1fr)); gap: .55rem; overflow-x: auto; align-items: start; }
  .la .crt-col { background: var(--crt-soft); border-radius: 12px; padding: 0 .4rem .4rem; min-width: 0; }
}

/* company page */
.la .crt-back { min-height: 2.4rem; padding: .2rem .1rem; border: 0; background: none; color: var(--crt-blue); font: inherit; font-size: 1rem; cursor: pointer; }
.la .crt-cohead { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .2rem; }
.la .crt-coname { font-size: 1.5rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.la .crt-stages { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.la .crt-stchip.sm { flex-direction: row; padding: .3rem .6rem; font-size: .85rem; min-height: 2.2rem; align-items: center; }
.la .crt-people { display: flex; flex-direction: column; gap: .4rem; }
.la .crt-person { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .6rem; padding: .55rem .65rem; border: 1px solid var(--crt-line); border-radius: 10px; background: #fff; }
.la .crt-pmain { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; min-width: 0; }
.la .crt-role { color: var(--crt-ink-2); font-size: .85rem; }
.la .crt-pline { grid-column: 1; display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.la .crt-person > .crt-link { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.la .crt-pform { grid-template-columns: 1fr; }
.la .crt-prow { display: flex; gap: .6rem; align-items: center; }
.la .crt-link { min-height: 2.2rem; padding: .2rem .3rem; border: 0; background: none; color: var(--crt-blue); font: inherit; cursor: pointer; text-align: left; text-decoration: none; }
.la .crt-btn { flex: none; min-height: 2.4rem; padding: .3rem 1rem; border: 0; border-radius: 10px; background: var(--crt-blue); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.la .crt-btn:disabled { opacity: .5; }
.la .crt-in { width: 100%; min-width: 0; min-height: 2.4rem; padding: .35rem .6rem; border: 1px solid var(--crt-line); border-radius: 8px; background: #fff; font: inherit; font-size: 1rem; color: inherit; }
.la textarea.crt-in { resize: vertical; }
.la .crt-addnote { display: flex; gap: .4rem; align-items: flex-end; margin-bottom: .5rem; }
.la .crt-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.la .crt-act { padding: .55rem .2rem .6rem .7rem; border-left: 3px solid #c7c7cc; border-bottom: 1px solid var(--crt-line); }
.la .crt-act[data-type="sms"] { border-left-color: #30b158; }
.la .crt-act[data-type="email"] { border-left-color: #0a84ff; }
.la .crt-act[data-type="call"] { border-left-color: #ff9f0a; }
.la .crt-act[data-type="note"] { border-left-color: #8e8e93; background: rgba(118, 118, 128, .05); }
.la .crt-act[data-dir="in"] { background: rgba(255, 159, 10, .07); }
.la .crt-amain { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .6rem; }
.la .crt-atype { font-weight: 600; font-size: .9rem; }
.la .crt-awhen { color: var(--crt-ink-2); font-size: .8rem; }
.la .crt-asubj { font-weight: 600; font-size: .9rem; margin-top: .15rem; }
.la .crt-abody { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .93rem; margin-top: .15rem; }
.la .crt-fields { display: grid; grid-template-columns: 1fr; gap: .45rem; }
.la .crt-field { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.la .crt-lab { color: var(--crt-ink-2); font-size: .78rem; font-weight: 600; }
.la .crt-chans { display: flex; flex-direction: column; gap: .25rem; margin-top: .8rem; }
.la .crt-chan { display: flex; gap: .6rem; font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.la .crt-chan > .crt-dim:first-child { flex: none; width: 4.5rem; }
@media (min-width: 900px) {
  .la .crt[data-mode="company"] { max-width: 60rem; }
  .la .crt-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .la .crt-field.wide { grid-column: 1 / -1; }
}

/* next steps (To Dos with a company_id) */
.la .crt-next { font-size: .8rem; color: var(--crt-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.la .crt-next[data-late="true"] { color: #d70015; font-weight: 600; }
.la .crt-next[data-none="true"] { color: #b25000; }
.la .crt-tasks { list-style: none; margin: 0 0 .4rem; padding: 0; }
.la .crt-task { display: flex; align-items: center; gap: .6rem; padding: .45rem .1rem; border-bottom: 1px solid var(--crt-line); }
.la .crt-ttl { flex: 1 1 auto; min-width: 0; }
.la .crt-tdue { flex: none; font-size: .85rem; }
.la .crt-tdue[data-late="true"] { color: #d70015; font-weight: 600; }
.la .crt-addtask { display: flex; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 .6rem; }
.la .crt-addtask > .crt-in:first-child { flex: 1 1 12rem; min-width: 0; }
.la .crt-due { flex: 0 0 auto; width: auto; }

/* ===== Material 3 draft (flag): CRM home tab (Companies/Pipeline/company page). Only the changed
   declarations are overridden, so the live look stays byte-equivalent when the pill is off. ===== */
:where([data-md3]) .la .crt {
  --crt-ink: var(--md-sys-color-on-surface); --crt-ink-2: var(--md-sys-color-on-surface-variant); --crt-line: var(--md-sys-color-outline-variant); --crt-blue: var(--md-sys-color-primary); --crt-soft: var(--md-sys-color-surface-container);
  font-family: var(--md-ref-typeface-plain);
}
:where([data-md3]) .la .crt-seg[aria-pressed="true"] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); box-shadow: none; }
:where([data-md3]) .la .crt-listsel { border: 1px solid var(--md-sys-color-outline); background: var(--md-sys-color-surface-container-lowest); }
:where([data-md3]) .la .crt-q { background: var(--md-sys-color-surface-container-lowest); }
:where([data-md3]) .la .crt-sort { background: var(--md-sys-color-surface-container-lowest); }
:where([data-md3]) .la .crt-h3 { font-weight: 500; }
:where([data-md3]) .la .crt-more { background: var(--md-sys-color-surface-container-lowest); }
:where([data-md3]) .la .crt-stchip { background: var(--md-sys-color-surface-container-lowest); }
:where([data-md3]) .la .crt-stchip[aria-pressed="true"] { background: color-mix(in srgb, var(--st) 12%, var(--md-sys-color-surface-container-lowest)); }
:where([data-md3]) .la .crt-card { background: var(--md-sys-color-surface-container-lowest); }
:where([data-md3]) .la .crt-coname { font-size: var(--md-sys-typescale-headline-small-size, 1.5rem); font-weight: 400; }
:where([data-md3]) .la .crt-person { background: var(--md-sys-color-surface-container-lowest); }
:where([data-md3]) .la .crt-btn { padding: .3rem 1.25rem; border-radius: var(--md-sys-shape-corner-full); color: var(--md-sys-color-on-primary); font-weight: 500; }
:where([data-md3]) .la .crt-in { background: var(--md-sys-color-surface-container-lowest); }
