/* Responsive refinements. Loaded after theme.css; application logic stays unchanged. */
.live-admin, .portal-nav > div, .staff-welcome > div,
.live-admin .card-body, .live-admin .row > *, .live-admin fieldset {
  min-width: 0;
}
.live-admin :is(p, h1, h2, h3, strong, .badge, .role-chip),
.admin-editor, dialog {
  overflow-wrap: anywhere;
}
body:has(dialog[open]) { overflow: hidden; }
.profile-retry-icon { display: none; }
@media (max-width: 767.98px) {
  .live-admin .btn, .login .btn, dialog .btn,
  .live-admin .form-control, .live-admin .form-select,
  .login select, dialog input:not([type="checkbox"]), dialog select, dialog textarea {
    min-height: 44px;
  }
  .live-admin .form-control, .live-admin .form-select,
  .login input, .login select, dialog input, dialog select, dialog textarea {
    font-size: 16px;
    max-width: 100%;
  }
  .live-admin .btn, dialog .btn { white-space: normal; }
  dialog .btn { min-width: 0; }
  .btn-close { flex-shrink: 0; min-width: 44px; min-height: 44px; padding: 0; }
  .portal-nav { gap: 12px !important; }
  .portal-nav > div { flex: 1 1 200px; gap: 12px !important; }
  .portal-nav > .staff-nav-actions { flex: 1 1 100%; justify-content: flex-end; }
  .portal-nav h1 { line-height: 1.35; }
  .portal-nav .btn { flex-shrink: 0; }
  .staff-welcome { flex-direction: column; align-items: stretch; gap: 20px; padding: 24px; }
  .staff-total { min-width: 0; width: 100%; }
  .staff-credit { height: 100%; }
  .staff-credit-top { flex-wrap: wrap; }
  .staff-credit h3 { min-height: 0; }
  .staff-credit-number { line-height: 1.3; }
  .staff-credit-number small { display: block; }
  .staff-credit-actions { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); width: 100%; align-items: end; }
  .staff-credit-actions > label { min-width: 0; }
  .staff-credit-actions #leave-open { grid-column: 1 / -1; width: 100%; }
  .live-admin .card-body.p-4 { padding: 18px !important; }
  #admin-table { overflow-x: auto; }
  .live-admin #admin-table td { overflow-wrap: anywhere; align-items: flex-start; }
  .live-admin #admin-table td::before { max-width: 42%; white-space: normal; }
  .live-admin #admin-table td.admin-actions-cell { flex-wrap: wrap; }
  .live-admin #admin-table td.admin-actions-cell .btn { flex: 1 1 100px; }
  #admin-pager .pagination, #leave-history-tabs { flex-wrap: wrap; }
  #leave-history-tabs .btn { flex: 1 1 auto; }
  .leave-history-card { padding: 16px; }
  .dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .dialog-actions .btn { flex: 1 1 100px; }
  /* One viewport-bounded scroll area, without a guessed browser-toolbar gap. */
  dialog.leave-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    width: calc(100% - 16px);
    max-width: 680px;
    height: auto;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 18px;
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
    border-radius: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 16px 90px;
  }
  dialog.leave-dialog .dialog-actions {
    position: static;
    margin: 20px 0 0;
    padding: 14px 0 0;
    background: #fff;
    border-top: 1px solid #e1e9e1;
  }
  .admin-editor:not([hidden]) {
    height: 100vh;
    height: 100dvh;
    padding: 8px;
    align-items: center;
    overflow: hidden;
  }
  .admin-editor > .card-body {
    margin: auto;
    width: 100%;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 16px 90px;
    border-radius: 16px;
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px)) !important;
  }
  .admin-editor form .d-flex.gap-2.mt-3 {
    position: static;
    margin-inline: 0;
    margin-bottom: 0;
    padding: 14px 0 0;
    flex-wrap: wrap;
  }
  .admin-editor form .d-flex.gap-2.mt-3 .btn { flex: 1 1 100px; }
  #ui-toasts { right: 12px; left: 12px; bottom: max(12px, env(safe-area-inset-bottom, 0px)); width: auto; }
  .ui-toast-text { min-width: 0; overflow-wrap: anywhere; }
}
@media (max-width: 380px) {
  .portal-nav > div { flex-basis: 100%; }
  .portal-nav > .btn { margin-left: auto; }
  .admin-filters > .col-6 { width: 100%; }
  .staff-welcome { padding: 20px; }
}
/* Compact employee navbar: brand, photo and sign-out stay on one row. */
@media (max-width: 767.98px) {
  .portal-nav.staff-navbar {
    flex-wrap: nowrap !important;
    gap: 6px !important;
    padding: 8px 10px;
  }
  .portal-nav.staff-navbar > .staff-brand {
    flex: 1 1 auto;
    gap: 8px !important;
  }
  .staff-navbar .staff-brand > img { width: 64px; flex: 0 0 64px; }
  .staff-navbar .staff-brand-copy { padding-left: 8px !important; }
  .staff-navbar .staff-brand-copy .eyebrow { font-size: 8px; white-space: nowrap; }
  .staff-navbar .staff-brand-copy h1 { font-size: 12px; line-height: 1.25; white-space: nowrap; }
  .portal-nav.staff-navbar > .staff-nav-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 4px !important;
  }
  .staff-navbar .staff-profile-nav { position: static; }
  .staff-navbar .profile-nav-controls { flex-wrap: nowrap; gap: 2px; }
  .staff-navbar #profile-edit {
    display: inline-grid;
    place-items: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
  }
  .staff-navbar .profile-nav-label, .staff-navbar .profile-retry-label { display: none; }
  .staff-navbar .profile-retry-icon { display: inline; font-size: 20px; }
  .staff-navbar #profile-retry { min-width: 28px; padding: 0 3px; }
  .staff-navbar #staff-signout {
    min-height: 44px;
    padding: 7px 9px;
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
  }
  .staff-navbar .profile-nav-status:not(.visually-hidden) {
    position: absolute;
    top: calc(100% + 8px);
    right: 10px;
    width: min(340px, calc(100vw - 20px));
    padding: 10px;
    background: #fff;
    border: 1px solid #dbe7dc;
    border-radius: 8px;
    box-shadow: 0 8px 24px #05261222;
  }
}
@media (max-width: 380px) {
  .staff-navbar .staff-brand > img { width: 56px; flex-basis: 56px; }
  .portal-nav.staff-navbar > .staff-brand { gap: 6px !important; }
  .staff-navbar .staff-brand-copy { padding-left: 6px !important; }
  .staff-navbar .staff-brand-copy h1 { font-size: 11px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  dialog, .admin-editor > .card-body { max-height: calc(100dvh - 16px); overflow-y: auto; }
  .admin-editor:not([hidden]) { padding: 8px; align-items: center; }
}
