/* Bersa Inventory — mobile layout + frozen headings */

/* Avoid overflow ancestors killing position:sticky on iOS Safari */
.fi-body,
.fi-layout,
.fi-main,
.fi-main-ctn,
.fi-page {
  overflow: visible !important;
}

/* Keep topbar pinned (Filament already sticky; harden on iOS overflow parents) */
.fi-topbar {
  position: sticky !important;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
  background-color: rgba(250, 250, 249, 0.94);
}

.dark .fi-topbar {
  background-color: rgba(12, 10, 9, 0.94);
}

/* Freeze page title + header actions while content scrolls */
.fi-header {
  position: sticky;
  top: 3.75rem; /* below topbar */
  z-index: 30;
  margin-inline: -0.25rem;
  padding: 0.75rem 0.25rem 0.85rem;
  background-color: rgb(var(--gray-50));
  border-bottom: 1px solid rgba(120, 113, 108, 0.18);
}

.dark .fi-header {
  background-color: rgb(var(--gray-950));
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

@supports (color: color-mix(in oklab, white 50%, black)) {
  .fi-header {
    background-color: color-mix(in oklab, rgb(var(--gray-50)) 92%, transparent);
  }
  .dark .fi-header {
    background-color: color-mix(in oklab, rgb(var(--gray-950)) 92%, transparent);
  }
}

/* Compact page heading on phones */
@media (max-width: 640px) {
  .fi-header {
    top: 3.5rem;
    gap: 0.65rem !important;
    padding-top: 0.5rem;
    padding-bottom: 0.65rem;
  }

  .fi-header-heading {
    font-size: 1.25rem !important;
    line-height: 1.3 !important;
  }

  .fi-header .fi-ac {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .fi-header .fi-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Dashboard widgets: full-bleed readable cards */
  .fi-wi-widget {
    min-width: 0;
  }

  .fi-wi-chart {
    overflow: visible;
  }

  .fi-wi-chart-horizontal > .fi-section {
    overflow: visible;
  }

  /* Stats overview: stack cleanly */
  .fi-wi-stats-overview-stats-ctn {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.65rem !important;
  }

  /* Tables: allow horizontal scroll without crushing columns */
  .fi-ta-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .fi-ta-table {
    min-width: 36rem;
  }

  /* Forms: avoid sideways overflow */
  .fi-fo-component-ctn,
  .fi-section-content {
    min-width: 0;
  }

  .fi-main > .fi-page {
    padding-inline: 0.75rem;
  }
}

/* Sticky table column headers (all list/report tables) */
.fi-ta-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

.fi-ta-table thead th,
.fi-ta-header-cell {
  background-color: rgb(var(--gray-50)) !important;
  box-shadow: inset 0 -1px 0 rgba(120, 113, 108, 0.18);
}

.dark .fi-ta-table thead th,
.dark .fi-ta-header-cell {
  background-color: rgb(var(--gray-900)) !important;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

/* When the table scrolls inside its own container, stick under the sticky page header */
@media (max-width: 640px) {
  .fi-ta-content {
    max-height: min(70vh, 36rem);
  }

  .fi-ta-table thead {
    top: 0;
  }
}

/* Chart canvas height for horizontal bars */
.fi-wi-chart .chartjs-render-monitor,
.fi-wi-chart canvas {
  max-height: none !important;
}
