/*
  V1 UI polish
  Contains legacy modules whose cards/sub-tabs were wider than the content column.
  The goal is predictable containment without changing module business logic.
*/

#app,
#main,
.main,
.content,
.page-content,
[data-view],
[data-route] {
  min-width: 0;
  max-width: 100%;
}

#main *,
.main * {
  box-sizing: border-box;
}

.mod-hero,
.mod-help-banner,
.terrain-luxe-hero,
.aff-dashboard,
.kanban-board,
.sub-tabs,
.sales-sub-tabs,
.dir2-kpis,
.temps2-kpis,
.sal2-kpis,
.me2-kpis,
.cli2-kpis,
.aud-kpis,
.kpi-grid,
.planning-hero-kpis,
.aff-dashboard-kpis {
  max-width: 100%;
  min-width: 0;
}

.cli2-kpis,
.dir2-kpis,
.temps2-kpis,
.sal2-kpis,
.me2-kpis,
.aud-kpis,
.kpi-grid,
.planning-hero-kpis,
.aff-dashboard-kpis {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
  gap: 12px !important;
}

.cli2-kpi,
.dir2-kpi,
.temps2-kpi,
.sal2-kpi,
.me2-kpi,
.aud-kpi,
.kpi-card,
.planning-hero-kpi,
.aff-dashboard-kpi {
  min-width: 0 !important;
  max-width: 100%;
  overflow: hidden;
}

.cli2-kpi *,
.dir2-kpi *,
.temps2-kpi *,
.sal2-kpi *,
.me2-kpi *,
.aud-kpi *,
.kpi-card *,
.planning-hero-kpi *,
.aff-dashboard-kpi *,
.mod-hero *,
.terrain-luxe-hero * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sub-tabs,
.sales-sub-tabs {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  white-space: nowrap;
}

.kanban-board,
.aff-dashboard {
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
}

#main table,
.main table {
  max-width: 100%;
}

#main th,
#main td,
.main th,
.main td {
  overflow-wrap: anywhere;
}

#main iframe,
.main iframe {
  max-width: 100%;
}

.icon-btn,
.ai-fab {
  flex: 0 0 auto;
  overflow: hidden !important;
  line-height: 1;
  white-space: nowrap;
}

.icon-btn {
  min-width: 44px !important;
}

.ai-fab {
  min-width: 58px !important;
}

@media (max-width: 900px) {
  .mod-hero,
  .terrain-luxe-hero {
    padding-inline: 16px !important;
  }

  .cli2-kpis,
  .dir2-kpis,
  .temps2-kpis,
  .sal2-kpis,
  .me2-kpis,
  .aud-kpis,
  .kpi-grid,
  .planning-hero-kpis,
  .aff-dashboard-kpis {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)) !important;
  }
}
