/* Shared adaptive layout. The original palette, typography and actions are retained. */
/* Native form focus stays inside the control, including fields at scroll edges.
   Root/body specificity keeps module focus rules from restoring an outer halo.
   Semi fields and native choice/button controls retain their own focus states. */
:root body :is(input,select,textarea):not(:where(
  [type=checkbox],[type=radio],[type=range],[type=color],[type=hidden],
  [type=button],[type=submit],[type=reset],[type=image],[type=file],[class*="semi-"]
)):focus {
  outline:2px solid var(--crm-primary,var(--semi-color-primary,#3370ff));
  outline-offset:-2px;
  box-shadow:none;
}
/* Keep single-line native controls vertically centered even when a module
   gives them a fixed height. Multi-line fields keep their natural top-start
   editing behavior, and listbox/file/choice controls keep their native UI. */
:root body :is(
  input:not(:where([type=checkbox],[type=radio],[type=range],[type=color],[type=hidden],
    [type=button],[type=submit],[type=reset],[type=image],[type=file],[class*="semi-"])),
  select:not([multiple])
) {
  box-sizing:border-box;
  vertical-align:middle;
  line-height:normal !important;
}
/* Contract/order filters use content-driven heights. Semi's percentage-height
   selection otherwise collapses to one line at the top of the min-height box. */
:is(.cs-filter-select,.ow-filter-select).semi-select.semi-select-single {
  align-items:center;
}
:is(.cs-filter-select,.ow-filter-select).semi-select.semi-select-single .semi-select-selection {
  height:auto;
  min-height:32px;
  padding-block:6px;
  overflow:visible;
}
:is(.cs-filter-select,.ow-filter-select).semi-select.semi-select-single .semi-select-content-wrapper {
  min-width:0;
  min-height:1lh;
  height:auto;
  white-space:normal;
  overflow:visible;
}
/* Native form padding must not leak into Semi's inline search input. */
:is(.cs-filter-select,.ow-filter-select).semi-select.semi-select-single .semi-input-wrapper {
  display:flex;
  align-items:center;
  height:100%;
  line-height:inherit;
}
:is(.cs-filter-select,.ow-filter-select).semi-select.semi-select-single .semi-input {
  height:100%;
  min-height:0;
  padding:0;
  border:0;
  background:transparent;
  font:inherit;
  line-height:normal;
}
/* Keep every expandable-menu arrow beside its label.  Count badges stay at the
   far edge of the item, so the arrow does not jump between the label and badge. */
.sidebar .nav-item > .nav-arrow { order:2; margin-left:5px; flex-shrink:0; }
.sidebar .nav-item > .nav-count { order:3; }
/* These modules use one collapsible heading, followed directly by their pages. */
.sidebar .nav-section-toggle {
  height:auto; min-height:40px; margin:16px 0 0; padding:10px 12px;
  border-top:1px solid var(--crm-control-border); border-radius:0;
  color:var(--crm-table-text); font-size:var(--ui-text-size); font-weight:600;
  gap:8px; text-align:left; white-space:normal;
}
.sidebar .nav-section-label { flex:1 1 0; min-width:0; overflow-wrap:anywhere; }
.sidebar .nav-section-toggle > .nav-arrow { margin-left:0; transform:rotate(0deg); }
.sidebar .nav-section-toggle[aria-expanded=true] > .nav-arrow { transform:rotate(90deg); }
.sidebar .nav-section-toggle.active { color:var(--crm-primary); }
.sidebar .nav-section-toggle > .nav-count { order:1; margin-left:0; }
.sidebar .nav-section-toggle > .nav-count:empty { display:none; }
.sidebar .nav-section-toggle:focus-visible { outline-offset:-2px; }
/* Every second-level item follows the business-management rhythm.  Direct
   sections (projects, finance, HR, tasks and settings) start on the same left
   rail as business-management areas; only third-level pages receive the
   additional nested indent below. */
.sidebar .nav-section-toggle + .sub-nav { padding-left:0; }
.sidebar .sub-nav .sub-item {
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  min-height:32px;
  padding:9px 12px;
  font-size:var(--ui-caption-size,12px);
  line-height:1.1667;
  white-space:normal;
  overflow-wrap:anywhere;
}
.sidebar .sub-nav .sub-icon {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:16px;
  height:16px;
  min-width:16px;
  flex:0 0 16px;
  color:var(--crm-muted,var(--muted,#8090a8));
  font-size:13px;
  line-height:16px;
  text-align:center;
}
.sidebar .sub-nav .sub-item:hover .sub-icon,.sidebar .sub-nav .sub-item.active .sub-icon { color:inherit; }
/* Business management has one extra catalog level: the top-level module is
   followed by second-level business areas, then their existing pages. Keep
   the second-level rhythm aligned with the other module headings while the
   leaf pages retain the compact third-level caption size. */
.sidebar .nav-business-toggle + .sub-nav { padding-left:0; }
.sidebar .sub-nav > .sub-item.nav-level-two-toggle {
  min-height:40px;
  padding:10px 12px;
  color:var(--crm-table-text,var(--ink));
  font-size:var(--ui-text-size,13px);
  font-weight:500;
  line-height:1.25;
  border-radius:0;
}
.sidebar .nav-level-two-toggle .sub-label { flex:0 1 auto; min-width:0; overflow-wrap:anywhere; }
.sidebar .nav-level-two-toggle > .nav-arrow { margin-left:5px; transform:rotate(0deg); }
.sidebar .nav-level-two-toggle[aria-expanded=true] > .nav-arrow { transform:rotate(90deg); }
.sidebar .nav-level-two-toggle.active { color:var(--crm-primary,var(--blue)); background:var(--crm-header-bg,#edf1ff); }
.sidebar .nav-level-three { padding-left:26px; }
.sidebar .nav-section-toggle + .sub-nav > .sub-item:not(.nav-level-two-toggle) {
  min-height:40px;
  padding:10px 12px;
  color:var(--crm-table-text,var(--ink));
  font-size:var(--ui-text-size,13px);
  font-weight:500;
  line-height:1.25;
  border-radius:0;
}
.sidebar .nav-level-three > .sub-item {
  min-height:32px;
  padding:8px 12px;
  font-size:var(--ui-caption-size,12px);
  line-height:1.1667;
}
.crm-customer-scope-heading{display:flex;align-items:center;gap:8px;min-width:0;max-width:100%}
.crm-customer-scope-tabs{display:flex;flex-wrap:wrap;gap:8px 24px;min-width:0;max-width:100%}
.crm-customer-scope-tabs .page-tab{min-width:0;min-height:36px;padding:8px 2px;font-size:var(--ui-text-size,14px);white-space:normal;overflow-wrap:anywhere;color:var(--crm-ink,var(--ink))}
.crm-customer-scope-tabs .page-tab.active,.crm-customer-scope-tabs .page-tab:hover{color:var(--crm-primary,var(--blue))}
.crm-customer-scope-tabs .page-tab:focus-visible{outline:2px solid var(--crm-primary,var(--blue));outline-offset:2px;border-radius:3px}
.crm-customer-scope-heading>.module-info-wrap{flex-shrink:0}
.lead-scope-heading{display:flex;align-items:center;gap:8px;min-width:0;max-width:100%}
.lead-scope-tabs{display:flex;flex-wrap:wrap;gap:8px 24px;min-width:0;max-width:100%}
.lead-scope-tabs .page-tab{min-width:0;min-height:36px;padding:8px 2px;font-size:var(--ui-text-size,14px);white-space:normal;overflow-wrap:anywhere;color:var(--crm-ink,var(--ink))}
.lead-scope-tabs .page-tab.active,.lead-scope-tabs .page-tab:hover{color:var(--crm-primary,var(--blue))}
.lead-scope-tabs .page-tab:focus-visible{outline:2px solid var(--crm-primary,var(--blue));outline-offset:2px;border-radius:3px}
.lead-scope-tabs .page-tab[hidden]{display:none}
.lead-scope-heading>.module-info-wrap{flex-shrink:0}
.crm-customer-opportunity-tabs{min-width:0;max-width:100%;flex-wrap:wrap;gap:8px 24px;overflow:visible;}
.crm-customer-opportunity-tabs .page-tab{min-width:0;max-width:100%;min-height:36px;padding:8px 2px;white-space:normal;overflow-wrap:anywhere;color:var(--crm-ink,var(--ink));}
.crm-customer-opportunity-tabs .page-tab.active,.crm-customer-opportunity-tabs .page-tab:hover{color:var(--blue);}
.crm-customer-opportunity-tabs .page-tab small{font-size:inherit;color:inherit;}
.crm-customer-opportunity-tabs .page-tab:focus-visible{outline:2px solid var(--blue);outline-offset:2px;border-radius:3px;}
.crm-responsive-table { width:100%; min-width:0; overflow:hidden; }
/* Shared viewport rail; its body host keeps it out of clipped table ancestors.
   The original bottom scrollbar remains available next to pagination. */
.crm-table-viewport-scrollbar{position:fixed;z-index:10;height:18px;box-sizing:border-box;background:var(--crm-page-bg,#f7f8fb);border-top:1px solid var(--crm-border,#e2e8f0);touch-action:none;user-select:none;cursor:pointer}
.crm-table-viewport-scrollbar[hidden]{display:none}
.crm-table-viewport-scrollbar>div{height:10px;margin-top:3px;border-radius:6px;background:var(--crm-muted,#75869d);pointer-events:none}
.crm-table-viewport-scrollbar:focus-visible{outline:2px solid var(--crm-primary,#3370ff);outline-offset:-2px}
table.crm-auto-table,
.crm-responsive-table table.semi-table {
  table-layout:fixed;
}

/* Long follow-up fields stay compact by default and expand on demand. */
.crm-collapsible-text{display:block;min-width:0;max-width:100%;}
.crm-collapsible-text-content{display:-webkit-box;max-width:100%;margin:0;overflow:hidden;overflow-wrap:anywhere;white-space:pre-wrap;-webkit-box-orient:vertical;-webkit-line-clamp:2;}
.crm-collapsible-text.is-expanded .crm-collapsible-text-content{display:block;overflow:visible;-webkit-line-clamp:unset;}
.crm-collapsible-text-toggle{display:block;margin-top:3px;padding:0;border:0;background:none;color:var(--blue,#3370ff);font-size:11px;line-height:1.5;cursor:pointer;white-space:nowrap;}
.crm-collapsible-text-toggle:hover{text-decoration:underline;}
.crm-collapsible-text-toggle:focus-visible{outline:2px solid var(--blue,#3370ff);outline-offset:2px;border-radius:2px;}
.crm-customer-cell-text{display:block;min-width:0;max-width:100%;max-height:none;overflow:visible;overflow-wrap:anywhere;white-space:normal;line-height:1.5;-webkit-line-clamp:unset;}
.crm-customer-workspace[data-customer-scope="pool"] .crm-customer-cell-text{display:block;max-height:none;overflow:visible;-webkit-line-clamp:unset;}
.crm-customer-name-text{font-family:var(--ui-font);font-weight:700;}
.customer-reference-table .crm-customer-cell-text,.crm-customer-contact-table .crm-customer-cell-text{width:100%;}
.customer-reference-table .name-link,.crm-customer-contact-table .name-link{min-width:0;max-width:100%;}
.customer-reference-table .name-link .crm-customer-cell-text,.crm-customer-contact-table .name-link .crm-customer-cell-text{flex:1 1 auto;}
.customer-dossier-page .enterprise-fact-text .crm-collapsible-text-content{display:block;max-width:100%;max-height:none;overflow:visible;overflow-wrap:anywhere;white-space:pre-wrap;-webkit-line-clamp:unset;}
.lead-latest-followup-cell .crm-collapsible-text{width:100%;}
.lead-last-note.crm-collapsible-text-content{width:100%;text-align:left;font-size:11px;color:#657489;line-height:1.5;white-space:pre-wrap;}
.lead-latest-followup-cell .lead-latest-followup-date{margin-top:5px;}
.lead-latest-followup-cell .crm-collapsible-text-toggle{margin-top:2px;color:var(--blue,#3370ff);}

/* The lead list keeps follow-up content and its metadata in separate rows.
   The metadata row stays inline so the date always precedes the disclosure
   action without colliding with the two-line note clamp. */
.lead-latest-followup-cell .crm-collapsible-text-content,
table.crm-auto-table .lead-latest-followup-cell .crm-collapsible-text-content {
  display:-webkit-box;
  width:100%;
  max-width:100%;
  max-height:3em;
  overflow:hidden;
  overflow-wrap:anywhere;
  white-space:pre-wrap;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;
}
.lead-latest-followup-cell .crm-collapsible-text.is-expanded .crm-collapsible-text-content,
table.crm-auto-table .lead-latest-followup-cell .crm-collapsible-text.is-expanded .crm-collapsible-text-content {
  display:block;
  max-height:none;
  overflow:visible;
  -webkit-line-clamp:unset;
}
.lead-latest-followup-meta {
  display:flex;
  align-items:baseline;
  flex-wrap:wrap;
  gap:0 8px;
  min-width:0;
  margin-top:4px;
}
.lead-latest-followup-meta .lead-latest-followup-date {
  display:inline;
  flex:0 0 auto;
  max-width:none;
  margin:0;
}
.lead-latest-followup-meta .crm-collapsible-text-toggle {
  display:inline-block;
  flex:0 0 auto;
  margin:0;
}
.lead-latest-followup-meta .crm-collapsible-text-toggle[hidden] {
  display:none;
}
.enterprise-history-note-wrap{margin:8px 0;}
.enterprise-history-note-wrap .enterprise-history-note{margin:0;}
table.crm-auto-table :is(th,td), .crm-responsive-table :is(th,td) {
  min-width:0; height:auto; white-space:normal; overflow-wrap:anywhere; vertical-align:middle;
  padding:10px 8px; box-sizing:border-box; border-right:1px solid var(--crm-border);
}
table.crm-auto-table th:last-child,table.crm-auto-table td:last-child,
.crm-responsive-table th:last-child,.crm-responsive-table td:last-child { border-right:0; }
table.crm-auto-table th { position:relative; }
.crm-table-scroll { width:100%; max-width:100%; overflow:auto; overscroll-behavior-inline:contain; }
.crm-table-scroll > table.crm-auto-table { max-width:none; }
.column-resize-handle {
  position:absolute; z-index:7; inset:0 -5px 0 auto; width:10px; cursor:col-resize;
  touch-action:none; background:transparent; outline:0;
}
.column-resize-handle::after {
  content:''; position:absolute; inset:6px auto 6px 4px; width:1px;
  background:var(--crm-border); transition:background .15s,width .15s;
}
.column-resize-handle:hover::after,.column-resize-handle:focus-visible::after {
  width:2px; background:var(--crm-primary);
}
.column-resize-handle:focus-visible { box-shadow:inset -2px 0 0 var(--crm-primary); }
.crm-column-resizing { cursor:col-resize; user-select:none; }
table.crm-auto-table :is(th,td)[data-sticky=true] {
  position:sticky; left:var(--crm-sticky-left,0); z-index:2; background:var(--crm-surface);
}
table.crm-auto-table th[data-sticky=true] { z-index:5; background:var(--crm-header-bg); }
table.crm-auto-table :is(th,td)[data-sticky=true]:has(+ :not([data-sticky=true])) { box-shadow:5px 0 8px -8px #1f3a5f99; }
table.crm-auto-table thead th { position:sticky; top:0; z-index:4; background:var(--crm-header-bg); }
table.crm-auto-table thead th[data-sticky=true] { z-index:6; }
.crm-page-hidden { display:none !important; }
.crm-table-pagination {
  display:flex; justify-content:flex-end; align-items:center; flex-wrap:wrap; gap:8px 12px;
  min-height:48px; padding:8px 12px; border-top:1px solid var(--crm-border);
  color:var(--crm-muted); font-size:var(--ui-caption-size); background:var(--crm-surface);
}
.crm-table-pagination label { display:inline-flex; align-items:center; gap:6px; }
.crm-table-pagination select { min-width:82px; height:32px; border:1px solid var(--crm-border); border-radius:var(--crm-control-radius); background:var(--crm-surface); color:var(--crm-ink); }
table.crm-auto-table :is(.lead-company,.lead-intention,.name-link,.sf-company,.lead-tag-cell,.lead-operation-cell,.lead-product-cell) {
  min-width:0; max-width:100%; white-space:normal;
}
table.crm-auto-table :is(.row-actions,.lead-social-badges,.lead-wechat-inline) { display:flex; flex-wrap:wrap; align-items:center; gap:4px; }
table.crm-auto-table :is(.tag,.lead-chip,.row-action) { max-width:100%; white-space:normal; overflow-wrap:anywhere; }

/* Cell content must shrink with the column, including nested flex children. */
table.crm-auto-table :is(th,td) > *,
.crm-responsive-table :is(th,td) > * { min-width:0; max-width:100%; }
table.crm-auto-table :is(.name-link,.sf-company) > span:not(.table-avatar),
.crm-responsive-table :is(.semi-space-item,.semi-button-content,.semi-tag-content) { min-width:0; max-width:100%; }
table.crm-auto-table :is(.lead-last-note,.sf-next-text) {
  width:100%; max-width:100%; white-space:normal; overflow-wrap:anywhere;
  overflow:visible; text-overflow:clip; height:auto; line-height:1.5;
}
table.crm-auto-table .row-actions { min-width:0; max-width:100%; flex-wrap:wrap; }
table.crm-auto-table :is(.tag,.row-action) { display:inline-block; height:auto; line-height:1.5; }
table.crm-auto-table .table-avatar { flex-shrink:0; }
table.crm-auto-table .lead-operation-cell { position:static; box-shadow:none; }
table.crm-auto-table .outbound-phone { display:inline-flex; align-items:center; gap:4px; max-width:100%; }
table.crm-auto-table .outbound-phone-label { min-width:0; overflow-wrap:anywhere; }
.crm-responsive-table :is(.semi-table-cell,.semi-space-item) { min-width:0; }
/* Checkbox marks are icons, not text: inherited text baselines shift both the
   tick and mixed-state dash down inside the square. Keep Semi's state styling. */
.semi-checkbox-inner-display {
  display:inline-flex; align-items:center; justify-content:center; line-height:1;
}
/* Selection columns need their own gutter: Semi's 16px cell padding otherwise
   squeezes a compact column's checkbox. Match the customer list's 13px square,
   while retaining a 24px hit target and Semi's checked/mixed/disabled states. */
.crm-responsive-table .semi-table :is(th,td).semi-table-column-selection {
  padding-inline:8px; text-align:center; vertical-align:middle;
}
.crm-responsive-table .semi-table-column-selection .semi-table-selection-wrap {
  display:inline-flex; align-items:center; justify-content:center; min-width:24px;
}
.crm-responsive-table .semi-table-column-selection :is(.semi-checkbox,.semi-checkbox-inner) {
  flex:none; width:24px; min-width:24px; height:24px; align-items:center; justify-content:center;
}
.crm-responsive-table .semi-table-column-selection .semi-checkbox-inner-display {
  flex:none; width:13px; min-width:13px; height:13px; aspect-ratio:1;
}
.crm-responsive-table .semi-table-column-selection .semi-checkbox-inner-display .semi-icon { font-size:13px; }
.crm-responsive-table :is(.semi-button,.semi-tag) { max-width:100%; }
.crm-responsive-table :is(.semi-button,.semi-tag) { height:auto; min-height:var(--semi-height-control-small,24px); }
.crm-responsive-table :is(.semi-button-content,.semi-tag-content) { white-space:normal; overflow-wrap:anywhere; text-overflow:clip; line-height:1.5; }
.crm-responsive-table .semi-table-pagination-outer { flex-wrap:wrap; gap:8px; }
.crm-responsive-table :is(.semi-pagination,.semi-page) { flex-wrap:wrap; justify-content:flex-end; height:auto; row-gap:6px; }
.crm-responsive-table .semi-table-pagination-wrapper { min-width:0; max-width:100%; }
.crm-summary-pagination{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;min-width:0;width:100%}
.crm-summary-pagination-info{display:flex;align-items:center;flex-wrap:wrap;gap:8px 20px;min-width:0;max-width:100%;overflow-wrap:anywhere;white-space:normal}
.crm-summary-pagination-controls{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:8px 12px;min-width:0;max-width:100%;margin-left:auto}
.crm-summary-pagination-controls>.semi-table-pagination-info{min-width:0;white-space:normal;overflow-wrap:anywhere}
.crm-summary-pagination-controls>.semi-page{min-width:0;max-width:100%;flex-wrap:wrap}
.crm-responsive-table :is(.semi-page-total,.semi-page-switch) { flex:0 0 auto; }
.crm-responsive-table .semi-table-thead > .semi-table-row > .semi-table-row-head { border-right:1px solid var(--crm-border); }
.crm-responsive-table .react-resizable-handle { width:10px; right:-5px; cursor:col-resize; }
.crm-responsive-table .semi-table-fixed-left { box-shadow:5px 0 8px -8px #1f3a5f99; }
.crm-responsive-table .semi-space { max-width:100%; flex-wrap:wrap; }
.crm-responsive-table audio { max-width:100%; }

/* Narrow containers become labelled records, not squashed columns or hidden data. */
table.crm-auto-table[data-layout=cards],
.crm-responsive-table[data-layout=cards] table { display:block; }
table.crm-auto-table[data-layout=cards] colgroup,
.crm-responsive-table[data-layout=cards] colgroup { display:none; }
table.crm-auto-table[data-layout=cards] thead,
.crm-responsive-table[data-layout=cards] thead {
  display:block; position:relative; width:auto; height:auto; overflow:visible; clip-path:none;
}
table.crm-auto-table[data-layout=cards] thead tr,
.crm-responsive-table[data-layout=cards] thead tr { display:flex; flex-wrap:wrap; }
table.crm-auto-table[data-layout=cards] th:not([data-select=true]),
.crm-responsive-table[data-layout=cards] th {
  position:absolute; width:1px !important; height:1px; padding:0; border:0;
  overflow:hidden; clip-path:inset(50%); white-space:nowrap;
}
table.crm-auto-table[data-layout=cards] th[data-select=true] {
  position:static; display:flex; align-items:center; gap:8px; width:100% !important; padding:10px 12px;
}
table.crm-auto-table[data-layout=cards] th[data-select=true]::after { content:'选择本页'; }
table.crm-auto-table[data-layout=cards] tbody,
.crm-responsive-table[data-layout=cards] tbody { display:block; width:100%; }
table.crm-auto-table[data-layout=cards] tbody > tr,
.crm-responsive-table[data-layout=cards] tbody > tr {
  display:grid; grid-template-columns:minmax(0,1fr); gap:8px 16px;
  padding:12px; border-bottom:1px solid var(--crm-border); background:var(--crm-surface);
}
table.crm-auto-table[data-layout=cards][data-card-columns="2"] tbody > tr,
.crm-responsive-table[data-layout=cards][data-card-columns="2"] tbody > tr { grid-template-columns:repeat(2,minmax(0,1fr)); }
table.crm-auto-table[data-layout=cards] tbody > tr > td,
.crm-responsive-table[data-layout=cards] tbody > tr > td {
  display:block; width:auto !important; max-width:100%; min-width:0; height:auto;
  position:static; border:0; padding:0; text-align:left; box-shadow:none;
}
.crm-responsive-table[data-layout=cards] .semi-table-tbody > .semi-table-row > .semi-table-row-cell { padding:0; border:0; }
table.crm-auto-table[data-layout=cards] td[data-full-row=true],
.crm-responsive-table[data-layout=cards] td[colspan]:not([colspan="1"]) { grid-column:1 / -1; }
table.crm-auto-table[data-layout=cards] td[data-label]:not([data-label=""])::before,
.crm-responsive-table[data-layout=cards] td[data-label]:not([data-label=""])::before {
  content:attr(data-label); display:block; margin-bottom:3px;
  color:var(--crm-muted); font-size:var(--ui-caption-size); font-weight:400;
}
table.crm-auto-table[data-layout=cards] td[data-select=true] { grid-column:1 / -1; }
table.crm-auto-table[data-layout=cards] td[data-select=true]::after { content:'选择此记录'; margin-left:8px; color:var(--crm-muted); }
table.crm-auto-table[data-layout=cards] .sf-opportunity-row { padding-top:0; }
:is(.table-wrap,.lead-table-scroll,.sf-table-scroll,.catalog-table-scroll,.enterprise-scroll):has(> table[data-layout=cards]) { max-height:none; overflow:visible; }

/* Fluid forms/toolbars and contained drawers, without scaling down text. */
.page-root,.enterprise-tab-content { container-type:inline-size; }
.main-content,.page-root,.enterprise-tab-content,.modal-body,.crm-create-page { min-width:0; }
.page-tabs,.crm-stage-tabs,.lead-status-tabs,.enterprise-open-tabs { flex-wrap:wrap; }
.lead-status-tabs { max-width:100%; }
.lead-toolbar,.crm-search-row,.crm-advanced-row,.office-toolbar,.catalog-toolbar { max-width:100%; }
/* Keep team filters and their result/actions on one shared desktop row. */
.team-lead-toolbar-row { display:flex; flex-wrap:wrap; align-items:flex-start; gap:10px 16px; min-width:0; max-width:100%; margin-bottom:12px; }
.team-lead-toolbar-row > .team-lead-toolbar { flex:1 1 620px; min-width:0; margin:0; }
.team-lead-toolbar-row > .team-lead-toolbar-actions { display:flex; flex-wrap:wrap; align-items:center; gap:10px; min-width:0; min-height:36px; margin:0 0 0 auto; }
.lead-toolbar :is(input,select),.crm-search-row :is(input,select),.crm-advanced-row :is(input,select) { min-width:0; max-width:100%; }
/* Lead list filters stay compact at every width; wrap whole label/control groups. */
.lead-workspace > .lead-toolbar,
.team-lead-toolbar-row .lead-toolbar { gap:6px 8px; }
.lead-workspace > .lead-toolbar .lead-search,
.team-lead-toolbar .lead-search {
  flex:0 1 auto; flex-wrap:nowrap; width:auto; min-width:0; max-width:100%; gap:6px;
}
.lead-workspace > .lead-toolbar .lead-search input,
.team-lead-toolbar .team-lead-search input {
  width:100px; flex:0 1 100px; min-width:0; padding-inline:8px;
}
.lead-workspace > .lead-toolbar > select,
.team-lead-toolbar :is(#team-lead-call,#team-lead-tag,#team-lead-team,#team-lead-member) {
  field-sizing:content; flex:0 1 auto; width:auto; min-width:88px; max-width:100%; padding-inline:8px;
}
.team-lead-toolbar :is(#team-lead-team,#team-lead-member) { max-width:calc(100% - 34px); }
.lead-workspace > .lead-toolbar .secondary-btn,
.team-lead-toolbar-row .secondary-btn { padding-inline:8px; }
.team-lead-toolbar-row { gap:8px; }
/* Native and React captions share one in-flow prefix; no layout observers. */
.crm-field-caption { display:block; min-width:0; white-space:normal; overflow-wrap:anywhere; }
.crm-required-mark { display:inline-block; width:.7em; margin-inline-end:3px; color:var(--crm-required-color,#d93939); font:inherit; font-style:normal; line-height:inherit; vertical-align:baseline; }
.sf-field,.form-field,.enterprise-contact-inputs > * { min-width:0; }
.sf-field,.form-field,.enterprise-facts :is(dt,dd),.enterprise-contact-card,
.modal :is(label,legend),.office-modal :is(label,legend) { overflow-wrap:anywhere; }
.enterprise-contact-tools,.lead-custom-tag,.outbound-recipient { flex-wrap:wrap; }
.lead-custom-tag > label { min-width:0; }
.sf-field :is(input,select,textarea),.form-field :is(input,select,textarea) { width:100%; min-width:0; max-width:100%; }
.sf-field textarea,.form-field textarea { max-height:calc(2 * 1.8em + 18px); overflow:auto; field-sizing:fixed; }
/* Only new-record business text fields: one line initially, grow with all content. */
:is(.crm-lead-form,.crm-customer-form) :is(.sf-field,.form-field) textarea[data-auto-grow] {
  min-height:calc(1lh + 18px); height:auto; max-height:none; field-sizing:content;
  box-sizing:border-box; white-space:pre-wrap; overflow-wrap:anywhere; resize:vertical;
}
.sf-field :is(input[type=checkbox],input[type=radio]),.form-field :is(input[type=checkbox],input[type=radio]) { width:auto; flex:none; }
.sf-form-grid,.form-grid { grid-template-columns:repeat(auto-fit,minmax(min(240px,100%),1fr)); }
.form-field.full,.sf-full { grid-column:1 / -1; }
.modal,.office-modal { max-height:calc(100dvh - 24px); max-width:calc(100vw - 24px); }
.modal-header h3 { flex:1 1 0; min-width:0; overflow-wrap:anywhere; }
.modal-header .close { flex:none; display:inline-grid; place-items:center; min-width:36px; min-height:36px; }
.modal-footer { flex-wrap:wrap; }
.enterprise-tab-drawer { width:min(960px,100vw); left:auto; right:0; }
.enterprise-tab-bar { height:auto; min-height:48px; flex:none; align-items:flex-start; gap:8px; padding-block:7px; max-height:40dvh; overflow:auto; }
.enterprise-open-tabs { flex:1; overflow:visible; }
.enterprise-open-tab { height:auto; min-height:34px; min-width:0; max-width:100%; padding-block:6px; text-align:left; white-space:normal; overflow-wrap:anywhere; }
.enterprise-open-tab > span { min-width:0; overflow-wrap:anywhere; }
.enterprise-open-tab > i,.enterprise-drawer-close { flex:none; }
.enterprise-tab-content { min-height:0; }
.enterprise-header { align-items:flex-start; }
.enterprise-header h1,.sf-error,.outbound-settings-section h4 { overflow-wrap:anywhere; }
.outbound-task-actions { display:flex; flex-wrap:wrap; gap:8px; }
.outbound-modal .filter-tabs [aria-pressed=true] { background:var(--crm-header-bg); color:var(--crm-primary); border-color:var(--crm-control-hover); }
.lead-tag-option { white-space:normal; overflow:visible; }
.crm-mobile-menu,.crm-menu-backdrop { display:none; }
@container (max-width:700px) {
  .enterprise-summary,.crm-create-summary,.stats-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .enterprise-facts,.enterprise-contact-inputs { grid-template-columns:minmax(0,1fr); }
  .enterprise-facts > div { grid-template-columns:minmax(80px,30%) minmax(0,1fr); }
  .lead-toolbar > * { max-width:100%; }
}
@media(max-width:700px) {
  .sidebar { display:none; }
  .crm-mobile-menu { display:inline-flex; align-items:center; flex:none; }
  .crm-menu-open .sidebar { display:flex; position:fixed; inset:0 auto 0 0; width:min(260px,85vw); height:100dvh; z-index:1202; padding:18px 12px; }
  .crm-menu-open .crm-menu-backdrop { display:block; position:fixed; inset:0; width:100%; height:100dvh; z-index:1201; background:#172b4d55; border:0; }
  .crm-menu-open .sidebar .nav-item { font-size:var(--ui-text-size); justify-content:flex-start; padding:0 12px; }
  .crm-menu-open .sidebar .sub-nav.open:not([hidden]) { display:block !important; }
  .crm-menu-open .sidebar .nav-group-label:not([hidden]) { display:block !important; }
  .crm-menu-open .sidebar .nav-section-toggle { padding-block:10px; }
  .crm-menu-open .sidebar .nav-section-toggle > .nav-arrow { display:block; }
  .crm-menu-open .sidebar .brand-logo-frame { width:140px; }
  .crm-menu-open .sidebar .brand-logo { width:100%; height:auto; object-fit:contain; }
  .topbar .breadcrumb { flex:1 1 160px; }
  .lead-status-tabs { justify-content:flex-start; }
  .enterprise-tab-drawer { width:100%; }
  .enterprise-open-tabs { flex:1; gap:2px; }
  .enterprise-open-tab { white-space:normal; height:auto; min-height:34px; overflow-wrap:anywhere; }
  .page-root,.enterprise-tab-content { padding:16px 12px 28px; }
  .lead-toolbar :is(input,select) { flex:1 1 140px; }
}
.business-number{display:block;min-width:0;white-space:normal;overflow-wrap:anywhere;font:inherit;color:var(--muted,#64748b)}
/* Keep first-page feedback inside the viewport of a horizontally scrolling table. */
.lead-table-scroll .crm-loading-shell {
  width: max(0px, calc(var(--crm-table-host-width, 100%) - 32px));
  max-width: 100%;
  box-sizing: border-box;
}
/* Shared first-frame placeholders: no fabricated totals or blocking overlays. */
.crm-page-loading { width:100%; min-width:0; display:grid; gap:16px; color:var(--crm-ink,#263850); font-family:var(--ui-font,inherit); }
.crm-page-loading h1 { margin:0; font-size:var(--crm-page-title-size,20px); line-height:1.5; overflow-wrap:anywhere; }
.crm-page-loading p { margin:0; color:var(--crm-muted,#72819a); font-size:var(--ui-text-size,13px); overflow-wrap:anywhere; }
.crm-loading-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(160px,100%),1fr)); gap:12px; min-width:0; }
.crm-loading-summary>div,.crm-loading-table { min-width:0; background:var(--crm-surface,#fff); border:1px solid var(--crm-border,#e3e9f2); border-radius:var(--crm-card-radius,6px); padding:16px; }
.crm-loading-summary span { display:block; width:60%; max-width:100%; height:14px; margin-bottom:12px; background:var(--crm-header-bg,#f3f6fa); border-radius:4px; }
.crm-loading-summary span+span { width:35%; height:22px; margin-bottom:0; }
.crm-loading-table { display:grid; gap:16px; }
.crm-loading-filter { width:min(280px,100%); height:32px; background:var(--crm-header-bg,#f3f6fa); border-radius:4px; }
.crm-loading-line { height:30px; background:var(--crm-header-bg,#f3f6fa); border-radius:4px; }
.crm-embedded-host { position:relative; min-width:0; width:100%; }
.crm-frame-loading { position:absolute; inset:0 0 auto; min-width:0; background:var(--crm-page-bg,#f5f7fb); z-index:1; }
/* List selection feedback follows every business action and wraps as a group. */
.crm-selection-summary {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  flex:0 1 auto;
  gap:8px;
  min-width:0;
  max-width:100%;
  font:inherit;
}
.crm-selection-summary[hidden] {display:none}
.crm-selection-summary > span {
  min-width:0;
  color:var(--semi-color-text-1, var(--muted, #64748b));
  overflow-wrap:anywhere;
  white-space:normal;
}
.crm-selection-summary > button {
  flex:0 1 auto;
  min-width:0;
  max-width:100%;
  height:auto;
  min-height:32px;
  font-family:inherit;
  font-size:inherit;
  white-space:normal;
  overflow-wrap:anywhere;
}
.crm-selection-summary .semi-button-content {
  min-width:0;
  white-space:normal;
  overflow-wrap:anywhere;
}
/* Optional retention in the customer handover dialog. */
.crm-handover-modal .crm-handover-retention{display:flex;align-items:flex-start;gap:8px;margin-top:12px;min-width:0;cursor:pointer}
.crm-handover-modal .crm-handover-retention input{flex:0 0 16px;width:16px;height:16px;margin:3px 0 0}
.crm-handover-modal .crm-handover-retention span{min-width:0;white-space:normal;overflow-wrap:anywhere}

/* Visit statistics follow the actual page width, including narrow hosts. */
#sf-metrics {container-type:inline-size;container-name:sales-metrics;min-width:0}
.sf-workspace .sf-basic-metrics {grid-template-columns:repeat(8,minmax(0,1fr))}
.crm-customer-metrics {container-type:inline-size;container-name:customer-metrics;min-width:0}
.crm-stat-grid-visits {grid-template-columns:repeat(6,minmax(0,1fr))}
@container customer-metrics (max-width:1050px) {
  .crm-stat-grid-visits {grid-template-columns:repeat(3,minmax(0,1fr))}
}
@container customer-metrics (max-width:640px) {
  .crm-stat-grid-visits {grid-template-columns:repeat(2,minmax(0,1fr))}
}
@container customer-metrics (max-width:360px) {
  .crm-stat-grid-visits {grid-template-columns:minmax(0,1fr)}
}
@container sales-metrics (max-width:1450px) {
  .sf-workspace .sf-basic-metrics {grid-template-columns:repeat(4,minmax(0,1fr))}
}
@container sales-metrics (max-width:720px) {
  .sf-workspace .sf-basic-metrics {grid-template-columns:repeat(2,minmax(0,1fr))}
}
@container sales-metrics (max-width:360px) {
  .sf-workspace .sf-basic-metrics {grid-template-columns:minmax(0,1fr)}
}
/* Long employee names may wrap beyond one line without leaving the header. */
.topbar { height:auto;min-height:62px;padding-block:8px; }
