/*
  Stage 105.3K CLEAN — Old / Partially Treated Page Group Cleanup v1
  Built cleanly from confirmed Stage 105.3J CLEAN.

  Scope:
  - Controlled visual cleanup for older/partially treated top-level page groups.
  - Focuses on legacy cards, panels, filter/tool rows, form sections, tabs and
    empty/loading surfaces that still looked older than the new UI v2 pages.

  Safety:
  - Frontend CSS-only visual layer plus a marker script.
  - No backend, database, API, route, popup behaviour, app.js, save logic,
    Billing/SageOne runtime, RADIUS runtime, prepaid execution, product backend,
    customer package/speed, Asset Register backend, Job Cards, Calendar, Android,
    workers, tracking, or protected-module logic changes.
  - Protects Customer 360 tabbed profile, menus/dropdowns, customer search
    pickers, modals/popups, sidebar/page offset, table readability and buttons.
*/

:root{
  --ui1053k-text: #0f172a;
  --ui1053k-muted: #526173;
  --ui1053k-muted-2: #64748b;
  --ui1053k-border: rgba(148,163,184,.25);
  --ui1053k-border-strong: rgba(37,99,235,.18);
  --ui1053k-panel: rgba(255,255,255,.965);
  --ui1053k-panel-soft: rgba(248,250,252,.92);
  --ui1053k-panel-softer: rgba(241,245,249,.78);
  --ui1053k-shadow: 0 10px 26px rgba(15,23,42,.055);
  --ui1053k-shadow-soft: 0 6px 18px rgba(15,23,42,.04);
  --ui1053k-radius: 17px;
  --ui1053k-radius-sm: 13px;
  --ui1053k-accent: #2563eb;
  --ui1053k-accent-soft: rgba(37,99,235,.075);
  --ui1053k-teal-soft: rgba(20,184,166,.075);
}

html.stage1053k-old-page-cleanup body:is(
  .ispforge-ui-v2-setup-tools-professional-active,
  .ispforge-ui-v2-billing-professional-active,
  .ispforge-ui-v2-reports-professional-active,
  .ispforge-ui-v2-customer-directory-professional-active,
  .ispforge-ui-v2-devices-assets-professional-active,
  .ispforge-ui-v2-rpp-professional-active,
  .ispforge-ui-v2-ops-professional-active,
  .ispforge-ui-v2-setup-tools-active,
  .ispforge-ui-v2-billing-reports-active,
  .ispforge-ui-v2-customer-directory-active
) #app-screen > main#page.page{
  color: var(--ui1053k-text);
}

/* Legacy/older content cards and panels.
   Keep the selector inside #page and avoid navigation, modals, Customer 360 and
   customer search pickers. */
html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(
  .card,
  .panel,
  .box,
  .widget,
  .well,
  .setup-card,
  .settings-card,
  .admin-card,
  .tools-card,
  .report-card,
  .billing-card,
  .device-card,
  .asset-card,
  .product-card,
  .radius-card,
  .prepaid-card,
  .legacy-card,
  .stage-card,
  .content-card,
  .section-card,
  .form-panel,
  .list-panel,
  .table-panel,
  .detail-panel
):not(.stage822-card):not(.stage1052c-panel):not(.stage1052c-tabbed-profile):not(.modal):not(.modal-content):not(.popup):not(.dialog):not(.stage833-result):not(.stage833-results):not(.stage831-dropdown):not(.submenu-bar){
  box-sizing: border-box;
  border-color: var(--ui1053k-border) !important;
  border-radius: var(--ui1053k-radius) !important;
  background: var(--ui1053k-panel) !important;
  color: var(--ui1053k-text) !important;
  box-shadow: var(--ui1053k-shadow-soft);
}

/* Make old section headings feel related across modules without changing text. */
html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(
  .card-header,
  .panel-header,
  .section-header,
  .box-header,
  .widget-header,
  .settings-section-header,
  .setup-section-header,
  .table-header,
  .list-header
):not(.stage822-card-head):not(.stage1052c-tab-header):not(.modal-header):not(.popup-header){
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(148,163,184,.20);
}

html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(
  .card-header,
  .panel-header,
  .section-header,
  .box-header,
  .widget-header,
  .settings-section-header,
  .setup-section-header,
  .table-header,
  .list-header
):not(.stage822-card-head):not(.stage1052c-tab-header):not(.modal-header):not(.popup-header) :is(h1,h2,h3,h4,.title,.card-title,.panel-title,.section-title){
  margin: 0 !important;
  color: var(--ui1053k-text) !important;
  -webkit-text-fill-color: var(--ui1053k-text) !important;
  font-weight: 900 !important;
  letter-spacing: -.018em;
  line-height: 1.18;
}

/* Field and filter blocks on older pages. */
html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(
  .filters,
  .filter-bar,
  .filter-row,
  .filter-grid,
  .search-row,
  .toolbar,
  .table-toolbar,
  .action-row,
  .actions-row,
  .form-grid,
  .form-row,
  .field-grid,
  .settings-grid,
  .setup-grid,
  .admin-grid,
  .tools-grid
):not(.stage1052c-tab-list):not(.stage833-search-wrap):not(.stage831-dropdown):not(.submenu-bar):not(.modal *){
  box-sizing: border-box;
  gap: 10px 12px;
  align-items: end;
  max-width: 100%;
}

html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.filters,.filter-bar,.filter-row,.search-row,.table-toolbar):not(.stage833-search-wrap):not(.modal *){
  border: 1px solid rgba(148,163,184,.20);
  border-radius: var(--ui1053k-radius-sm);
  background: linear-gradient(135deg, var(--ui1053k-panel-soft), rgba(255,255,255,.88));
  padding: 12px;
  box-shadow: 0 5px 14px rgba(15,23,42,.035);
}

/* Legacy tabs/navs inside content pages only, not top menus or Customer 360. */
html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.tabs,.tab-bar,.tab-row,.nav-tabs):not(.stage1052c-tab-list):not(.submenu-bar):not(.stage831-dropdown){
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px;
  border: 1px solid rgba(148,163,184,.20);
  border-radius: 15px;
  background: rgba(241,245,249,.78);
}

html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.tabs,.tab-bar,.tab-row,.nav-tabs):not(.stage1052c-tab-list):not(.submenu-bar):not(.stage831-dropdown) :is(button,a,.tab){
  border-radius: 999px;
}

/* Small status/empty/loading blocks that still appeared flat on legacy pages. */
html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(
  .empty,
  .empty-state,
  .loading,
  .notice,
  .info-box,
  .warning-box,
  .error-box,
  .success-box,
  .message,
  .callout
):not(.stage833-result):not(.modal *):not(.popup *){
  border-radius: var(--ui1053k-radius-sm);
  border: 1px solid rgba(148,163,184,.22);
  background: var(--ui1053k-panel-soft);
  color: var(--ui1053k-text);
  padding: 12px 14px;
}

html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.muted,.hint,.help-text,.description,.small,.subtle,.secondary-text):not(.stage1052c-tab-title *):not(.stage833-result *){
  color: var(--ui1053k-muted) !important;
  -webkit-text-fill-color: var(--ui1053k-muted) !important;
}

/* Inputs in older panels: keep popup readability layer untouched. */
html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.card,.panel,.box,.widget,.legacy-card,.stage-card,.content-card):not(.stage822-card):not(.stage1052c-panel):not(.modal):not(.popup) :is(input,select,textarea){
  max-width: 100%;
  border-color: rgba(148,163,184,.34);
}

html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.card,.panel,.box,.widget,.legacy-card,.stage-card,.content-card):not(.stage822-card):not(.stage1052c-panel):not(.modal):not(.popup) :is(label,.form-label,.field-label){
  color: #334155 !important;
  font-weight: 800;
}

/* Grid/card rows: make older pages consistent without masonry or absolute sizing. */
html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(
  .cards,
  .card-grid,
  .grid-cards,
  .summary-grid,
  .stats-grid,
  .module-grid,
  .tile-grid,
  .dashboard-grid
):not(.stage822-grid):not(.stage1052c-panel-grid){
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 14px;
  align-items: stretch;
}

/* Table wrappers on older pages should not look cramped after the page shell fix. */
html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.table-wrap,.table-wrapper,.data-table-wrap,.list-table-wrap):not(.stage1052c-panel *){
  border-radius: var(--ui1053k-radius);
  border: 1px solid rgba(148,163,184,.23);
  background: rgba(255,255,255,.94);
  box-shadow: var(--ui1053k-shadow-soft);
  overflow: auto;
}

/* Final protection for navigation, dropdowns, popups and Customer 360. */
html.stage1053k-old-page-cleanup :is(
  #sidebar,
  .sidebar,
  .side-nav,
  #top-menu,
  .top-menu,
  .stage831-dropdown,
  .submenu-bar,
  .stage1052c-tabbed-profile,
  .stage1052c-tab-list,
  .stage1052c-panel,
  .stage822-card,
  .stage833-search-wrap,
  .stage833-results,
  .stage833-result,
  .modal,
  .modal-content,
  .popup,
  .dialog,
  .stage822-modal
){
  /* Keep previous confirmed modules authoritative here. */
}

@media (max-width: 900px){
  html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.card-header,.panel-header,.section-header,.box-header,.widget-header,.table-header,.list-header):not(.stage1052c-tab-header):not(.modal-header):not(.popup-header){
    align-items: flex-start;
  }
  html.stage1053k-old-page-cleanup #app-screen > main#page.page :is(.filters,.filter-bar,.filter-row,.search-row,.table-toolbar):not(.stage833-search-wrap):not(.modal *){
    padding: 10px;
  }
}
