/* R74: role-safe shell, mobile safe-area clearance, and close-only frameless controls.
 * This stylesheet must be linked AFTER management_mobile_navigation and :head. */
html.aic-layout-refactor body.aic-sidebarless-shell {
  --sidebar-w: 0px;
}
html.aic-layout-refactor body.aic-sidebarless-shell.sidebar-collapsed {
  --sidebar-w: 0px;
}
html.aic-layout-refactor body.aic-sidebarless-shell main.main-content {
  margin-left: calc(var(--page-pad-x) + var(--safe-left));
  width: calc(100% - 2 * var(--page-pad-x) - var(--safe-left) - var(--safe-right));
}
/* The desktop menu lives in the bottom-right; it is not a Hero control. */
@media (min-width: 1025px) {
  html.aic-layout-refactor body.r68-has-mini-sidebar.aic-sidebarless-shell main.main-content {
    margin-bottom: calc(90px + var(--safe-bottom));
  }
  html.aic-layout-refactor body.r68-has-mini-sidebar .dashboard-sidebar-toggle {
    top: auto;
    bottom: calc(14px + var(--safe-bottom));
    right: calc(18px + var(--safe-right));
    min-width: 50px;
    min-height: 48px;
    background: var(--ui-surface, #fff);
    border: 1px solid var(--ui-color-border, #dce3ed);
  }
}
/* No top-right menu remains, so R68's reserved Hero column is obsolete. */
html.aic-layout-refactor body.r68-has-mini-sidebar main.main-content .ui-hero__top,
html.aic-layout-refactor body.r68-has-mini-sidebar main.main-content > :first-child:not(.ui-page) {
  padding-inline-end: 0;
}
/* Mini menu is always a LEFT drawer, never a bottom-right popover. */
html.aic-layout-refactor body.r68-has-mini-sidebar .dashboard-mini-sidebar {
  left: 0;
  right: auto;
  top: 0;
  bottom: 0;
  width: min(232px, calc(100vw - 28px - var(--safe-left) - var(--safe-right)));
  min-width: 0;
  max-width: none;
  max-height: none;
  height: 100vh;
  height: 100dvh;
  padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
  border: 0;
  border-right: 1px solid var(--ui-color-border, #dce3ed);
  border-radius: 0;
  box-shadow: var(--ui-shadow-edge-right, 2px 0 14px rgba(15,23,42,.12));
  transform: translateX(calc(-100% - 20px));
  transform-origin: center left;
  z-index: 1399;
  overflow: hidden;
}
html.aic-layout-refactor body.r68-has-mini-sidebar .dashboard-mini-sidebar.is-open {
  transform: translateX(0);
}
html.aic-layout-refactor body.r68-has-mini-sidebar .dashboard-mini-sidebar__backdrop {
  background: rgba(15,23,42,.24);
  z-index: 1398;
}
html.aic-layout-refactor body.r68-has-mini-sidebar .dashboard-mini-sidebar__inner {
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: 0;
}
html.aic-layout-refactor body.r68-has-mini-sidebar .dashboard-mini-sidebar__nav {
  min-height: 0;
  overflow-y: auto;
}
html.aic-layout-refactor body.dashboard-mini-sidebar-open {
  overflow: hidden;
}
@media (min-width: 1025px) {
  html.aic-layout-refactor body.dashboard-mini-sidebar-open .dashboard-sidebar-toggle {
    z-index: 1401;
  }
}
/* An open close-icon is not an outlined toolbar button. */
html.aic-layout-refactor body .dashboard-sidebar-toggle.is-r74-x-open {
  border: 0;
  box-shadow: none;
}
html.aic-layout-refactor body .dashboard-sidebar-toggle.is-r74-x-open:focus-visible {
  outline: 2px solid var(--ui-color-focus, #2563eb);
  outline-offset: 2px;
}
/* All fixed three-tab navigations reserve one navigation-height clearance.
 * Override prior margin-bottom rules rather than stacking a second margin. */
@media (max-width: 1024px) {
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) {
    --aic-r74-nav-height: 72px; /* measured 69px at base font; keep 3px for rounding */
    --aic-r74-nav-clearance: calc(var(--aic-r74-nav-height) + var(--safe-bottom) + 24px);
  }
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) main.main-content {
    margin-bottom: var(--aic-r74-nav-clearance);
    padding-bottom: 0;
  }
  html.aic-layout-refactor body.aic-driver-mobile-nav .driver-mobile-nav,
  html.aic-layout-refactor body.aic-management-mobile-nav .management-mobile-nav {
    box-sizing: border-box;
  }
  /* Override BOTH R72 and R73 popover coordinates with the management drawer geometry. */
  html.aic-layout-refactor body.aic-driver-mobile-nav .dashboard-mini-sidebar {
    left: 0;
    right: auto;
    top: 0;
    bottom: 0;
    width: min(232px, calc(100vw - 28px - var(--safe-left) - var(--safe-right)));
    max-width: none;
    max-height: none;
    height: 100vh;
    height: 100dvh;
    transform-origin: center left;
  }
  html.aic-layout-refactor body.aic-driver-mobile-nav .dashboard-mini-sidebar__inner {
    height: 100%;
    max-height: none;
    overflow-y: auto;
  }
  /* The left drawer and backdrop cover all three bottom tabs, including Other.
     Keep its native safe-area padding; no extra nav-height spacer is needed. */
  /* Floating actions belong above, not under, the fixed bottom bar. */
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) :is(
    .group-form-page, .waybills-page.staff-group-form-page
  ) .r46-group-form-footer {
    bottom: calc(var(--aic-r74-nav-height) + var(--safe-bottom) + 12px);
    right: calc(12px + var(--safe-right));
    max-width: calc(100vw - 24px - var(--safe-left) - var(--safe-right));
  }
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) :is(
    .group-form-page, .waybills-page.staff-group-form-page
  ) { padding-bottom: 96px; }
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) .hazard-new-page .mobile-submit-bar {
    bottom: calc(var(--aic-r74-nav-height) + var(--safe-bottom));
    padding-bottom: 10px;
  }
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) .hazard-new-page:has(.mobile-submit-bar) {
    padding-bottom: 96px;
  }
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) :is(
    .plans-index-page .floating-bulk-action,
    .waybills-page .floating-bulk-action,
    .unused-dispatch-page .dwb-cleanup-floating,
    .plans-dispatch-confirm-page .dispatch-confirm-floating-action
  ) {
    bottom: calc(var(--aic-r74-nav-height) + var(--safe-bottom) + 12px);
  }
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) :is(
    .plan-board-page > .plan-board-save-feedback,
    .plans-index-page .toast,
    .waybills-page .toast,
    .unused-dispatch-page .toast
  ) {
    bottom: calc(var(--aic-r74-nav-height) + var(--safe-bottom) + 16px);
  }
  /* Reserve the height of an actually visible floating toolbar while open. */
  html.aic-layout-refactor body:is(.aic-driver-mobile-nav, .aic-management-mobile-nav) main.main-content:has(.floating-bulk-action.is-show) {
    margin-bottom: calc(var(--aic-r74-nav-clearance) + 64px);
  }
}
@media (prefers-reduced-motion: reduce) {
  html.aic-layout-refactor body.r68-has-mini-sidebar .dashboard-mini-sidebar,
  html.aic-layout-refactor body.r68-has-mini-sidebar .dashboard-mini-sidebar__backdrop {
    transition-duration: 0.01ms;
  }
}

/* R74: icon-only ×/clear controls: preserve size, action, hover feedback,
 * focus-visible outline; NEVER remove the generic .icon-btn or .ui-btn border. */
html.aic-layout-refactor button.office-modal__close,
html.aic-layout-refactor button.office-modal-close,
html.aic-layout-refactor button.modal-close,
html.aic-layout-refactor button.selected-file-clear,
html.aic-layout-refactor button.schedule-modal-close,
html.aic-layout-refactor button.selected-file-modal-close,
html.aic-layout-refactor button.system-error-workflow-close,
html.aic-layout-refactor button.session-modal__close,
html.aic-layout-refactor button.group-dispatch-modal__close,
html.aic-layout-refactor button.hz-modal-xbtn,
html.aic-layout-refactor button.office-switcher-modal__close,
html.aic-layout-refactor button.bulk-report-modal__close,
html.aic-layout-refactor button.profile-modal__close,
html.aic-layout-refactor button.transport-modal__close,
html.aic-layout-refactor button.report-modal__close,
html.aic-layout-refactor button.filter-modal__close,
html.aic-layout-refactor button.hazard-photo-modal__close,
html.aic-layout-refactor button.photo-modal__close,
html.aic-layout-refactor button.report-datetime-modal__close,
html.aic-layout-refactor button.period-picker-modal__close,
html.aic-layout-refactor button.waybill-office-transfer-modal__close,
html.aic-layout-refactor button.place-modal-xbtn,
html.aic-layout-refactor button.plan-board-group-modal__close,
html.aic-layout-refactor button.plan-board-all-confirm-modal__close,
html.aic-layout-refactor button.plan-board-driver-confirm-modal__close,
html.aic-layout-refactor button.plan-board-legend-modal__close,
html.aic-layout-refactor button.plans-shared-driver-modal__close-btn,
html.aic-layout-refactor button.foot-waybill-modal__close,
html.aic-layout-refactor button.foot-waybill-other-routes-modal__close,
html.aic-layout-refactor button.plans-shared-schedule-modal__close-btn,
html.aic-layout-refactor button.split-relay-modal__close,
html.aic-layout-refactor button.report-return-modal__close,
html.aic-layout-refactor button.group-member-picker-modal__close,
html.aic-layout-refactor button.place-picker-modal__close,
html.aic-layout-refactor button.support-modal-close,
html.aic-layout-refactor button.ui-modal__close,
html.aic-layout-refactor button.ui-action-sheet__close,
html.aic-layout-refactor button.system-error-filter-close,
html.aic-layout-refactor button.picker-modal__close,
html.aic-layout-refactor button.selected-member-remove,
html.aic-layout-refactor button.icon-btn[data-close-csv-modal],
html.aic-layout-refactor button.icon-btn[data-close-reconcile-modal],
html.aic-layout-refactor button.app-sidebar__mobile-toggle[aria-expanded="true"],
html.aic-layout-refactor button#driverMobileOtherToggle[aria-expanded="true"] {
  border: 0 !important;
  border-width: 0 !important;
  box-shadow: none !important;
  background-image: none;
}
html.aic-layout-refactor button.office-modal__close:focus-visible,
html.aic-layout-refactor button.office-modal-close:focus-visible,
html.aic-layout-refactor button.modal-close:focus-visible,
html.aic-layout-refactor button.selected-file-clear:focus-visible,
html.aic-layout-refactor button.schedule-modal-close:focus-visible,
html.aic-layout-refactor button.selected-file-modal-close:focus-visible,
html.aic-layout-refactor button.system-error-workflow-close:focus-visible,
html.aic-layout-refactor button.session-modal__close:focus-visible,
html.aic-layout-refactor button.group-dispatch-modal__close:focus-visible,
html.aic-layout-refactor button.hz-modal-xbtn:focus-visible,
html.aic-layout-refactor button.office-switcher-modal__close:focus-visible,
html.aic-layout-refactor button.bulk-report-modal__close:focus-visible,
html.aic-layout-refactor button.profile-modal__close:focus-visible,
html.aic-layout-refactor button.transport-modal__close:focus-visible,
html.aic-layout-refactor button.report-modal__close:focus-visible,
html.aic-layout-refactor button.filter-modal__close:focus-visible,
html.aic-layout-refactor button.hazard-photo-modal__close:focus-visible,
html.aic-layout-refactor button.photo-modal__close:focus-visible,
html.aic-layout-refactor button.report-datetime-modal__close:focus-visible,
html.aic-layout-refactor button.period-picker-modal__close:focus-visible,
html.aic-layout-refactor button.waybill-office-transfer-modal__close:focus-visible,
html.aic-layout-refactor button.place-modal-xbtn:focus-visible,
html.aic-layout-refactor button.plan-board-group-modal__close:focus-visible,
html.aic-layout-refactor button.plan-board-all-confirm-modal__close:focus-visible,
html.aic-layout-refactor button.plan-board-driver-confirm-modal__close:focus-visible,
html.aic-layout-refactor button.plan-board-legend-modal__close:focus-visible,
html.aic-layout-refactor button.plans-shared-driver-modal__close-btn:focus-visible,
html.aic-layout-refactor button.foot-waybill-modal__close:focus-visible,
html.aic-layout-refactor button.foot-waybill-other-routes-modal__close:focus-visible,
html.aic-layout-refactor button.plans-shared-schedule-modal__close-btn:focus-visible,
html.aic-layout-refactor button.split-relay-modal__close:focus-visible,
html.aic-layout-refactor button.report-return-modal__close:focus-visible,
html.aic-layout-refactor button.group-member-picker-modal__close:focus-visible,
html.aic-layout-refactor button.place-picker-modal__close:focus-visible,
html.aic-layout-refactor button.support-modal-close:focus-visible,
html.aic-layout-refactor button.ui-modal__close:focus-visible,
html.aic-layout-refactor button.ui-action-sheet__close:focus-visible,
html.aic-layout-refactor button.system-error-filter-close:focus-visible,
html.aic-layout-refactor button.picker-modal__close:focus-visible,
html.aic-layout-refactor button.selected-member-remove:focus-visible,
html.aic-layout-refactor button.icon-btn[data-close-csv-modal]:focus-visible,
html.aic-layout-refactor button.icon-btn[data-close-reconcile-modal]:focus-visible,
html.aic-layout-refactor button.app-sidebar__mobile-toggle[aria-expanded="true"]:focus-visible,
html.aic-layout-refactor button#driverMobileOtherToggle[aria-expanded="true"]:focus-visible {
  outline: 2px solid var(--ui-color-focus, #2563eb) !important;
  outline-offset: 2px;
}
