/* Apex Legal ERP — Phase 2C UI foundation
   Shared stacking, readability, focus and scroll primitives.
   This file intentionally avoids module-specific layout redesign. */
:root{
  --apex-z-base:1;
  --apex-z-sticky:20;
  --apex-z-dock:60;
  --apex-z-mobile-nav:650;
  --apex-z-sidebar:700;
  --apex-z-profile:800;
  --apex-z-overlay:1000;
  --apex-z-modal:1100;
  --apex-z-nested-modal:1200;
  --apex-z-popover:1300;
  --apex-z-toast:1400;
  --apex-z-priority:1500;
  --apex-text-micro:10px;
  --apex-text-small:11px;
  --apex-text-base:12px;
  --apex-focus:#0f8090;
  --apex-scroll-thumb:#9eb3bf;
  --apex-scroll-track:#edf3f6;
}

html{scrollbar-gutter:stable}
body{overflow-wrap:anywhere}
button,input,select,textarea{font:inherit}
button,[role="button"],a[href],input,select,textarea{touch-action:manipulation}

/* Consistent keyboard focus without changing mouse/pointer appearance. */
:where(button,a[href],input,select,textarea,[tabindex]):focus-visible{
  outline:3px solid color-mix(in srgb,var(--apex-focus) 34%,transparent);
  outline-offset:2px;
}

/* Shared, quiet scrollbars for legal registers and popup workspaces. */
:where(.register,.ledger-viewport,.modal-card,.apex-global-card,.notice-editor-shell,
       .case-ops-sheet,.ce-sheet,.ch-sheet,.scan-settings-panel,.sq-panel,
       .record-popup-body,.selection-body,.wq-dashboard,.case-drilldown,
       .register-drilldown,.pe-table-wrap){
  scrollbar-width:thin;
  scrollbar-color:var(--apex-scroll-thumb) var(--apex-scroll-track);
  overscroll-behavior:contain;
}
:where(.register,.ledger-viewport,.modal-card,.apex-global-card,.notice-editor-shell,
       .case-ops-sheet,.ce-sheet,.ch-sheet,.scan-settings-panel,.sq-panel,
       .record-popup-body,.selection-body,.wq-dashboard,.case-drilldown,
       .register-drilldown,.pe-table-wrap)::-webkit-scrollbar{width:9px;height:9px}
:where(.register,.ledger-viewport,.modal-card,.apex-global-card,.notice-editor-shell,
       .case-ops-sheet,.ce-sheet,.ch-sheet,.scan-settings-panel,.sq-panel,
       .record-popup-body,.selection-body,.wq-dashboard,.case-drilldown,
       .register-drilldown,.pe-table-wrap)::-webkit-scrollbar-track{background:var(--apex-scroll-track)}
:where(.register,.ledger-viewport,.modal-card,.apex-global-card,.notice-editor-shell,
       .case-ops-sheet,.ce-sheet,.ch-sheet,.scan-settings-panel,.sq-panel,
       .record-popup-body,.selection-body,.wq-dashboard,.case-drilldown,
       .register-drilldown,.pe-table-wrap)::-webkit-scrollbar-thumb{
  background:var(--apex-scroll-thumb);border:2px solid var(--apex-scroll-track);border-radius:999px
}

/* Minimum screen readability for metadata and controls. Print layouts retain their own compact rules. */
@media screen{
  :where(.case-register,.notice-dedicated-register,.tir-dedicated-register,.misc-dedicated-register,
         .causelist-app,.pending-entries-app,.invoice-app,.wq-app,.dashboard-app)
    :where(label,small,th,.pill,.micro,.meta){font-size:max(var(--apex-text-micro),1em)!important}
  :where(.case-register,.notice-dedicated-register,.tir-dedicated-register,.misc-dedicated-register,
         .causelist-app,.pending-entries-app,.invoice-app,.wq-app,.dashboard-app)
    :where(button,input,select,textarea){font-size:max(var(--apex-text-small),1em)!important}
  :where(.modal-card button,.modal-card input,.modal-card select,.modal-card textarea,
         .apex-global-card button,.apex-global-card input,.apex-global-card select,.apex-global-card textarea){
    font-size:max(var(--apex-text-small),1em)
  }
}

/* Grid/flex children should shrink instead of forcing horizontal page overflow. */
:where(.modal-card,.apex-global-card,.notice-editor-shell,.case-ops-sheet,.ce-sheet,.ch-sheet,
       .scan-settings-panel,.sq-panel,.wq-dashboard-shell,.case-drilldown,.register-drilldown) *{
  min-width:0
}

/* Avoid animation-related usability issues without changing the default visual design. */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}
