/* CRM v4: page-level styles only. The frame (header, side navigation, page,
   bottom navigation, mobile menu) is cm-app-frame; every colour, space and
   font comes from Commmerce UI tokens (--cm-*). Components are never styled
   from outside. */

html, body { margin: 0; }
body {
  background: var(--cm-bg-page);
  color: var(--cm-text-default);
  font-family: var(--cm-font-sans);
  font-size: var(--cm-type-body-md-size);
  line-height: var(--cm-type-body-md-line-height);
}
a { color: var(--cm-text-information); }
.v4-boot { padding: var(--cm-space-32); color: var(--cm-text-secondary); }
.v4-muted { color: var(--cm-text-tertiary); }

.v4-skip { position: absolute; left: -9999px; top: 0; z-index: 100; padding: var(--cm-space-8); background: var(--cm-bg-surface); }
.v4-skip:focus { left: var(--cm-space-8); }

.v4-logo { display: inline-flex; align-items: center; min-width: 0; text-decoration: none; }
.v4-logo img { display: block; height: 18px; width: auto; max-width: 100%; }

.v4-main { min-width: 0; outline: none; }
.v4-bell-foot { display: flex; flex-direction: column; gap: 4px; }
.v4-bell-foot .v4-muted { font-size: var(--cm-type-body-sm-size); }


/* ---- My work and task rows (light DOM inside Commmerce UI rows/cards) ---- */
.v4-score { margin: 0; color: var(--cm-text-secondary); }
.v4-sub { margin: var(--cm-space-16) var(--cm-space-20) var(--cm-space-8); font-size: var(--cm-type-body-sm-size); font-weight: 600; color: var(--cm-text-secondary); }
.v4-card-foot { margin: 0; padding: var(--cm-space-8) var(--cm-space-20); font-size: var(--cm-type-body-sm-size); }
.v4-row { display: flex; flex-direction: column; min-width: 0; }
.v4-row-title { font-weight: 500; overflow-wrap: anywhere; }
.v4-row-sub { font-size: var(--cm-type-body-sm-size); color: var(--cm-text-tertiary); overflow-wrap: anywhere; }
.v4-late { color: var(--cm-text-critical); }
.v4-task { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.v4-task-title { margin: 0; font-size: var(--cm-type-body-md-size); font-weight: 600; }
.v4-task-title a { color: inherit; text-decoration: none; }
.v4-task-title a:hover, .v4-task-title a:focus-visible { text-decoration: underline; }
.v4-task-due { font-size: var(--cm-type-body-sm-size); color: var(--cm-text-secondary); }
.v4-task-due.is-late { color: var(--cm-text-critical); font-weight: 600; }
.v4-task-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px var(--cm-space-16); font-size: var(--cm-type-body-sm-size); color: var(--cm-text-tertiary); }
.v4-task-desc { margin: 0; font-size: var(--cm-type-body-sm-size); color: var(--cm-text-secondary); }

/* Dialog fields that Commmerce UI has no component for yet. */
.v4-field { display: flex; flex-direction: column; gap: 6px; }
.v4-field label { display: flex; flex-direction: column; gap: 6px; font-size: var(--cm-type-label-size); font-weight: var(--cm-type-label-weight); }
.v4-req { color: var(--cm-text-critical); }
.v4-lane-empty { margin: 0; padding: var(--cm-space-16) var(--cm-space-20) var(--cm-space-20); color: var(--cm-text-tertiary); }
.v4-lane-empty strong { color: var(--cm-text-default); font-weight: 500; }
.v4-row-title cm-icon { vertical-align: -3px; color: var(--cm-icon-default); }

/* ---- Records list ---- */
.v4-cols { display: grid; grid-template-columns: var(--cm-table-columns); gap: var(--cm-space-8); align-items: center; min-width: 0; }
.v4-cols > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v4-cell-name { font-weight: 500; }
.v4-narrow-only { display: none; }
@media (max-width: 640px) {
  .v4-wide-only { display: none !important; }
  /* Stacked list rows (mobile="stack"): no blank gaps for empty cells, and a long value stays inside the row. */
  cm-resource-item[columns] > .v4-cell:empty { display: none; }
  cm-resource-item[columns] > .v4-cell { max-width: 100%; }
  .v4-narrow-only { display: flex; }
}
.v4-checklist { display: flex; flex-direction: column; gap: var(--cm-space-12); max-height: 50vh; overflow: auto; }
.v4-list { margin: 0; padding-left: 1.2em; }
.v4-pre { white-space: pre-wrap; }
.v4-err { margin: 0; color: var(--cm-text-critical); font-size: var(--cm-type-body-sm-size); }
.v4-form { display: flex; flex-direction: column; gap: var(--cm-space-20); }
.v4-form-sec h3 { margin: 0 0 var(--cm-space-12); font-size: var(--cm-type-heading-sm-size); }
.v4-form .v4-wide { grid-column: 1 / -1; }
.v4-label { font-size: var(--cm-type-label-size); font-weight: var(--cm-type-label-weight); }

/* ---- Record page ---- */
.v4-fields { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--cm-space-16) var(--cm-space-32); }
.v4-fieldbox { min-width: 0; }
.v4-fieldbox.v4-wide { grid-column: 1 / -1; }
.v4-fieldbox dt { font-size: var(--cm-type-body-sm-size); color: var(--cm-text-tertiary); margin-bottom: 2px; }
.v4-fieldbox dd { margin: 0; display: flex; align-items: flex-start; gap: var(--cm-space-8); min-width: 0; }
.v4-fieldval { min-width: 0; overflow-wrap: anywhere; flex: 0 1 auto; }
.v4-fieldbox dd cm-button { opacity: .55; flex: none; }
.v4-fieldbox:hover dd cm-button, .v4-fieldbox dd cm-button:focus-within { opacity: 1; }
.v4-tl-list { list-style: none; margin: 0; padding: 0; }
.v4-tl { display: flex; gap: var(--cm-space-12); padding: var(--cm-space-16) var(--cm-space-20); border-top: var(--cm-border-1) solid var(--cm-border-subtle); }
.v4-tl:first-child { border-top: 0; }
.v4-tl > cm-icon { flex: none; margin-top: 2px; color: var(--cm-icon-default); }
.v4-tl-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.v4-tl-head { display: flex; justify-content: space-between; gap: var(--cm-space-8); flex-wrap: wrap; }
.v4-tl-text { margin: 0; color: var(--cm-text-secondary); overflow-wrap: anywhere; }
.v4-old { color: var(--cm-text-tertiary); text-decoration: line-through; }
.v4-note-form { padding: var(--cm-space-16) var(--cm-space-20) var(--cm-space-20); border-bottom: var(--cm-border-1) solid var(--cm-border-subtle); }
.v4-iframe { width: 100%; height: 60vh; border: var(--cm-border-1) solid var(--cm-border-default); border-radius: var(--cm-radius-sm); background: #fff; }
cm-layout-section > cm-status-tabs { margin-bottom: var(--cm-space-20); display: block; }
/* Timeline kind filter (All / Notes / Calls...): space before the first row. */
cm-status-tabs[data-role="kind"] { display: block; margin-bottom: var(--cm-space-16); }

/* ---- Desk ticket conversation ---- */
.v4-tk-thread { list-style: none; margin: 0; padding: var(--cm-space-16) var(--cm-space-20) var(--cm-space-20); display: flex; flex-direction: column; gap: var(--cm-space-12); }
.v4-tk-msg { display: flex; flex-direction: column; gap: 6px; padding: var(--cm-space-12) var(--cm-space-16); border-radius: var(--cm-radius-md); border: var(--cm-border-1) solid var(--cm-border-subtle); max-width: 88%; }
.v4-tk-in { background: var(--cm-bg-surface); align-self: flex-start; }
.v4-tk-out { background: var(--cm-bg-information-soft); align-self: flex-end; }
.v4-tk-note { background: var(--cm-bg-attention-soft); align-self: stretch; max-width: none; }
.v4-tk-event { align-self: center; font-size: var(--cm-type-body-sm-size); color: var(--cm-text-tertiary); text-align: center; }
.v4-tk-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.v4-tk-frame { width: 100%; min-height: 120px; border: 0; background: #fff; }
.v4-clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.v4-fields-1 { grid-template-columns: 1fr; margin-bottom: var(--cm-space-16); }
@media (max-width: 640px) { .v4-tk-msg { max-width: none; } .v4-tk-side { flex-wrap: wrap; } }

/* ---- Mail and Chat ---- */
.v4-unread { font-weight: 700; }
.v4-chat { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 420px; padding: 0; box-sizing: border-box; gap: 0; }
.v4-chat[hidden] { display: none; }
.v4-chat-frame-wrap { flex: 1; min-height: 0; margin: var(--cm-space-16) var(--cm-space-24) var(--cm-space-24); display: grid; place-items: center; border: var(--cm-border-1) solid var(--cm-border-card); border-radius: var(--cm-radius-md); background: var(--cm-bg-surface); overflow: hidden; }
.v4-chat-frame { width: 100%; height: 100%; border: 0; }
body.v4-chat-mode #main { display: none; }
@media (max-width: 1023px) { .v4-chat { height: calc(100vh - 150px); } .v4-chat-frame-wrap { margin: var(--cm-space-8); } }

/* ---- Reports ---- */
.v4-bars { display: flex; flex-direction: column; gap: var(--cm-space-8); }
.v4-bar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 48px; align-items: center; gap: var(--cm-space-8); }
.v4-bar-label { font-size: var(--cm-type-body-sm-size); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v4-bar-n { text-align: end; font-variant-numeric: tabular-nums; font-size: var(--cm-type-body-sm-size); }
.v4-botline { margin-bottom: var(--cm-space-16); }

/* ---- Settings ---- */
.v4-fieldset { border: 0; margin: 0; padding: 0; }
.v4-fieldset legend { padding: 0; margin-bottom: var(--cm-space-8); font-size: var(--cm-type-label-size); font-weight: var(--cm-type-label-weight); }
.v4-pad { padding: var(--cm-space-16) var(--cm-space-20); }

/* ---- Brands and Demos ---- */
.v4-spec-meta { color: var(--cm-text-secondary); font-size: var(--cm-type-body-sm-size); }
.v4-spec-meta > span { min-width: 0; overflow-wrap: anywhere; }

/* ---- Visits and Outreach planner ---- */
/* Visits, Outreach planner and Cold email (crm-v6/modules/visits.js,
   plan.js, outreach.js). Light DOM only, Commmerce UI tokens only.
   Merge into crm-v6/styles.css. */

.v4-pad { padding: 0 var(--cm-space-20) var(--cm-space-16); }
.v4-mt { margin-top: var(--cm-space-20); display: flex; }

/* Planner rows */
.v4-plan-time { min-width: 64px; font-size: var(--cm-type-body-sm-size); color: var(--cm-text-tertiary); font-variant-numeric: tabular-nums; }
.v4-plan-row.is-done { opacity: .6; }
[data-drop].is-drop { outline: 2px dashed var(--cm-border-strong); outline-offset: -2px; }

/* Cold email */
.v4-quote { margin: 0; padding: var(--cm-space-8) var(--cm-space-16); border-inline-start: 3px solid var(--cm-border-strong); background: var(--cm-bg-inset); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .v4-plan-time { min-width: 0; }
}

/* ---- Renewals, At risk, Duplicates, Feedback, Activity log ---- */
/* Styles for platform.js, accounts.js, merge.js, feedback.js and activity.js
   (light DOM only, Commmerce UI tokens only). Merge into crm-v6/styles.css. */

.ac-grow { flex: 1 1 260px; min-width: 0; }
.ac-nowrap { white-space: nowrap; }
.ac-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.ac-list { margin: 0; padding-left: 1.1em; }
.ac-pick { display: inline-flex; align-items: flex-start; gap: 6px; cursor: pointer; }
.ac-pick input { margin-top: 3px; accent-color: var(--cm-action-primary); }
td.ac-on { background: var(--cm-bg-information-soft); }
.ac-text { margin: 0; overflow-wrap: anywhere; }
.ac-pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--cm-type-body-sm-size); }
.ac-files { display: flex; flex-wrap: wrap; gap: var(--cm-space-8); }
.ac-thumb { padding: 0; border: var(--cm-border-1) solid var(--cm-border-default); border-radius: var(--cm-radius-sm); background: var(--cm-bg-inset); cursor: zoom-in; overflow: hidden; width: 96px; height: 72px; }
.ac-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ac-thumb:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
.ac-media { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; }
.v4-sr { display: inline-block; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; vertical-align: top; }
.ac-reasons { padding: 0 var(--cm-space-20) var(--cm-space-16); }
@media (min-width: 641px) { cm-data-table.ac-wide table { min-width: 960px; } }
cm-data-table.ac-wide td, cm-data-table.ac-wide th { padding-inline: var(--cm-space-8); }

/* ---- Cadences and Customize ---- */
/* Cadences and Customize (crm-v6/modules/cadences.js, customize.js). Light
   DOM only, Commmerce UI tokens only. Merge into crm-v6/styles.css. */
.v4-cad.is-off { opacity: .7; }
.v4-cad-steps { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 4px; }
.v4-cad-row { padding-top: var(--cm-space-16); border-top: var(--cm-border-1) solid var(--cm-border-subtle); }
.v4-cad-row:first-child { padding-top: 0; border-top: 0; }
.v4-sub0 { margin: 0; font-size: var(--cm-type-body-md-size); font-weight: 600; }
.v4-cad-after { margin: 0; align-self: end; padding-bottom: 12px; }
.v4-wrap { white-space: normal; overflow-wrap: anywhere; }
cm-nested-list[data-sid] { display: block; margin-bottom: var(--cm-space-20); }
.v4-pk-list { list-style: none; margin: 0 0 var(--cm-space-12); padding: 0; display: flex; flex-direction: column; gap: var(--cm-space-8); }
.v4-pk-row { display: flex; flex-direction: column; gap: var(--cm-space-8); padding-bottom: var(--cm-space-12); border-bottom: var(--cm-border-1) solid var(--cm-border-subtle); }
.v4-pk-line { display: flex; align-items: center; gap: var(--cm-space-8); }
.v4-pk-line .v4-pk-label { flex: 1; min-width: 0; }
@media (max-width: 640px) { .v4-cad-after { padding-bottom: 0; } }

/* ---- Record side cards and the Bot dashboard ---- */
/* Record page account panels (account-panel.js, sso-panel.js) and the Bot
   dashboard (bot.js). Light DOM only, Commmerce UI tokens only.
   Merge into crm-v6/styles.css. */
.v4-pn-acct { display: flex; flex-direction: column; gap: var(--cm-space-8); min-width: 0; }
.v4-pn-acct p { margin: 0; overflow-wrap: anywhere; }
.v4-pn-acct + .v4-pn-acct { border-top: var(--cm-border-1) solid var(--cm-border-subtle); padding-top: var(--cm-space-16); }
.v4-pn-store { display: flex; flex-direction: column; gap: var(--cm-space-8); padding: var(--cm-space-12); border: var(--cm-border-1) solid var(--cm-border-subtle); border-radius: var(--cm-radius-md); min-width: 0; }
.v4-pn-store p { margin: 0; overflow-wrap: anywhere; }
.v4-pn-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--cm-space-8); }
.v4-pn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.v4-pn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--cm-space-8); font-size: var(--cm-type-body-sm-size); min-width: 0; }
.v4-pn-row > * { min-width: 0; overflow-wrap: anywhere; }
.v4-bot-actions cm-select { min-width: 150px; }
@media (max-width: 640px) { .v4-bot-actions { flex-wrap: wrap; } }

/* ---- Field app ---- */
/* ---- Field app (crm-v6/modules/field/) ----
   Light DOM only, Commmerce UI tokens only. Phones: the field app's own tab
   bar (cm-bottom-navigation.fd-tabbar) replaces the CRM's bottom bar, which
   is hidden while body.v4-field-mode is set (index.js adds it, leaveField()
   removes it). Wide screens: field tabs are cm-link-tabs above the screen. */

/* Hide the CRM frame's bottom bar host (#v4-bottom) on phones in field mode:
   the field app's own tab bar takes its place. */
@media (max-width: 1023px) {
  body.v4-field-mode #v4-bottom { display: none !important; }
  /* Room for the field tab bar (fixed, about 70px plus the home indicator):
     the frame pads main by --cm-app-frame-bottom-offset (1.4.0, #26/#20 release). */
  body.v4-field-mode #v4-frame { --cm-app-frame-bottom-offset: calc(76px + env(safe-area-inset-bottom, 0px)); }
  body.v4-field-mode .fd-submit-bar { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .fd-tabs-wide { display: none !important; }
}
@media (min-width: 1024px) {
  .fd-tabbar { display: none !important; }
}
.fd-tabbar { z-index: 30; }

.fd { display: flex; flex-direction: column; gap: var(--cm-space-12); }
.fd-body { padding-bottom: var(--cm-space-20); min-width: 0; }
.fd-banners { display: flex; flex-direction: column; gap: var(--cm-space-8); }
.fd-banners:empty { display: none; }
.fd [hidden], .fd-gallery[hidden] { display: none !important; }
.fd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }
.fd-muted { color: var(--cm-text-tertiary); font-size: var(--cm-type-body-sm-size); }
.fd-pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--cm-type-body-sm-size); }
.fd-tone-red { color: var(--cm-text-critical); }
.fd-tone-amber { color: var(--cm-text-attention); }
.fd-ic { flex: none; vertical-align: -3px; }
.fd-greet { margin: 0 0 var(--cm-space-8); font-weight: 600; font-size: var(--cm-type-body-lg-size); }
.fd-loading { display: flex; align-items: center; gap: var(--cm-space-8); color: var(--cm-text-secondary); margin: var(--cm-space-16) 0; }
.fd-stale { display: flex; align-items: center; gap: 6px; color: var(--cm-text-attention); font-size: var(--cm-type-body-sm-size); margin: 0 0 var(--cm-space-8); }
.fd-block { display: block; width: 100%; margin: 0 0 var(--cm-space-8); }

.fd-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--cm-space-8); margin-bottom: var(--cm-space-16); }

.fd-section { margin: 0 0 var(--cm-space-20); min-width: 0; }
.fd-section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--cm-space-8); margin-bottom: var(--cm-space-8); flex-wrap: wrap; }
.fd-section-head h2 { margin: 0; font-size: var(--cm-type-body-md-size); font-weight: 700; display: flex; align-items: center; gap: var(--cm-space-8); }
.fd-count-line { color: var(--cm-text-tertiary); font-size: var(--cm-type-body-sm-size); margin: 0 0 var(--cm-space-8); }
.fd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--cm-space-8); }
.fd-card { background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-card); border-radius: var(--cm-radius-md); overflow: hidden; min-width: 0; }
.fd-card-done { opacity: .7; }
.fd-card-main { display: flex; flex-direction: column; gap: 3px; padding: var(--cm-space-12) var(--cm-space-16); color: var(--cm-text-default); text-decoration: none; min-height: 44px; }
.fd-card-main:hover { background: var(--cm-bg-hover); }
.fd-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--cm-space-8); }
.fd-card-title { font-weight: 700; overflow-wrap: anywhere; }
.fd-card-sub { color: var(--cm-text-tertiary); font-size: var(--cm-type-body-sm-size); overflow-wrap: anywhere; margin: 0; }
.fd-dist { flex: none; font-weight: 700; font-size: var(--cm-type-body-sm-size); padding: 2px 8px; border-radius: var(--cm-radius-full); background: var(--cm-bg-information-soft); color: var(--cm-text-information); }
.fd-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.fd-note { font-size: var(--cm-type-body-sm-size); color: var(--cm-text-secondary); background: var(--cm-bg-inset); border-radius: var(--cm-radius-sm); padding: 6px 8px; margin-top: 4px; overflow-wrap: anywhere; }
.fd-actions { display: flex; gap: var(--cm-space-8); padding: 0 var(--cm-space-16) var(--cm-space-12); flex-wrap: wrap; }
.fd-fu-overdue { border-left: 4px solid var(--cm-icon-critical); }
.fd-fu-today { border-left: 4px solid var(--cm-border-strong); }
.fd-row { display: flex; align-items: center; gap: var(--cm-space-8); padding: var(--cm-space-8) var(--cm-space-12); background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-card); border-radius: var(--cm-radius-md); min-height: 52px; min-width: 0; }
.fd-row-wrap { flex-wrap: wrap; }
.fd-row-late { border-left: 4px solid var(--cm-icon-critical); }
.fd-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: var(--cm-text-default); text-decoration: none; overflow-wrap: anywhere; }
.fd-more { display: inline-block; margin-top: var(--cm-space-8); min-height: 44px; line-height: 44px; color: var(--cm-text-information); }
.fd-grid-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--cm-space-8); margin-top: var(--cm-space-8); }
.fd-grid-actions cm-button { display: block; }
.fd-hint { margin: var(--cm-space-8) 0 var(--cm-space-20); }

.fd-store-head { background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-card); border-radius: var(--cm-radius-md); padding: var(--cm-space-16); margin-bottom: var(--cm-space-12); }
.fd-store-head-sm { padding: var(--cm-space-12) var(--cm-space-16); }
.fd-store-name { margin: 0; font-size: var(--cm-type-heading-sm-size); font-weight: 700; overflow-wrap: anywhere; }
.fd-gps { display: flex; align-items: center; gap: 6px; margin: var(--cm-space-8) 0 0; padding: 8px 10px; border-radius: var(--cm-radius-sm); font-size: var(--cm-type-body-sm-size); font-weight: 500; flex-wrap: wrap; }
.fd-gps-ok { background: var(--cm-bg-success-soft); color: var(--cm-text-success); }
.fd-gps-warn { background: var(--cm-bg-attention-soft); color: var(--cm-text-attention); }
.fd-gps-wait { background: var(--cm-bg-information-soft); color: var(--cm-text-information); }

/* Photos: galleries of saved photos, and capture tiles (cm-file-upload variant="photo"). */
.fd-gallery { display: flex; gap: var(--cm-space-8); overflow-x: auto; padding: 2px 0 var(--cm-space-8); }
.fd-thumb { flex: none; padding: 0; border: var(--cm-border-1) solid var(--cm-border-card); border-radius: var(--cm-radius-sm); background: var(--cm-bg-inset); cursor: zoom-in; width: 120px; height: 90px; overflow: hidden; }
.fd-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fd-thumb-missing { font-size: var(--cm-type-body-xs-size); color: var(--cm-text-tertiary); padding: 8px; }
.fd-zoom { display: block; width: 100%; height: auto; max-height: 75vh; object-fit: contain; }
.fd-photo-row { display: flex; gap: var(--cm-space-8); flex-wrap: wrap; margin-bottom: var(--cm-space-8); }
.fd-photo-tile { flex: 1 1 140px; min-width: 0; }
.fd-photo-big, .fd-photo-wide { flex-basis: 100%; }
.fd-photo-tile[data-photo-input^="card"]::part(photo) { aspect-ratio: 16 / 10; }

.fd-form { margin: 0; }
.fd-label { margin: 0 0 6px; font-size: var(--cm-type-label-size); font-weight: var(--cm-type-label-weight); }
.fd-fieldset { border: var(--cm-border-1) solid var(--cm-border-card); border-radius: var(--cm-radius-md); margin: 0; padding: var(--cm-space-12); background: var(--cm-bg-surface); min-width: 0; }
.fd-fieldset legend { padding: 0 4px; font-weight: 700; }
.fd-outcomes { display: flex; flex-direction: column; gap: 6px; }
.fd-submit-bar { position: sticky; bottom: 0; z-index: 5; background: var(--cm-bg-page); padding: var(--cm-space-12) 0 4px; }
.fd-picked { margin: 0; color: var(--cm-text-success); }

.fd-done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--cm-space-8); padding: var(--cm-space-20) 0; }
.fd-done p { margin: 6px 0 0; }
.fd-done-actions { display: flex; flex-direction: column; gap: var(--cm-space-8); width: 100%; max-width: 360px; margin-top: var(--cm-space-16); }

.fd-profile { display: flex; align-items: center; gap: var(--cm-space-12); padding: var(--cm-space-16); background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-card); border-radius: var(--cm-radius-md); margin-bottom: var(--cm-space-20); }
.fd-profile > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.fd-kv { list-style: none; margin: 0; padding: 0; background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-card); border-radius: var(--cm-radius-md); }
.fd-kv li { display: flex; align-items: center; gap: var(--cm-space-8); padding: var(--cm-space-8) var(--cm-space-12); border-bottom: var(--cm-border-1) solid var(--cm-border-subtle); min-height: 44px; }
.fd-kv li:last-child { border-bottom: 0; }
.fd-kv li > span:not(.fd-rank) { flex: 1; min-width: 0; }
.fd-kv li.fd-me { background: var(--cm-bg-information-soft); }
.fd-rank { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--cm-bg-inset); font-size: var(--cm-type-body-xs-size); font-weight: 700; flex: none; }
.fd-big-n { font-size: 22px; font-weight: 700; }

@media (max-width: 360px) {
  .fd-metrics, .fd-grid-actions { grid-template-columns: minmax(0, 1fr); }
}

/* ---- E-sign ---- */
/* E-sign (crm-v6/modules/sign/). Light DOM only, Commmerce UI tokens only.
   Merge into crm-v6/styles.css.
   The document viewer and field editor are the CRM's own (owner decision, commmerce-ui#25).
   The signature is cm-signature-field (1.4.0). */

.v4-grow { flex: 1 1 260px; min-width: 0; }

/* Signer colours (six, from the tone tokens). */
.v4-sg-t0 { --tfg: var(--cm-text-information); --tbg: var(--cm-bg-information-soft); }
.v4-sg-t1 { --tfg: var(--cm-text-success); --tbg: var(--cm-bg-success-soft); }
.v4-sg-t2 { --tfg: var(--cm-text-attention); --tbg: var(--cm-bg-attention-soft); }
.v4-sg-t3 { --tfg: var(--cm-text-critical); --tbg: var(--cm-bg-critical); }
.v4-sg-t4 { --tfg: var(--cm-text-speciality); --tbg: var(--cm-bg-tag); }
.v4-sg-t5 { --tfg: var(--cm-text-default); --tbg: var(--cm-bg-inset); }

/* Template editor: thumbnails | pages | side panel. */
.v4-sg-ed { display: grid; grid-template-columns: 112px minmax(0, 1fr) 340px; height: calc(100vh - 210px); min-height: 480px; border-top: var(--cm-border-1) solid var(--cm-border-subtle); }
.v4-sg-thumbs { overflow-y: auto; padding: var(--cm-space-8); border-inline-end: var(--cm-border-1) solid var(--cm-border-subtle); background: var(--cm-bg-inset); display: flex; flex-direction: column; gap: var(--cm-space-8); align-items: center; }
.v4-sg-thumb { border: var(--cm-border-1) solid var(--cm-border-default); background: var(--cm-bg-surface); padding: 0; cursor: pointer; position: relative; border-radius: var(--cm-radius-xs); width: 90px; }
.v4-sg-thumb canvas { display: block; width: 90px; height: auto; border-radius: var(--cm-radius-xs); }
.v4-sg-thumb span { position: absolute; inset-inline-end: 4px; bottom: 4px; background: var(--cm-bg-dashboard); color: var(--cm-text-on-dark); font-size: 11px; border-radius: var(--cm-radius-xs); padding: 0 5px; }
.v4-sg-thumb:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
.v4-sg-scroll { overflow-y: auto; padding: var(--cm-space-16) var(--cm-space-20) var(--cm-space-32); background: var(--cm-bg-inset); }
.v4-sg-pagewrap { max-width: 860px; margin: 0 auto var(--cm-space-20); display: flex; flex-direction: column; gap: 4px; }
.v4-sg-page { position: relative; background: var(--cm-bg-surface); box-shadow: var(--cm-shadow-100); width: 100%; }
.v4-sg-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.v4-sg-layer { position: absolute; inset: 0; }
.v4-sg-side { overflow-y: auto; border-inline-start: var(--cm-border-1) solid var(--cm-border-subtle); background: var(--cm-bg-surface); padding: var(--cm-space-16) var(--cm-space-16) var(--cm-space-32); }
.v4-sg-sec { display: flex; flex-direction: column; gap: var(--cm-space-8); border-top: var(--cm-border-1) solid var(--cm-border-subtle); padding-top: var(--cm-space-16); }
.v4-sg-sec h2 { margin: 0; font-size: var(--cm-type-body-md-size); font-weight: 700; }
.v4-sg-palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.v4-sg-pal { font: inherit; font-size: var(--cm-type-body-sm-size); text-align: start; cursor: grab; padding: 7px 8px; color: var(--cm-text-default); background: var(--cm-bg-inset); border: var(--cm-border-1) dashed var(--cm-border-strong); border-radius: var(--cm-radius-sm); }
.v4-sg-pal:hover { background: var(--cm-bg-hover); }
.v4-sg-pal:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 1px; }
.v4-sg-role { display: flex; flex-direction: column; gap: 6px; padding-bottom: var(--cm-space-8); }
.v4-sg-role cm-text-field { flex: 1; min-width: 110px; }
.v4-sg-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--tfg); }

/* A field on the page: tinted by its signer, dashed when it is a repeated copy. */
.v4-sg-f { position: absolute; display: flex; align-items: center; overflow: hidden; user-select: none; touch-action: none; cursor: move; border: 2px solid var(--tfg); background: color-mix(in srgb, var(--tbg) 80%, transparent); border-radius: var(--cm-radius-xs); }
.v4-sg-f.copy { border-style: dashed; background: color-mix(in srgb, var(--tbg) 45%, transparent); }
.v4-sg-f.sel { box-shadow: 0 0 0 2px var(--cm-bg-surface), 0 0 0 4px var(--tfg); z-index: 2; }
.v4-sg-f:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--cm-bg-surface), 0 0 0 4px var(--cm-border-strong); }
.v4-sg-ft { font-size: 11px; line-height: 1.1; font-weight: 600; color: var(--tfg); padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.v4-sg-ft i { font-weight: 400; }
.v4-sg-rs { position: absolute; inset-inline-end: 0; bottom: 0; width: 10px; height: 10px; background: var(--tfg); cursor: nwse-resize; border-start-start-radius: 3px; }
.v4-sg-skip { position: absolute; inset-inline-end: 1px; top: 1px; width: 18px; height: 18px; padding: 0; border: 0; border-radius: var(--cm-radius-xs); background: var(--cm-bg-surface); color: var(--cm-text-default); font: inherit; line-height: 18px; cursor: pointer; }

@media (max-width: 1000px) { .v4-sg-ed { grid-template-columns: minmax(0, 1fr) 300px; } .v4-sg-thumbs { display: none; } }
@media (max-width: 700px) {
  .v4-sg-ed { grid-template-columns: 1fr; height: auto; }
  .v4-sg-scroll { padding: var(--cm-space-8); max-height: 70vh; }
  .v4-sg-side { border-inline-start: 0; border-top: var(--cm-border-1) solid var(--cm-border-subtle); }
}

/* Send dialog */
.v4-sg-h { margin: var(--cm-space-8) 0 0; font-size: var(--cm-type-body-md-size); font-weight: 700; }
.v4-sg-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px var(--cm-space-16); margin: 0; }
.v4-sg-dl dt { color: var(--cm-text-secondary); font-size: var(--cm-type-body-sm-size); }
.v4-sg-dl dd { margin: 0; overflow-wrap: anywhere; }
.v4-sg-actions { border-top: var(--cm-border-1) solid var(--cm-border-subtle); padding-top: var(--cm-space-16); }
.v4-sg-val { display: flex; flex-direction: column; gap: 6px; }
.v4-sg-who { border: var(--cm-border-1) solid var(--cm-border-subtle); border-radius: var(--cm-radius-md); padding: var(--cm-space-8) var(--cm-space-16) var(--cm-space-16); margin: 0; min-width: 0; }
.v4-sg-who legend { font-weight: 600; padding: 0 4px; }
.v4-sg-pick { cursor: pointer; }

/* Page previews and the PDF viewer */
.v4-sg-pv { background: var(--cm-bg-inset); padding: var(--cm-space-8); border-radius: var(--cm-radius-md); max-height: 70vh; overflow-y: auto; }
.v4-sg-pv-n { text-align: center; margin: 4px 0 var(--cm-space-12); }
.v4-sg-pv-val { position: absolute; display: flex; align-items: center; overflow: hidden; white-space: nowrap; font: 600 clamp(7px, 1.6vw, 12px)/1.1 var(--cm-font-sans); color: var(--cm-text-information); background: color-mix(in srgb, var(--cm-bg-information-soft) 55%, transparent); }
.v4-sg-pv-box { cursor: default; }
.v4-sg-target { cursor: crosshair; }
.v4-sg-pv-c { display: block; width: 100%; margin-bottom: var(--cm-space-8); box-shadow: var(--cm-shadow-100); background: var(--cm-bg-surface); }
.v4-sg-sender { flex: 0 1 240px; min-width: 180px; }
.v4-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Boards (cm-board) ---- */
.v4-board { display: block; height: calc(100vh - 330px); min-height: 420px; }
@media (max-width: 640px) { .v4-board { height: calc(100vh - 260px); } }

/* ---- Density pass (owner review, 16 Nov 2026) ---- */
/* Inline empty messages inside edge-to-edge cards get the card's padding. */
cm-card[flush] cm-empty-state[size="inline"] { display: block; padding: var(--cm-space-16) var(--cm-space-20) var(--cm-space-20); }
/* Long task descriptions: two lines, the rest on hover. */
.v4-task-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Filter rows: fields at a sensible width, search takes the rest. */
.v4-filters { display: flex; flex-wrap: wrap; gap: var(--cm-space-12); align-items: center; }
.v4-filters > cm-select, .v4-filters > cm-combobox { flex: 0 1 220px; min-width: 160px; }
.v4-filters > cm-search { flex: 1 1 280px; }
.v4-narrow-select { width: 220px; max-width: 100%; }
/* Renewals / returning tables: a person cell keeps each detail on one line. */
td.ac-person { min-width: 190px; max-width: 240px; }
td.ac-person .v4-row-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.v4-task-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-8) var(--cm-space-20); margin-block-start: var(--cm-space-4); }
.v4-btn-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-8); }
[hidden] { display: none !important; }
.v4-title-note { font-size: var(--cm-font-size-14); font-weight: 400; color: var(--cm-text-secondary); }
.v4-settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: var(--cm-space-16); align-items: start; }

/* ---- Owner's brief, 17 Nov 2026 ---- */
/* Desk: side panels on wide screens, one View picker below 1024px. */
.v4-dk-pick { display: none; }
@media (max-width: 1023px) {
  .v4-dk-views { display: none; }
  .v4-dk-pick { display: block; }
  .v4-dk-pick cm-select { width: 100%; }
}
.v4-dk-snip { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.v4-dk-tpl { width: 240px; max-width: 100%; }
/* Conversation uses the card's full width; who wrote it is in the header line and colour. */
.v4-tk-msg { max-width: none; }
.v4-tk-in, .v4-tk-out { align-self: stretch; }
/* Chat: the standard page header above the frame. */
.v4-chat-head { display: block; }
.v4-chat-unread { font-size: var(--cm-font-size-14); font-weight: 400; color: var(--cm-text-secondary); }
/* Mail pager under the list. */
.v4-mail-pager { margin-top: var(--cm-space-8); }
/* A title that is a link, without link colour. */
.v4-plain-link { color: inherit; text-decoration: none; }
.v4-plain-link:hover, .v4-plain-link:focus-visible { text-decoration: underline; }
.v4-stat-strip { display: flex; flex-wrap: wrap; gap: var(--cm-space-4) var(--cm-space-8); margin: 0; font-size: var(--cm-font-size-14); color: var(--cm-text-secondary); font-variant-numeric: tabular-nums; }
.v4-stat-strip strong { color: var(--cm-text-default); font-weight: 600; }
/* A quiet inline expander (Activity log details), not a bordered box. */
.v4-inline-details > summary { cursor: pointer; width: fit-content; font-size: var(--cm-font-size-13); color: var(--cm-text-link, var(--cm-text-secondary)); list-style: none; }
.v4-inline-details > summary::-webkit-details-marker { display: none; }
.v4-inline-details > summary::before { content: '▸ '; }
.v4-inline-details[open] > summary::before { content: '▾ '; }
.v4-inline-details > summary:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; border-radius: var(--cm-radius-xs); }
.v4-inline-details > pre { margin: var(--cm-space-8) 0 0; }
/* Agreement details: labels read like every other record page (13px, not tiny grey). */
.v4-sg-dl { gap: var(--cm-space-8) var(--cm-space-16); }
.v4-sg-dl dt { font-size: var(--cm-font-size-13); font-weight: 500; color: var(--cm-text-secondary); }
/* Template editor palette: look like things you can pick up, with drag and pressed states. */
.v4-sg-pal { border-style: solid; border-color: var(--cm-border-default); background: var(--cm-bg-surface); box-shadow: 0 1px 0 var(--cm-border-subtle); display: flex; align-items: center; gap: 6px; }
.v4-sg-pal::before { content: '⠿'; color: var(--cm-text-tertiary); font-size: 12px; line-height: 1; }
.v4-sg-pal:hover { border-color: var(--cm-border-strong); background: var(--cm-bg-hover); }
.v4-sg-pal:active { cursor: grabbing; transform: translateY(1px); box-shadow: none; }
/* Record page: "On this record" as a compact jump list. */
.v4-jumplist { display: flex; flex-direction: column; padding: var(--cm-space-4) var(--cm-space-8) var(--cm-space-12); }
.v4-jumplist a { display: flex; align-items: center; justify-content: space-between; gap: var(--cm-space-8); min-height: 32px; padding: 0 var(--cm-space-8); border-radius: var(--cm-radius-sm); color: var(--cm-text-default); text-decoration: none; font-size: var(--cm-font-size-14); }
.v4-jumplist a:hover { background: var(--cm-bg-hover); }
.v4-jumplist a:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: -2px; }
.v4-jumplist a.is-empty { color: var(--cm-text-tertiary); }
.v4-jump-n { font-size: var(--cm-font-size-12); color: var(--cm-text-secondary); font-variant-numeric: tabular-nums; }

/* At risk: one line per churn signal (data-lines="1"), wider than the 320px
   default on desktop (phone cards cap it themselves since Commmerce UI 1.7.2). */
cm-data-table.v4-churn-table { --cm-data-table-cell-max-width: 420px; }

/* Cards without flush already have the card's own padding: these helpers
   only pad themselves inside flush cards (a table or resource list edge to edge). */
cm-card:not([flush]) .v4-sub { margin-inline: 0; }
cm-card:not([flush]) .v4-sub:first-child { margin-top: 0; }
cm-card:not([flush]) .v4-card-foot { padding-inline: 0; }
cm-card:not([flush]) .v4-note-form { padding: 0 0 var(--cm-space-20); margin-bottom: var(--cm-space-16); }
cm-card:not([flush]) .v4-tk-thread { padding: 0; }

/* Desk ticket rows: status and owner pickers at fixed widths so row ends line up. */
.v4-tk-side { align-items: center; gap: var(--cm-space-8); }
@media (min-width: 641px) { .v4-tk-side { flex-wrap: nowrap; } }
.v4-tk-side .v4-tk-status { inline-size: 120px; }
.v4-tk-side .v4-tk-owner { inline-size: 160px; }
[data-role="web-sum"]:empty { display: none; }

/* Record page: an empty related list (detail.js listCard) is one title line, evenly padded. */
.v4-empty-head { margin: 0; display: flex; align-items: center; gap: var(--cm-space-8); font-size: var(--cm-type-heading-sm-size); line-height: var(--cm-type-heading-sm-line-height); font-weight: 600; }

/* Account activity (sso-panel.js): structured rows that fit the narrow record column. */
.v4-pn-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.v4-pn-who .v4-muted { font-size: var(--cm-type-body-sm-size); }
.v4-pn-prods, .v4-pn-sites { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--cm-space-8); }
.v4-pn-prods li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--cm-space-8); min-width: 0; }
.v4-pn-prod { font-weight: 500; }
.v4-pn-prods .v4-muted, .v4-pn-sites .v4-muted { font-size: var(--cm-type-body-sm-size); }
.v4-pn-sites li { min-width: 0; overflow-wrap: anywhere; }
.v4-pn-kv { margin: 0; display: flex; flex-direction: column; gap: var(--cm-space-8); }
.v4-pn-kv > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--cm-space-8); }
.v4-pn-kv dt { color: var(--cm-text-tertiary); font-size: var(--cm-type-body-sm-size); }
.v4-pn-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Record page: a field being edited in place keeps its cell; the input carries the label. */
cm-info-item[data-editing]::part(label) { display: none; }
cm-info-item[data-editing]::part(value) { display: block; margin-top: 0; }
.v4-inline-edit { width: 100%; }

/* Loading indicator (lib/ui.js spinner()): cm-spinner with the MMM loader slotted in. Timing and reduced motion come from
   Commmerce UI (--cm-spinner-duration, --cm-spinner-play-state); these heights override the library's 12/20px. */
cm-spinner.v4-spin { color: inherit; vertical-align: middle; flex: none; }
.v4-mmm-g { width: auto; }
.v4-mmm-g.v4-spin-sm { height: 9px; }
.v4-mmm-g.v4-spin-md { height: 14px; }
.v4-mmm-g polygon { fill: currentColor; animation: v4-spin var(--cm-spinner-duration, .8s) ease-in-out infinite; animation-play-state: var(--cm-spinner-play-state, running); }
.v4-mmm-g polygon:nth-child(2) { animation-delay: calc(var(--cm-spinner-duration, .8s) / 6); }
.v4-mmm-g polygon:nth-child(3) { animation-delay: calc(var(--cm-spinner-duration, .8s) / 3); }
@keyframes v4-spin { 0%, 60%, 100% { opacity: 1; } 30% { opacity: .3; } }
.v4-spin-block { display: flex; justify-content: center; align-items: center; padding: var(--cm-space-24) 0; color: var(--cm-text-secondary); }
