/* scene-specific styles: crm group (record, kanban, table, automation, email).
   Builds on core.css; every class here is prefixed dm-crm- except the shared
   .rise/.in reveal used inside .dm-crm bodies. */

/* shared: reveal, toast placement, heads, icons */
.dm-crm { line-height: 1.45; }
.dm-crm .rise { opacity: 0; transform: translateY(8px); transition: opacity 0.45s ease, transform 0.5s var(--ease-out); }
.dm-crm .rise.in { opacity: 1; transform: none; }
.dm-crm .dm-toast { position: absolute; right: 18px; bottom: 18px; z-index: 5; max-width: calc(100% - 36px); }
[dir="rtl"] .dm-crm .dm-toast { right: auto; left: 18px; }
.dm-crm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; min-width: 0; }
.dm-crm-head .dm-mark { width: 34px; height: 34px; border-radius: 9px; font-size: 0.8rem; }
.dm-crm-headtxt { min-width: 0; flex: 1; }
.dm-crm-headtxt b { display: block; color: var(--ink); font-family: var(--font-display); font-size: 1rem; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-headtxt span { display: block; color: var(--faint); font-size: 0.7rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-headtags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 50%; }
.dm-crm-ic {
  width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; font-style: normal;
  background: rgba(59, 130, 246, 0.16); color: #8fbaff;
}
.dm-crm-ic.call { background: rgba(7, 159, 191, 0.16); color: #8de0f7; }
.dm-crm-ic.note { background: rgba(139, 127, 240, 0.16); color: #b9b2ff; }
.dm-crm-ic.bolt { width: 34px; height: 34px; border-radius: 9px; background: rgba(255, 197, 85, 0.14); color: var(--warn); }
.dm-crm-tabs { margin-bottom: 12px; }
.dm-crm-tabs .dm-tab u { text-decoration: none; color: var(--faint); font-weight: 600; opacity: 0.8; }
.dm-crm-who { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.dm-crm-who .dm-avatar { width: 20px; height: 20px; font-size: 0.54rem; }
.dm-crm-who em { font-style: normal; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* record: fields and timeline */
.dm-crm-field { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.dm-crm-field:last-child { border-bottom: 0; }
.dm-crm-field > span { color: var(--faint); font-size: 0.7rem; flex: none; min-width: 78px; }
.dm-crm-field > b { color: var(--ink); font-size: 0.76rem; font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; }
.dm-crm-ev {
  display: flex; align-items: flex-start; gap: 10px; padding: 5px 8px; border-radius: 10px; margin-bottom: 3px;
  border: 1px solid transparent; background: rgba(255, 255, 255, 0.015);
}
.dm-crm-ev > div { min-width: 0; flex: 1; }
.dm-crm-evtop { display: flex; align-items: center; gap: 7px; min-width: 0; }
.dm-crm-ev b { flex: 0 0 auto; max-width: 52%; min-width: 0; color: var(--ink); font-size: 0.76rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-meta { margin-inline-start: auto; flex: 0 1 auto; min-width: 0; color: var(--faint); font-size: 0.66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-meta .dm-avatar { display: inline-grid; width: 15px; height: 15px; font-size: 0.46rem; vertical-align: -3px; margin-right: 5px; }
[dir="rtl"] .dm-crm-meta .dm-avatar { margin-right: 0; margin-left: 5px; }
.dm-crm-snip { display: block; color: var(--muted); font-size: 0.7rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-evend { display: flex; justify-content: flex-end; padding-top: 2px; }
.dm-crm-evend .dm-btn { padding: 4px 12px; }

/* kanban: the board (the toast sits under the shortest column, bottom-left) */
.dm-crm-board ~ .dm-toast { right: auto; left: 18px; }
[dir="rtl"] .dm-crm-board ~ .dm-toast { left: auto; right: 18px; }
.dm-crm-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.dm-crm-col {
  background: rgba(255, 255, 255, 0.025); border: 1px solid var(--line-soft); border-radius: 14px; padding: 10px; min-width: 0;
  transition: border-color 0.3s, background 0.3s;
}
.dm-crm-col.over { border-color: rgba(7, 159, 191, 0.5); background: rgba(7, 159, 191, 0.06); }
.dm-crm-colh { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 2px 4px 10px; min-width: 0; }
.dm-crm-colh b { color: var(--ink); font-size: 0.66rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-crm-colh span { color: var(--faint); font-size: 0.68rem; flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dm-crm-colh u { text-decoration: none; }
.dm-crm-cards { display: flex; flex-direction: column; gap: 8px; min-height: 64px; }
.dm-crm-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 9px 10px; min-width: 0; transition: opacity 0.25s, border-color 0.3s;
}
.dm-crm-card b { display: block; color: var(--ink); font-size: 0.74rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-card span { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--faint); font-size: 0.66rem; min-width: 0; }
.dm-crm-card span u { text-decoration: none; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }
.dm-crm-card span .dm-avatar { width: 16px; height: 16px; font-size: 0.46rem; margin-left: auto; }
[dir="rtl"] .dm-crm-card span .dm-avatar { margin-left: 0; margin-right: auto; }
.dm-crm-card span em { font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-card.lifted { opacity: 0.25; border-style: dashed; }
.dm-crm-card.landed { animation: dm-crm-land 0.5s var(--ease-spring); border-color: rgba(7, 159, 191, 0.5); }
@keyframes dm-crm-land { 0% { transform: scale(0.94); opacity: 0.6; } }
.dm-crm-card.ghost {
  position: absolute; z-index: 5; margin: 0; pointer-events: none; transition: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); transform: rotate(-2deg) scale(1.03); border-color: rgba(7, 159, 191, 0.6);
  background: #10242a;
}

/* table: saved view, formula column, filter chips */
.dm-crm-viewbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.dm-crm-viewname { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dm-crm-viewname b { color: var(--ink); font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-viewname span { color: var(--faint); font-size: 0.8rem; flex: none; }
.dm-crm-table { min-width: 0; }
.dm-crm-tr { display: grid; grid-template-columns: 1.7fr 1fr 0.8fr 0.9fr 1.1fr 1fr; gap: 10px; align-items: center; min-width: 0; }
.dm-crm-tr.dm-row { padding: 5px 9px; margin-bottom: 2px; }
.dm-crm-th { padding: 4px 9px 6px; color: var(--faint); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.dm-crm-th span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-crm-th .full, .dm-crm-th .short { font-style: normal; }
.dm-crm-th .short { display: none; }
.dm-crm-th .dm-badge { text-transform: none; letter-spacing: 0; padding: 0 5px; font-size: 0.56rem; vertical-align: middle; }
.dm-crm-tr.dm-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.dm-crm-tr .num { text-align: right; }
[dir="rtl"] .dm-crm-tr .num { text-align: left; }
.dm-crm-tr .dm-crm-who { max-width: 100%; }
.dm-crm-ev-val { color: var(--ink) !important; font-weight: 600; min-height: 1.2em; border-radius: 6px; padding: 1px 5px; transition: background 0.25s; }
.dm-crm-ev-val.flash { background: rgba(7, 159, 191, 0.2); }
.dm-crm .dm-row.out { opacity: 0.22; }
.dm-crm .dm-total u { text-decoration: none; }

/* automation: log and publish row */
.dm-crm-autogrid .dm-step { padding: 6px 10px; margin-bottom: 5px; }
.dm-crm-mode { transition: background 0.3s, color 0.3s; }
.dm-crm-log { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; min-height: 128px; }
.dm-crm-logline {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.03); color: var(--muted); font-size: 0.72rem; font-variant-numeric: tabular-nums;
}
.dm-crm-logline i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); flex: none; }
.dm-crm-logline.amber i { background: var(--warn); }
.dm-crm-logline.good i { background: var(--good); }
.dm-crm-logline span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-crm-publish { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.dm-crm-publish span { color: var(--faint); font-size: 0.7rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* email: template rows and the compose card */
.dm-crm-tpl {
  display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 10px; margin-bottom: 4px;
  border: 1px solid transparent; transition: border-color 0.3s, background 0.3s;
}
.dm-crm-tpl.hl { border-color: rgba(7, 159, 191, 0.45); background: rgba(7, 159, 191, 0.08); }
.dm-crm-tpl b { color: var(--ink); font-size: 0.76rem; font-weight: 550; flex: none; width: 44%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-crm-tpl .dm-meter { flex: 1; }
.dm-crm-tpl u { text-decoration: none; color: var(--ink); font-size: 0.74rem; font-weight: 600; font-variant-numeric: tabular-nums; flex: none; min-width: 34px; text-align: right; }
[dir="rtl"] .dm-crm-tpl u { text-align: left; }
.dm-crm-line { display: flex; align-items: baseline; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.dm-crm-line span { color: var(--faint); font-size: 0.7rem; flex: none; min-width: 52px; }
.dm-crm-line b { color: var(--ink); font-size: 0.76rem; font-weight: 500; min-height: 1.2em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-crm-bodytxt { padding: 10px 2px 8px; color: var(--muted); font-size: 0.76rem; line-height: 1.8; min-height: 4.4em; }
.dm-crm-bodytxt > * { opacity: 0; transition: opacity 0.3s; }
.dm-crm-bodytxt > .in { opacity: 1; }
.dm-crm-var {
  font-style: normal; display: inline-block; border-radius: 6px; padding: 0 6px; line-height: 1.5; vertical-align: baseline;
  font-size: 0.68rem; font-weight: 600; background: rgba(255, 197, 85, 0.14); color: var(--warn); transition: background 0.3s, color 0.3s;
}
.dm-crm-var.ok { background: rgba(61, 220, 151, 0.14); color: var(--good); }
.dm-crm-var.pop { animation: dm-pop 0.45s var(--ease-spring); }
.dm-crm-sendrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.dm-crm-sendrow span { color: var(--faint); font-size: 0.7rem; }

/* narrow frames: a split column (560px) and phones */
:is(.split-visual, .flow-step) .dm-crm-board { grid-template-columns: repeat(2, 1fr); }
:is(.split-visual, .flow-step) .dm-crm-tr { grid-template-columns: 1.6fr 1fr 0.8fr 0.8fr 1.1fr; }
:is(.split-visual, .flow-step) .dm-crm-tr .c5 { display: none; }
:is(.split-visual, .flow-step) .dm-crm-th .full { display: none; }
:is(.split-visual, .flow-step) .dm-crm-th .short { display: inline; }
@media (max-width: 860px) {
  .dm-crm-board { grid-template-columns: repeat(2, 1fr); }
  .dm-crm-tr { grid-template-columns: 1.6fr 1fr 0.8fr 0.8fr 1.1fr; }
  .dm-crm-tr .c5 { display: none; }
  .dm-crm-th .full { display: none; }
  .dm-crm-th .short { display: inline; }
}
@media (max-width: 520px) {
  .dm-crm .dm-toast, .dm-crm-board ~ .dm-toast { position: static; margin: 12px 0 0 auto; width: fit-content; }
  [dir="rtl"] .dm-crm .dm-toast, [dir="rtl"] .dm-crm-board ~ .dm-toast { margin: 12px auto 0 0; }
  .dm-crm-mailgrid .dm-toast { grid-column: 1 / -1; margin-top: 0; }
  .dm-crm-evtop { flex-wrap: wrap; row-gap: 1px; }
  .dm-crm-ev b { max-width: 100%; }
  .dm-crm-meta { flex: 1 0 100%; margin-inline-start: 0; }
  .dm-crm-headtags .dm-tag:nth-child(3) { display: none; }
  .dm-crm-colh { flex-direction: column; align-items: flex-start; gap: 1px; }
  .dm-crm-tr, :is(.split-visual, .flow-step) .dm-crm-tr { grid-template-columns: 1.3fr 1.25fr 0.9fr; gap: 8px; }
  .dm-crm-tr .c2, .dm-crm-tr .c3 { display: none; }
  .dm-crm-card span em { display: none; }
  .dm-crm-headtags { max-width: 40%; }
  .dm-crm-tpl { flex-wrap: wrap; row-gap: 4px; }
  .dm-crm-tpl b { width: 100%; }
  .dm-crm-th .dm-badge { display: none; }
  .dm-crm-field > span { min-width: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .dm-crm .rise, .dm-crm-bodytxt > * { opacity: 1; transform: none; transition: none; }
  .dm-crm-card.landed, .dm-crm-var.pop { animation: none; }
}
