/* CRM /v6 (default since 20 Nov 2026; was /v5 from 18 Nov): the CRM on Commmerce UI in its refined look.
   index.html sets data-cm-look="refined" and loads this sheet after styles.css.
   Only light-DOM CRM elements here; components change through Commmerce UI tokens. */

/* Board: an empty stage is a full column you can drop a card into or add one to. */
.v5-drop {
  display: grid; justify-items: center; gap: var(--cm-space-8); text-align: center;
  padding: var(--cm-space-20) var(--cm-space-12); margin: var(--cm-space-4) 0;
  border: 1.5px dashed var(--cm-border-input); border-radius: var(--cm-radius-md);
  color: var(--cm-text-tertiary); font-size: var(--cm-font-size-13); line-height: var(--cm-line-height-13);
}

/* Desk rows: status badge and owner instead of the two pickers. */
.v5-tk-side { flex-wrap: nowrap; }
.v5-owner {
  display: inline-flex; align-items: center; gap: var(--cm-space-8); min-inline-size: 120px;
  font-size: var(--cm-font-size-13); color: var(--cm-text-tertiary); white-space: nowrap;
}
@media (max-width: 640px) { .v5-owner { min-inline-size: 0; } .v5-tk-side { flex-wrap: wrap; } }

/* Desk rows on phones: status and owner sit in the row's detail line, not on a line of their own. */
.v5-narrow { display: none; }
@media (max-width: 640px) {
  .v5-tk-side { display: none; }
  .v5-narrow { display: inline-flex; align-items: center; gap: var(--cm-space-8); }
}

/* Phones: long grey intro paragraphs show two lines; "Show more" opens the rest (lib/ui.js startV5Phone). */
@media (max-width: 640px) {
  p.v5-clamp:not(.v5-open) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  p.v5-clamp { margin-bottom: 0; }
  .v5-more {
    align-self: flex-start; margin: calc(-1 * var(--cm-space-8)) 0 0; padding: var(--cm-space-4) 0; border: 0; background: none;
    font: inherit; font-size: var(--cm-font-size-13); font-weight: 500; color: var(--cm-text-default); text-decoration: underline; cursor: pointer;
  }
}
@media (min-width: 641px) { .v5-more { display: none; } }

/* Phones: tighter spacing where two rows stack. */
@media (max-width: 640px) {
  /* Page tabs straight above view tabs (Renewals, Returning users): one group, not two sections. */
  cm-link-tabs + cm-status-tabs { margin-block-start: calc(-1 * var(--cm-space-12)); }
  /* Board cards: the 44px touch target of the "..." menu no longer pushes the details down. */
  cm-board-card > cm-action-menu[slot="actions"] { margin-block: calc(-1 * var(--cm-space-8)); }
}

/* Borderless header icons (cm-button variant="tertiary") and the light avatar ring come from Commmerce UI since 1.19. */

/* Links (owner 18 Nov 2026): black with a light grey underline that darkens on hover, instead of the
   information orange that /v4 uses. Links styled elsewhere (task titles, menus) keep their own rules. */
a { color: var(--cm-text-default); text-decoration: underline; text-decoration-color: var(--cm-border-input); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

/* Look and feel of the merchant admin (owner, 18 Nov 2026): neutral greys (no green tint), a #F4F4F4 page,
   the white page panel, and light grey section cards with no border inside it. The green accent, Inter and
   darker supporting text of the refined look stay. */
:root[data-cm-look="refined"] {
  --cm-bg-page: #f4f4f4; --cm-bg-hover: #f7f7f7; --cm-bg-inset: #fafafa; --cm-bg-input-filled: #f9f9f9; --cm-bg-icon: #f7f7f7;
  --cm-bg-tag: #f1f1f1; --cm-thumb-bg: #e7e7e7; --cm-border-subtle: #ececec; --cm-border-input: #8b8b8b;
  --cm-text-default: #111111; --cm-text-tertiary: #5f5f5f; --cm-text-secondary: #9e9e9e; --cm-icon-default: #8b8b8b;
}
#main cm-card:not([flush]):not(:has(cm-resource-list, cm-data-table, cm-timeline))::part(card) { background: #fafafa; border-color: transparent; }
/* (a card holding a list, table or timeline stays white: those have white rows of their own) */

/* Board cards open with a press anywhere on them (lib/ui.js), so they show a pointer; dragging still works. */
cm-board-card[href]::part(card) { cursor: pointer; }

/* Dropdown lists: the chosen option is the light green of selected rows with dark text, not a black or grey bar. */
cm-select, cm-combobox { --cm-action-primary: var(--cm-accent-soft); --cm-action-primary-hover: #d3f2d1; --cm-action-primary-text: var(--cm-text-default); }

/* Notifications: a white header like the rest of the page and no striped rows. */
cm-notification-panel { --cm-bg-panel-header: var(--cm-bg-surface); --cm-text-on-dark: var(--cm-text-default); --cm-icon-hover: var(--cm-text-default); --cm-bg-hover: var(--cm-bg-surface); }

/* List rows run edge to edge (owner, 18 Nov 2026): Commmerce UI does this itself since 1.17.1, so no override here. */

/* Tables in an edge-to-edge (flush) card: the grey heading bar is straight and runs to the card's edges; the card
   already has the rounded corners and the side borders (the table's own rounded corners showed inside it). */
cm-card[flush] cm-data-table > table thead th:first-child { border-start-start-radius: 0; border-inline-start: 0; }
cm-card[flush] cm-data-table > table thead th:last-child { border-start-end-radius: 0; border-inline-end: 0; }

/* Mail (modules/mail.js mailPanes): list | conversation, each scrolling on its own; height set by lib/ui.js. */
.v5-mail { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: var(--cm-space-20); min-height: 0; }
.v5-mail-list, .v5-mail-read { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-subtle); border-radius: var(--cm-radius-md); overflow: hidden; }
.v5-mail-tools { display: flex; flex-direction: column; gap: var(--cm-space-12); padding: var(--cm-space-12) var(--cm-space-12) var(--cm-space-8); border-bottom: var(--cm-border-1) solid var(--cm-border-subtle); }
.v5-mail-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.v5-mail-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-block: 2px; }
.v5-mail-top { display: flex; align-items: baseline; gap: var(--cm-space-8); }
.v5-mail-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v5-mail-at { flex: none; font-size: var(--cm-font-size-12); color: var(--cm-text-tertiary); }
.v5-mail-subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--cm-font-size-13); }
.v5-mail-snip { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12); color: var(--cm-text-tertiary); }
.v5-unread .v5-mail-who, .v5-unread .v5-mail-subj { font-weight: 600; }
.v5-unread .v5-mail-who::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-inline-end: 6px; border-radius: 50%; background: var(--cm-accent); vertical-align: 1px; }
.v5-mail-pager { display: flex; align-items: center; gap: var(--cm-space-8); padding: var(--cm-space-8) var(--cm-space-12); }
.v5-mail-pager .v4-muted { flex: 1; }
.v5-mail-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: var(--cm-space-8); color: var(--cm-text-tertiary); }
.v5-mail-empty p { margin: 0; }
.v5-read-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-8) var(--cm-space-12); padding: var(--cm-space-16) var(--cm-space-20); border-bottom: var(--cm-border-1) solid var(--cm-border-subtle); }
.v5-read-head h2 { flex: 1 1 16rem; min-width: 0; margin: 0; font-size: var(--cm-font-size-18); line-height: var(--cm-line-height-18); font-weight: 600; overflow-wrap: anywhere; }
.v5-read-tag { display: inline-flex; align-items: center; gap: var(--cm-space-8); font-size: var(--cm-font-size-13); color: var(--cm-text-tertiary); }
.v5-back { display: none; }
.v5-read-body { padding: var(--cm-space-8) var(--cm-space-20) var(--cm-space-20); display: flex; flex-direction: column; gap: var(--cm-space-8); }
.v5-msg { border-bottom: var(--cm-border-1) solid var(--cm-border-subtle); }
.v5-msg summary { list-style: none; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: var(--cm-space-12); row-gap: 2px; align-items: center; padding: var(--cm-space-12) 0; cursor: pointer; }
.v5-msg summary::-webkit-details-marker { display: none; }
.v5-msg summary:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; border-radius: var(--cm-radius-sm); }
.v5-msg-from { display: flex; flex-direction: column; min-width: 0; }
.v5-msg-to { font-size: var(--cm-font-size-12); color: var(--cm-text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v5-msg-at { font-size: var(--cm-font-size-12); color: var(--cm-text-tertiary); white-space: nowrap; }
.v5-msg-peek { grid-column: 2 / -1; font-size: var(--cm-font-size-13); color: var(--cm-text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v5-msg[open] .v5-msg-peek { display: none; }
.v5-msg-body { white-space: pre-wrap; overflow-wrap: anywhere; padding: 0 0 var(--cm-space-16) 36px; line-height: 1.6; }
.v5-msg-files { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-8); padding: 0 0 var(--cm-space-16) 36px; font-size: var(--cm-font-size-13); }
.v5-file { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: var(--cm-border-1) solid var(--cm-border-subtle); border-radius: var(--cm-radius-sm); }
.v5-compose { display: flex; flex-direction: column; gap: var(--cm-space-12); margin-top: var(--cm-space-12); padding: var(--cm-space-16); border: var(--cm-border-1) solid var(--cm-border-subtle); border-radius: var(--cm-radius-md); background: var(--cm-bg-surface); }
.v5-compose-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--cm-space-12); }
.v5-compose-fields [data-role="subj"] { grid-column: 1 / -1; }
.v5-compose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-8); }
.v5-compose-actions .v4-muted { margin-inline-start: auto; font-size: var(--cm-font-size-12); }
/* Narrow: one pane at a time (data-open="1" = the conversation), with Back. */
@media (max-width: 1023px) {
  .v5-mail { grid-template-columns: minmax(0, 1fr); }
  .v5-mail[data-open="1"] .v5-mail-list, .v5-mail:not([data-open="1"]) .v5-mail-read { display: none; }
  .v5-back { display: inline-flex; margin-inline-start: calc(-1 * var(--cm-space-8)); }
  .v5-read-head h2 { flex-basis: 100%; }
  .v5-compose-fields { grid-template-columns: minmax(0, 1fr); }
  .v5-read-body { padding-inline: var(--cm-space-12); }
  .v5-msg-body, .v5-msg-files { padding-inline-start: 0; }
}
.v5-compose-fields .v5-wide { grid-column: 1 / -1; }
button.v5-file { font: inherit; font-size: var(--cm-font-size-13); color: var(--cm-text-default); background: var(--cm-bg-surface); cursor: pointer; }
button.v5-file:hover { background: var(--cm-bg-hover); }
button.v5-file:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
button.v5-file[aria-busy="true"] { opacity: .6; cursor: progress; }
.v5-fwd-files { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-8) var(--cm-space-16); font-size: var(--cm-font-size-13); }
.v5-fwd-files[hidden] { display: none; }
.v5-fwd-label { color: var(--cm-text-tertiary); }

/* Edge-to-edge (flush) cards: the header had 24px above the title and 8px below it (before a list's Select bar
   or a table heading). The title gets 16px more below, so the space above and below it is the same. */
cm-card[flush]:not([description])::part(title) { padding-block-end: var(--cm-space-16); }
/* Tables in those cards: the first and last columns line up with the card title (24px, 16px on phones), and the
   last row has no line of its own on top of the card's bottom edge. */
cm-card[flush] cm-data-table > table :is(th, td):first-child { padding-inline-start: var(--cm-space-24); }
cm-card[flush] cm-data-table > table :is(th, td):last-child { padding-inline-end: var(--cm-space-24); }
@media (max-width: 640px) {
  cm-card[flush] cm-data-table > table :is(th, td):first-child { padding-inline-start: var(--cm-space-16); }
  cm-card[flush] cm-data-table > table :is(th, td):last-child { padding-inline-end: var(--cm-space-16); }
}
cm-card[flush] cm-data-table > table tbody tr:last-child > :is(th, td) { border-block-end: 0; }
