/* Adaptación compartida de tienda y panel, conservando sus temas y colores. */
:where(.grid-2, .account, .cart, .checkout, .contact, .sup-layout, .sup-form, .crm-grid-2, .crm-grid-3) > * { min-width: 0; }
:where(.field, .crm-field, .card-panel, .crm-card, .awrap, .crm-main, .cat-layout, .cat-row) { min-width: 0; }
.grid-2 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.upload__body { min-width: min(220px, 100%); }
body.crm .select2-selection__rendered { min-width: 0; }
body.crm .select2-results__option { overflow-wrap: anywhere; }
body.crm .crm-dialog__head h3 { min-width: 0; overflow-wrap: anywhere; }
body.crm .crm-dialog__body { min-height: 0; }
body.crm .crm-table-sort { display: none; }
body.crm .crm-table-sort select { width: 100%; }
@media (max-width: 720px) {
  body.crm .crm-table-sort { display: grid; gap: .3rem; flex: 1 1 100%; min-width: 0; color: var(--sp-muted); font-size: .8rem; }
  body.crm .crm-table-sort .select2-container { width: 100% !important; }
  body.crm .crm-pagination__actions { width: 100%; min-width: 0; justify-content: flex-start; gap: .4rem; }
  body.crm .crm-page-link { flex: 1 1 auto; }
  body.crm .crm-page-size-label { flex-basis: calc(100% - 90px); }
  body.crm .period .field { min-width: 0; max-width: 100%; }
  body.crm .period :is(input, select) { min-width: 0; }
  body.crm .crm-filter-bar > *, body.crm .atitle-actions { max-width: 100%; }
  body.crm .crm-main { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
  .upload__body { flex-basis: 100%; }
}
@media (max-width: 620px) {
  body:not(.crm) .head__in { gap: 4px; }
  body:not(.crm) .head__actions .ico:not(.ico--avatar), body:not(.crm) .head__burger { width: 44px; height: 44px; }
  body:not(.crm) .head__actions .ico--avatar { margin-inline: 5px; }
  body.crm .crm-head { padding-inline: max(.65rem, env(safe-area-inset-left)); }
  body.crm .crm-head__side { min-width: 0; }
  .btn, .crm-btn { white-space: normal; text-align: center; }
}
@media (max-width: 360px) {
  body:not(.crm) .brand__tag { display: none; }
  body:not(.crm) .brand__name { font-size: .92rem; letter-spacing: .06em; }
  body:not(.crm) .brand { gap: 6px; }
}
@media (pointer: coarse), (max-width: 820px) {
  :where(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), textarea, select) { font-size: 16px; }
  body.crm :is(.crm-field, .field, .period, .chat__search, .chat__reply) :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), textarea, select),
  body.crm .select2-container--sophiaris :is(.select2-selection, .select2-search__field) { font-size: 16px; }
  body.crm :is(.crm-icon-btn, .lead-table .crm-icon-btn, .crm-dialog__close, .crm-burger, .crm-page-link),
  .ob-controls button, .cat-viewer__nav, .cat-viewer__close { min-width: 44px; min-height: 44px; }
  body.crm :is(.crm-btn, .btn), body:not(.crm) .btn, .act-tabs a, .act-week__add { min-height: 44px; }
  .act-tabs a { display: inline-flex; align-items: center; }
  .act-week { scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
  .act-week__col { scroll-snap-align: start; }
}
/* La ventana conserva acceso al cierre y al formulario con poco alto disponible. */
@media (max-height: 500px) {
  body.crm .crm-dialog { max-height: calc(100dvh - 12px); }
  body.crm .crm-dialog--record { height: calc(100dvh - 12px); }
  body.crm .crm-dialog__head { padding-block: .4rem; }
  body.crm .crm-dialog__body { padding-block: .6rem; }
  body.crm .crm-form-frame { min-height: 0; height: min(68dvh, 780px); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body.crm .crm-mobile-tools { display: none; }
@media (max-width: 720px) {
  body.crm .crm-mobile-tools { display: flex; }
  body.crm .crm-mobile-tools .crm-table-sort { flex-basis: 100%; }
}
@media (max-width: 340px) {
  body.crm .crm-head .crm-round[data-theme-toggle] { display: grid; }
  body.crm .crm-head { gap: .25rem; }
}
@media (pointer: coarse), (max-width: 820px) {
  body:not(.crm) .field :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), textarea, select) { font-size: 16px; }
}
@media (max-width: 620px) {
  body:not(.crm) .head__burger { width: 44px; height: 44px; flex: none; align-items: center; justify-content: center; }
  body.crm .crm-bell__panel { position: fixed; top: 72px; right: max(12px, env(safe-area-inset-right)); left: max(12px, env(safe-area-inset-left)); width: auto; max-height: calc(100dvh - 84px); overflow-y: auto; }
  body.crm .crm-bell__head { flex-wrap: wrap; }
  body.crm .crm-bell__list { max-height: calc(100dvh - 180px); }
}
@media (max-width: 360px) {
  body:not(.crm) .head__in .brand__text { display: none; }
}

/* En escritorio el menú abierto deja de cubrir el panel: el shell completo usa
   exactamente el ancho restante. En móvil conserva el patrón modal con scrim. */
@media (min-width: 1024px) {
  body.crm.crm-nav-open { overflow-x: hidden; overflow-y: auto; }
  body.crm.crm-nav-open > :is(.crm-head, .crm-main, .crm-foot) {
    width: calc(100% - 340px);
    margin-left: 340px;
  }
  body.crm.crm-nav-open .crm-scrim { display: none !important; }
  body.crm.crm-nav-open .crm-nav { box-shadow: 12px 0 50px rgba(0, 0, 0, .45); }
}

/* El panel usa todo el ancho restante y limita el desborde a cada tabla. */
body.crm .crm-content-flow > *, body.crm .crm-module-flow > * { width: 100%; max-width: none; min-width: 0; }
body.crm :is(.crm-table-wrap, .table-wrap) { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
@media (min-width: 1024px) { body.crm .finance-workspace > .account { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  body.crm .finance-workspace .bars__row, body.crm .finance-workspace .bars--thin .bars__row { grid-template-columns: minmax(4.5rem, auto) minmax(0, 1fr); }
  body.crm .finance-workspace .bars__value { grid-column: 2; text-align: right; white-space: normal; }
}

/* Las direcciones de configuración siguen completas y legibles en celulares. */
body.crm .chat-setup__url {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Una dirección o correo largo no debe imponer el ancho mínimo de una tarjeta. */
body .side__list { grid-template-columns: minmax(0, 1fr); }
body .side__list > li { min-width: 0; }
body .side__list :is(a, span) { min-width: 0; overflow-wrap: anywhere; }

/* Personal workspace: intrinsic sizing keeps grids/cards inside their own lane. */
body.crm :is(.crm-profile,.crm-profile__id,.crm-profile__facts,.crm-form-grid,.crm-field,.shared-bank-card,.transfer-card__identity,.crm-page-actions) { min-width: 0; }
body.crm .bank-grid .transfer-field { grid-template-columns: minmax(0,.8fr) minmax(0,1.2fr); gap: .75rem; align-items: start; }
body.crm .bank-grid .transfer-field dd { display: block; min-width: 0; margin: 0; }
body.crm .bank-grid .transfer-field code { white-space: normal; overflow-wrap: anywhere; word-break: normal; }
body.crm .bank-grid .transfer-field--number code { white-space: normal; overflow-wrap: anywhere; }
body.crm .shared-bank-note { margin: 1rem 1.1rem; padding: .75rem; border-radius: .6rem; background: var(--sp-soft); line-height: 1.6; }
body.crm .shared-bank-info { width: calc(100% - 2.2rem); margin-inline: 1.1rem; }
body.crm .shared-bank-footer > span { flex: 1 1 10rem; min-width: 0; }
body.crm .crm-profile__mail { overflow-wrap: anywhere; word-break: break-word; }
body.crm .crm-profile__facts { grid-template-columns: repeat(auto-fit,minmax(min(100%,180px),1fr)); }
body.crm .crm-profile__head { align-items: center; }
body.crm .crm-profile__id { padding-top: 58px; }
body.crm .crm-profile__cam { width: 44px; height: 44px; }
body.crm .crm-avatar-file { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
body.crm .crm-profile__cam:focus-within { outline: 3px solid var(--sp-gold); outline-offset: 3px; }
body.crm :is(a,button,summary,input,select,textarea,[tabindex]):focus-visible { outline: 3px solid var(--sp-gold-3); outline-offset: 3px; }
body.crm .crm-bell__panel { width: min(440px,calc(100vw - 24px)); max-height: calc(100dvh - 100px); overflow-y: auto; overscroll-behavior: contain; color: var(--sp-ink); }
body.crm .crm-bell__hint { margin: .5rem 1rem; color: var(--sp-muted); font-size: .76rem; line-height: 1.5; }
body.crm .crm-bell__read-all { margin: .25rem 1rem .75rem; max-width: calc(100% - 2rem); }
body.crm .crm-inbox-item { display: grid; grid-template-columns: minmax(0,1fr) auto; border-top: 1px solid var(--sp-line); }
body.crm .crm-inbox-item .crm-bell__item { min-width: 0; border: 0; }
body.crm .crm-inbox-item .crm-bell__item > span { min-width: 0; overflow-wrap: anywhere; }
body.crm .crm-inbox-item.is-read .crm-bell__dot { background: transparent; border: 1px solid var(--sp-muted); }
body.crm .crm-inbox-actions { display: flex; align-items: start; padding: .5rem .4rem; gap: .2rem; }
body.crm .crm-inbox-actions button { min-width: 44px; min-height: 44px; padding: .35rem; border: 1px solid var(--sp-line); border-radius: .6rem; background: var(--sp-soft); color: var(--sp-ink); font: inherit; cursor: pointer; }
body.crm .crm-inbox-actions button:last-child { font-size: 1.35rem; }
@media(max-width:620px) {
  body.crm .crm-bell__panel { width: auto; }
  body.crm .bank-grid .transfer-field { grid-template-columns: 1fr; gap: .4rem; }
  body.crm .crm-profile__head { padding-inline: 1rem; gap: .6rem; }
  body.crm .crm-profile__id { flex-basis: 100%; padding-top: 0; }
  body.crm .crm-profile__facts { padding: 1rem; }
  body.crm .crm-profile__id h2 { font-size: 1.65rem; }
}
