/* Shared small-screen layout. Desktop rules remain in the existing stylesheets. */
.dip-mobile-cards { display: none; }
@media (max-width: 760px) {
  html, body { min-width: 0; }
  body:has(.app-shell.mobile-nav-open) { overflow: hidden; }
  .app-shell, .app-shell .main-area, .app-shell .page-content { min-width: 0; max-width: 100%; }
  .app-shell .main-area, .app-shell.nav-collapsed .main-area,
  .app-shell:not(.nav-collapsed) .main-area { width: 100%; margin-left: 0 !important; }
  .app-shell .sidebar, .app-shell.nav-collapsed .sidebar,
  .app-shell:not(.nav-collapsed) .sidebar {
    position: fixed !important; inset: 0 auto 0 0; width: min(84vw, 300px) !important;
    max-width: 300px; min-width: 0 !important; padding: 12px 10px; transform: translateX(-105%);
    transition: transform .2s ease; z-index: 51 !important; overflow-x: hidden;
  }
  .app-shell .sidebar.open, .app-shell.nav-collapsed .sidebar.open {
    transform: translateX(0);
  }
  .app-shell.nav-collapsed .sidebar.open .brand-copy,
  .app-shell.nav-collapsed .sidebar.open .nav-item > span:not(.nav-icon),
  .app-shell.nav-collapsed .sidebar.open .nav-heading-text,
  .app-shell.nav-collapsed .sidebar.open .cloud-status,
  .app-shell .sidebar.open .brand-copy,
  .app-shell .sidebar.open .station-switch #stationLabel,
  .app-shell .sidebar.open .station-switch .chevron,
  .app-shell .sidebar.open .nav-heading .nav-heading-text,
  .app-shell .sidebar.open .nav-section-chevron,
  .app-shell .sidebar.open .sidebar-bottom .cloud-status,
  .app-shell .sidebar.open .sidebar-bottom .nav-link span:last-child { display: initial !important; }
  .app-shell .sidebar.open .nav-section-items:not([hidden]) { display: block !important; }
  .app-shell .sidebar.open .nav-group, .app-shell .sidebar.open .nav-heading,
  .app-shell .sidebar.open .station-switch, .app-shell .sidebar.open .nav-dashboard .nav-item { width: 100% !important; justify-content: flex-start; }
  .app-shell .sidebar.open .nav-dashboard .nav-item { font-size: 13px !important; }
  .app-shell .sidebar .nav-section-items.flyout:not([hidden]) {
    position: static; width: auto; max-height: none; box-shadow: none; border: 0;
  }
  .sidebar-scrim.show { display: block; z-index: 50; }
  .app-shell .topbar, .app-shell:has(.admin-dashboard) .topbar {
    display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px; height: auto; min-height: 0; padding: 8px 12px;
    align-items: center;
  }
  .app-shell .mobile-menu {
    display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
    border: 1px solid var(--line); border-radius: 9px; background: white;
    color: var(--forest); font-size: 22px; display: grid !important;
  }
  .app-shell .header-brand-logo { display: none !important; }
  .app-shell .top-title, .app-shell:has(.admin-dashboard) .topbar .top-title {
    display: flex; grid-column: 2; grid-row: 1; min-width: 0; width: 100%; margin: 0;
  }
  .app-shell .top-title strong { max-width: 100%; font-size: 15px; }
  .app-shell .top-actions { grid-column: 3; grid-row: 1; justify-self: end; margin: 0; }
  .app-shell .top-actions .profile { min-width: 44px; min-height: 44px; }
  .app-shell .header-business-controls {
    grid-column: 1 / -1; grid-row: 2; display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px 52px;
    gap: 6px; min-width: 0; width: 100%; margin: 0;
  }
  .app-shell .header-business-controls input,
  .app-shell .header-business-controls select,
  .app-shell .header-business-controls > .date-display-control {
    width: 100%; min-width: 0; max-width: 100%; height: 44px; flex: auto;
    font-size: 13px;
  }
  .app-shell .header-business-controls > .date-display-control .date-display-text,
  .app-shell .header-business-controls > .date-display-control .date-source-control { height: 44px; }
  .app-shell .header-tool-btn { width: 100%; min-width: 0; height: 44px; padding: 0 4px; }
  .app-shell .header-print-btn { display: block; font-size: 11px; }
  .app-shell .global-search, .app-shell.dashboard-active .global-search {
    grid-column: 1 / -1; grid-row: 3; width: 100%; min-width: 0; max-width: none;
    margin: 0;
  }
  .app-shell .global-search input { width: 100%; height: 44px; font-size: 14px; }
  .app-shell .page-content { padding: 14px 12px 28px; }
  .app-shell .page-content > *, .app-shell .panel, .app-shell .panel-head,
  .app-shell .panel-body, .app-shell .page-heading, .app-shell .table-panel,
  .app-shell .admin-dashboard, .app-shell .admin-dash-grid,
  .app-shell .admin-dash-panel { min-width: 0; max-width: 100%; }
  .app-shell .page-heading, .app-shell .panel-head { flex-wrap: wrap; gap: 10px; }
  .app-shell .heading-actions, .app-shell .table-toolbar,
  .app-shell .filter-row, .app-shell .dialog-actions { min-width: 0; flex-wrap: wrap; }
  .app-shell .heading-actions .btn, .app-shell .table-toolbar > *,
  .app-shell .filter-row > * { min-width: 0; }
  .app-shell .heading-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-shell .heading-actions .btn { width: 100%; height: auto; min-height: 44px; padding: 8px; white-space: normal; line-height: 1.25; }
  .app-shell .search-box, .app-shell #tableSearch { width: 100%; flex: 1 1 100%; }
  .app-shell .form-grid, .app-shell .form-grid.two-col,
  #recordDialog #recordFields.form-grid, .app-shell .branding-grid,
  .app-shell .detail-grid, .app-shell .settlement-metrics,
  .app-shell .admin-dashboard .admin-kpis, .app-shell .admin-dashboard .admin-dash-grid,
  .app-shell .dash-breakup-grid, .app-shell .module-shortcuts {
    grid-template-columns: minmax(0, 1fr);
  }
  .app-shell .form-grid > *, .app-shell .field,
  .app-shell .field input, .app-shell .field select, .app-shell .field textarea,
  .app-shell .filter-row .field { min-width: 0; max-width: 100%; width: 100%; }
  .app-shell .field input, .app-shell .field select,
  .app-shell .filter-row input, .app-shell .filter-row select,
  .app-shell .btn, .app-shell .row-action,
  .app-shell .density-view-tabs button { min-height: 44px; }
  .app-shell .admin-dashboard .admin-operations { grid-template-columns: minmax(0, 1fr); }
  .app-shell .table-wrap { display: block; width: 100%; max-width: 100%; min-width: 0;
    overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
  .app-shell .table-wrap table { width: max-content !important; min-width: 760px; }
  .app-shell .table-foot { display: flex; flex-wrap: wrap; gap: 10px; }
  .app-shell .pagination { max-width: 100%; flex-wrap: wrap; }
  dialog.dialog, #recordDialog.dialog, #recordDialog.dialog.wide-dialog,
  #recordDialog.dialog.sale-entry-dialog {
    width: calc(100vw - 20px); max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px); margin: auto; padding: 14px;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  }
  dialog.dialog .dialog-actions { display: flex; gap: 8px; }
  dialog.dialog .dialog-actions .btn { flex: 1 1 125px; min-width: 0; }
  .app-shell .density-view-tabs { max-width: 100%; overflow-x: auto; }
  .app-shell .table-wrap:has(.dip-history-table) { display: none; }
  .dip-mobile-cards { display: grid; gap: 10px; padding: 10px; }
  .dip-mobile-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  .dip-mobile-card-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
  .dip-mobile-card-head strong { display: block; font-size: 16px; color: var(--forest); }
  .dip-mobile-card-head span:not(.status-pill) { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
  .dip-mobile-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
  .dip-mobile-values > div { min-width: 0; padding: 8px; border-radius: 8px; background: #f5f8f5; }
  .dip-mobile-values small { display: block; font-size: 12px; color: #54675c; }
  .dip-mobile-values b { display: block; margin-top: 3px; font-size: 14px; overflow-wrap: anywhere; }
  .dip-mobile-card-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
  .dip-mobile-card-actions .btn { min-width: 0; padding: 4px; font-size: 12px; }
}

@media (max-width: 390px) {
  .app-shell .header-business-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; }
  .app-shell .header-print-btn { grid-column: 1 / -1; }
}

@media (min-width: 761px) {
  .app-shell .mobile-menu { display: none; }
}
