/* BLACK X — Batch 4 data-heavy interface foundation
   Scope: CRM, Reports, Data Center and Team Performance only. */

.bx-data-foundation-page {
  --bx-data-edge-gold: rgba(218, 184, 102, .34);
  --bx-data-edge-silver: rgba(214, 220, 230, .22);
  --bx-data-glass: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.015));
  --bx-data-shadow: 0 18px 42px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.045), inset 1px 0 0 rgba(218,184,102,.025);
  --bx-data-filter-min: 220px;
  --bx-data-form-min: 250px;
  --bx-data-card-min: 245px;
  --bx-data-kpi-min: 160px;
}

.bx-data-foundation-page :is(.crm-board,.crm-card,.crm-form,.crm-subsection,.crm-relation-grid>article,.crm-detail-aside>article,.crm-task-board>article,.report-kpi-card,.report-module-card,.report-filter-bar,.report-freshness,.report-note,.report-table-wrap,.portal-card,.relation-card,.crud-form-panel,.planning-panel,.ownership-scope-panel,.crud-detail-card,.management-panel,.organization-dashboard-card,.organization-filter) {
  border: 1px solid var(--bx-data-edge-silver);
  border-top-color: var(--bx-data-edge-gold);
  border-radius: 14px;
  background: var(--bx-data-glass);
  box-shadow: var(--bx-data-shadow);
  backdrop-filter: blur(12px) saturate(112%);
  -webkit-backdrop-filter: blur(12px) saturate(112%);
}

.bx-data-foundation-page :is(.crm-board,.crm-card,.crm-form,.crm-subsection,.crm-relation-grid>article,.crm-detail-aside>article,.crm-task-board>article,.report-kpi-card,.report-module-card,.portal-card,.relation-card,.crud-detail-card,.organization-dashboard-card) {
  min-width: 0;
}

/* Container-aware filters: never force narrow fields just because the viewport is wide. */
.bx-data-foundation-page .bx-data-filter-grid,
.bx-data-foundation-page .crm-filters,
.bx-data-foundation-page .report-filter-bar,
.bx-data-foundation-page .organization-dashboard-filter {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--bx-data-filter-min)), 1fr)) !important;
  gap: 12px !important;
  align-items: end;
}

.bx-data-foundation-page :is(.crm-filters label,.report-filter-bar label,.organization-dashboard-filter .organization-field) {
  min-width: 0 !important;
  width: 100%;
}

.bx-data-foundation-page :is(.crm-input,.report-filter-bar input,.report-filter-bar select,.report-filter-scope,.organization-dashboard-filter input,.organization-dashboard-filter select,.organization-dashboard-filter textarea,.crud-field input,.crud-field select,.crud-field textarea) {
  width: 100% !important;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.bx-data-foundation-page :is(.crm-filters .btn,.report-filter-bar .btn,.organization-dashboard-filter .btn) {
  min-height: 42px;
  justify-content: center;
}

/* Forms use the available section width rather than fixed 2/3-column breakpoints. */
.bx-data-foundation-page :is(.crm-form-grid,.crud-form-grid) {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--bx-data-form-min)), 1fr)) !important;
  gap: 14px !important;
}

.bx-data-foundation-page :is(.crm-field-wide,.crud-field-wide) {
  grid-column: 1 / -1;
}

/* Compact data cards, but with a practical minimum width. */
.bx-data-foundation-page :is(.crm-card-grid,.crm-dashboard-grid,.crm-module-grid,.crm-relation-grid,.crm-task-board,.report-module-grid,.portal-grid.data-module-grid,.relation-grid,.crud-detail-grid,.organization-dashboard-grid) {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--bx-data-card-min)), 1fr)) !important;
  gap: 12px !important;
}

.bx-data-foundation-page :is(.crm-metric-grid,.report-kpi-grid) {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--bx-data-kpi-min)), 1fr)) !important;
  gap: 10px !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.bx-data-foundation-page .crm-metric-grid article {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--bx-data-edge-silver);
  border-top-color: var(--bx-data-edge-gold);
  border-radius: 12px;
  background: var(--bx-data-glass);
  box-shadow: var(--bx-data-shadow);
}

.bx-data-foundation-page :is(.crm-metric-grid strong,.report-kpi-value,.organization-dashboard-card strong) {
  font-size: clamp(1.15rem, 2vw, 1.55rem) !important;
  line-height: 1.1;
}

.bx-data-foundation-page :is(.crm-board,.crm-card,.crm-subsection,.report-kpi-card,.report-module-card,.portal-card,.relation-card,.crud-detail-card,.organization-dashboard-card) {
  padding: 14px !important;
}

.bx-data-foundation-page .crm-module-grid>a {
  min-height: 150px !important;
  padding: 16px !important;
  border-radius: 14px;
}

.bx-data-foundation-page .crm-card {
  gap: 10px !important;
}

.bx-data-foundation-page .crm-card dl>div,
.bx-data-foundation-page .crm-detail-aside dl>div,
.bx-data-foundation-page .crm-task-board dl>div {
  grid-template-columns: minmax(78px,.72fr) minmax(0,1.28fr) !important;
  gap: 8px !important;
  padding: 6px 0 !important;
}

.bx-data-foundation-page .bx-data-more {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(214,220,230,.12);
  margin-top: 2px;
  padding-top: 7px;
}

.bx-data-foundation-page .bx-data-more > summary {
  cursor: pointer;
  color: var(--color-gold-light, #e0c37c);
  font-size: .78rem;
  font-weight: 700;
}

.bx-data-foundation-page .bx-data-more > div {
  display: grid;
  grid-template-columns: minmax(78px,.72fr) minmax(0,1.28fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(214,220,230,.08);
}

.bx-data-foundation-page .bx-data-more dt { color: var(--color-text-dim); font-size: var(--text-sm); }
.bx-data-foundation-page .bx-data-more dd { margin: 0; color: var(--color-white-soft); overflow-wrap: anywhere; }

/* Dashboard density */
.bx-data-foundation-page .crm-dashboard-grid { align-items: start; }
.bx-data-foundation-page .crm-panel-head { margin-bottom: 12px !important; }
.bx-data-foundation-page .crm-stage-strip article,
.bx-data-foundation-page .crm-compact-list>a,
.bx-data-foundation-page .crm-compact-list>article { padding: 9px 0 !important; }
.bx-data-foundation-page .crm-stage-column article { padding: 12px !important; gap: 12px !important; }
.bx-data-foundation-page .crm-task-board>article p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Detail pages: keep hierarchy clear and prevent side rail from becoming too narrow. */
.bx-data-foundation-page .crm-detail-layout {
  grid-template-columns: minmax(0, 1.55fr) minmax(min(100%, 290px), .62fr) !important;
  gap: 16px !important;
}
.bx-data-foundation-page .crm-detail-layout main,
.bx-data-foundation-page .crm-detail-aside { gap: 14px !important; min-width: 0; }
.bx-data-foundation-page .crm-stage-banner { grid-template-columns: minmax(150px,.8fr) minmax(150px,1.4fr) minmax(150px,.7fr) !important; }

/* Analytical tables own their horizontal overflow; the page does not. */
.bx-data-foundation-page :is(.crm-report-table,.report-table-wrap) {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
}
.bx-data-foundation-page .crm-report-row { min-width: 680px !important; }
.bx-data-foundation-page .report-table { min-width: 640px; }
.bx-data-foundation-page :is(.crm-report-row>*,.report-table th,.report-table td) {
  padding: 9px 10px !important;
  font-size: .82rem !important;
}

/* Reports */
.bx-data-foundation-page .report-page-head { padding-block: 24px 10px; }
.bx-data-foundation-page .report-filter-bar { padding: 13px !important; }
.bx-data-foundation-page .report-filter-bar label { min-width: 0 !important; }
.bx-data-foundation-page .report-freshness,
.bx-data-foundation-page .report-note { padding: 10px 12px !important; }
.bx-data-foundation-page .report-kpi-grid,
.bx-data-foundation-page .report-module-grid { margin-top: 14px !important; }
.bx-data-foundation-page .report-section { margin-top: 18px !important; }

/* Data Center: reduce editorial bulk and make operational destinations scannable. */
.bx-data-center-page .page-hero { padding-bottom: 26px; }
.bx-data-center-page .page-lead,
.bx-data-center-page .page-summary { max-width: 78ch; }
.bx-data-center-page .portal-card-copy,
.bx-data-center-page .relation-card p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bx-data-center-page .module-badge-row { gap: 6px; }
.bx-data-center-page .crud-card-actions { gap: 7px; flex-wrap: wrap; }
.bx-data-center-page .crud-form-layout { gap: 16px !important; }

/* Team performance */
.bx-team-performance-page .organization-dashboard-grid { margin-top: 14px; }
.bx-team-performance-page .organization-dashboard-card { min-height: 112px; }
.bx-team-performance-page .organization-dashboard-filter { padding: 13px !important; }
.bx-team-performance-page .organization-dashboard-filter-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }

/* Protect available section width on all data-heavy pages. */
.bx-data-foundation-page .container,
.bx-data-foundation-page :is(section,article,aside,main,form,fieldset,div,label) { min-width: 0; }
.bx-data-foundation-page :is(input,select,textarea,button,a) { max-width: 100%; }

@media (max-width: 920px) {
  .bx-data-foundation-page { --bx-data-filter-min: 205px; --bx-data-form-min: 225px; --bx-data-card-min: 220px; }
  .bx-data-foundation-page .crm-detail-layout { grid-template-columns: 1fr !important; }
  .bx-data-foundation-page .crm-detail-aside { grid-template-columns: repeat(auto-fit,minmax(min(100%,220px),1fr)); }
  .bx-data-foundation-page .crm-stage-banner { grid-template-columns: 1fr !important; }
}

@media (max-width: 620px) {
  .bx-data-foundation-page { --bx-data-filter-min: 100%; --bx-data-form-min: 100%; --bx-data-card-min: 100%; --bx-data-kpi-min: 135px; }
  .bx-data-foundation-page :is(.crm-board,.crm-card,.crm-form,.crm-subsection,.crm-relation-grid>article,.crm-detail-aside>article,.crm-task-board>article,.report-kpi-card,.report-module-card,.portal-card,.relation-card,.crud-form-panel,.planning-panel,.ownership-scope-panel,.crud-detail-card,.management-panel,.organization-dashboard-card) { border-radius: 12px; }
  .bx-data-foundation-page .crm-score { min-width: 0; width: 100%; }
  .bx-data-foundation-page .crm-report-row { min-width: 620px !important; }
  .bx-data-foundation-page .report-table { min-width: 580px; }
}

@media print {
  .bx-report-data-page .report-filter-bar,
  .bx-report-data-page .report-export-row { display: none !important; }
  .bx-report-data-page .report-table-wrap { overflow: visible !important; box-shadow: none !important; border: 0 !important; }
}
