@media (max-width: 767px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  body { font-size: 14px; }
  .container-fluid.py-4, .portal-shell.py-4 { padding: 14px 10px !important; }
  .container-fluid[style*="max-width"] { padding-left: 0 !important; padding-right: 0 !important; }
  main { width: 100%; min-width: 0; }
  .row { --bs-gutter-x: 1rem; }
  .row.g-4 { --bs-gutter-y: 1rem; }
  .card { border-radius: 14px !important; box-shadow: 0 5px 18px rgba(60,25,18,.07) !important; }
  .card.p-3, .card.p-4, .card.p-5 { padding: 16px !important; }
  h1.h3, .h3 { font-size: 1.45rem; line-height: 1.25; }
  h2.h4, .h4 { font-size: 1.25rem; }
  h2.h5, .h5 { font-size: 1.05rem; }
  .display-6 { font-size: 1.8rem; }
  .metric { min-height: 104px !important; }
  .metric strong, .metric .number { font-size: 1.45rem !important; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .btn-lg { padding: .65rem 1rem; font-size: 1rem; }
  .form-control, .form-select, .input-group-text { min-height: 44px; font-size: 16px; }
  .form-control-lg, .form-select-lg { font-size: 16px; }
  textarea.form-control { min-height: 90px; }
  .input-group { flex-wrap: nowrap; }
  .d-flex.justify-content-between.align-items-center.mb-4,
  .d-flex.justify-content-between.align-items-end.mb-4 { align-items: stretch !important; gap: 12px !important; flex-wrap: wrap; }
  .d-flex.justify-content-between.align-items-center.mb-4 > a,
  .d-flex.justify-content-between.align-items-end.mb-4 > a { width: 100%; }
  .table-responsive { margin-left: -8px; margin-right: -8px; padding: 0 8px; -webkit-overflow-scrolling: touch; }
  .table-responsive::after { content: "Swipe table →"; display: block; text-align: right; color: #8a9398; font-size: 11px; padding: 5px 2px; }
  .table { min-width: 720px; margin-bottom: 0; }
  .table > :not(caption) > * > * { padding: .7rem .6rem; font-size: .82rem; }
  .table th { white-space: nowrap; }
  .table td .btn, .table td form { margin: 2px 0; }
  .alert { padding: .8rem; font-size: .88rem; }
  .modal-dialog { margin: 10px; }
  .modal-body { padding: 18px !important; }
  .salary-summary .col-lg-8, .salary-summary .col-lg-4 { padding: 18px !important; }
  .salary-summary .display-6 { font-size: 1.65rem; overflow-wrap: anywhere; }
  .list-group-item .d-flex.justify-content-between { flex-direction: column; }
  .list-group-item .text-nowrap { white-space: normal !important; }
  .auth-brand-logo { max-width: 180px !important; }
  .row.justify-content-center.py-5 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
  .row.justify-content-center.py-4 { padding-top: .5rem !important; padding-bottom: .5rem !important; }
  .signature-wrap canvas { height: 190px !important; }
  #signature-form .d-flex.align-items-center { align-items: stretch !important; flex-direction: column; width: 100%; }
  #signature-form .btn { width: 100%; }
  .notification-menu, .approval-menu { max-height: 76vh; overflow-y: auto; }
  .rounded-3.p-4 .row > [class*="col-"] { overflow-wrap: anywhere; }
}

@media (max-width: 420px) {
  .card.p-4 { padding: 14px !important; }
  h1.h3, .h3 { font-size: 1.3rem; }
  .auth-brand-logo { max-width: 155px !important; }
  .btn-group, .d-flex.gap-2 { flex-wrap: wrap; }
  .d-flex.gap-2 > .btn, .d-flex.gap-2 > form { flex-grow: 1; }
}

/* Employee portal: shared responsive safety layer */
@media (max-width: 991.98px) {
  .employee-portal-body .portal-shell { width: 100%; max-width: 100%; }
  .employee-portal-body main,
  .employee-portal-body main > *,
  .employee-portal-body section,
  .employee-portal-body article { min-width: 0; }
  .employee-portal-body img,
  .employee-portal-body svg,
  .employee-portal-body canvas { max-width: 100%; }
  .employee-portal-body .modal-dialog { max-width: calc(100vw - 24px); }
}

@media (max-width: 767.98px) {
  .employee-portal-body { width: 100%; overflow-x: hidden; font-size: 15px; }
  .employee-portal-body .topbar .portal-shell { min-height: 64px; padding: 10px 12px !important; }
  .employee-portal-body .topbar .d-flex.align-items-center.gap-3 { min-width: 0; }
  .employee-portal-body .header-profile { display: none; }
  .employee-portal-body .notification-button,
  .employee-portal-body .employee-menu-toggle { width: 40px; height: 40px; flex: 0 0 40px; }
  .employee-portal-body .topbar form .btn { min-height: 38px; padding: .4rem .65rem; }
  .employee-portal-body .portal-shell.py-4 { padding: 14px 12px max(24px, env(safe-area-inset-bottom)) !important; }
  .employee-portal-body .side { height: 100dvh; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .employee-portal-body .portal-shell > .row { display: block; margin: 0; }
  .employee-portal-body .portal-shell > .row > aside { width: 0; height: 0; min-height: 0; margin: 0; padding: 0; }
  .employee-portal-body .portal-shell > .row > main { width: 100%; max-width: 100%; margin: 0; padding: 0; }
  .employee-portal-body main h1,
  .employee-portal-body main h2,
  .employee-portal-body main h3,
  .employee-portal-body main p,
  .employee-portal-body main span,
  .employee-portal-body main strong,
  .employee-portal-body main a { overflow-wrap: anywhere; }
  .employee-portal-body main input,
  .employee-portal-body main select,
  .employee-portal-body main textarea { max-width: 100%; font-size: 16px !important; }
  .employee-portal-body main button,
  .employee-portal-body main .btn { touch-action: manipulation; }
  .employee-portal-body .card { box-shadow: none !important; }
  .employee-portal-body .portal-flash { margin-bottom: 12px; font-size: .88rem; }
  .employee-portal-body .modal,
  .employee-portal-body .lr-modal,
  .employee-portal-body .signature-preview-modal,
  .employee-portal-body .signature-sign-modal { padding: 10px; }
  .employee-portal-body .modal-dialog,
  .employee-portal-body .lr-dialog,
  .employee-portal-body .signature-preview-dialog,
  .employee-portal-body .signature-sign-dialog { width: 100%; max-width: 100%; margin: 0; max-height: calc(100dvh - 20px); }
  .employee-portal-body .modal-content { max-height: calc(100dvh - 20px); overflow-y: auto; }
  .employee-portal-body .modal-header { position: sticky; top: 0; z-index: 2; }
  .employee-portal-body .employee-home,
  .employee-portal-body .my-profile,
  .employee-portal-body .bank-workspace,
  .employee-portal-body .salary-archive,
  .employee-portal-body .signature-centre,
  .employee-portal-body .employee-security,
  .employee-portal-body .lr-page { width: 100%; max-width: 100%; min-width: 0; }
  .employee-portal-body .eh-welcome,
  .employee-portal-body .mp-summary,
  .employee-portal-body .bw-card { background-position: center; }
  .employee-portal-body .eh-panel,
  .employee-portal-body .mp-panel,
  .employee-portal-body .bw-panel,
  .employee-portal-body .sa-panel,
  .employee-portal-body .sg-card,
  .employee-portal-body .es-layout,
  .employee-portal-body .lr-panel { max-width: 100%; box-shadow: none; }
  .employee-portal-body .eh-actions a,
  .employee-portal-body .sg-action,
  .employee-portal-body .sa-sign,
  .employee-portal-body .bw-btn,
  .employee-portal-body .mp-btn,
  .employee-portal-body .es-submit,
  .employee-portal-body .lr-btn { min-height: 46px; }
  .employee-portal-body .eh-summary,
  .employee-portal-body .eh-duty,
  .employee-portal-body .sa-summary,
  .employee-portal-body .sg-summary,
  .employee-portal-body .lr-stats { width: 100%; }
  .employee-portal-body .mp-tabs { overscroll-behavior-x: contain; }
  .employee-portal-body .mp-doc-actions,
  .employee-portal-body .bw-actions,
  .employee-portal-body .lr-edit-actions { max-width: 100%; }
  .employee-portal-body .otp-code,
  .employee-portal-body .lr-otp-input { padding-left: .7rem !important; padding-right: .7rem !important; letter-spacing: .28em !important; }
  .employee-portal-body .table-responsive { width: 100%; max-width: 100%; }
  .employee-portal-body .eh-desktop-salaries,
  .employee-portal-body .sa-desktop-table,
  .employee-portal-body .lr-desktop { display: none !important; }
  .employee-portal-body .eh-mobile-salaries,
  .employee-portal-body .sa-mobile-list,
  .employee-portal-body .lr-mobile { display: block !important; }
  .employee-portal-body .row.g-3 > [class*="col-"],
  .employee-portal-body .row.g-4 > [class*="col-"] { min-width: 0; }
}

@media (max-width: 420px) {
  .employee-portal-body .portal-shell.py-4 { padding-left: 10px !important; padding-right: 10px !important; }
  .employee-portal-body .portal-logo { max-width: 132px !important; }
  .employee-portal-body .eh-summary,
  .employee-portal-body .eh-duty,
  .employee-portal-body .sa-summary,
  .employee-portal-body .sg-summary,
  .employee-portal-body .lr-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .employee-portal-body .eh-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .employee-portal-body .eh-action { min-height: 96px; }
  .employee-portal-body .mp-summary-data { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .employee-portal-body .mp-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .employee-portal-body .bw-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .employee-portal-body .lr-modal-request { align-items: flex-start; flex-wrap: wrap; }
  .employee-portal-body .lr-modal-request > span:first-child { width: calc(100% - 42px); }
  .employee-portal-body .lr-open-arrow { margin-left: auto; }
  .employee-portal-body .security-otp-modal .modal-body,
  .employee-portal-body #leaveSuccessModal .modal-body { padding: 16px !important; }
  .employee-portal-body .signature-sign-pad canvas { height: 190px; }
}

@media (max-width: 350px) {
  .employee-portal-body .portal-shell.py-4 { padding-left: 8px !important; padding-right: 8px !important; }
  .employee-portal-body .topbar .portal-shell { padding-left: 8px !important; padding-right: 8px !important; }
  .employee-portal-body .portal-logo { max-width: 116px !important; }
  .employee-portal-body .topbar .gap-3 { gap: .3rem !important; }
  .employee-portal-body .eh-summary,
  .employee-portal-body .eh-duty,
  .employee-portal-body .sa-summary,
  .employee-portal-body .sg-summary { grid-template-columns: 1fr; }
  .employee-portal-body .eh-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .employee-portal-body .mp-summary-data { grid-template-columns: 1fr; }
  .employee-portal-body .lr-stat { padding: .65rem; }
  .employee-portal-body .lr-stat:after { font-size: .58rem; }
  .employee-portal-body .otp-code,
  .employee-portal-body .lr-otp-input { font-size: 1.2rem !important; letter-spacing: .2em !important; }
}

/* Centred Super Admin workspace on wide displays */
@media (min-width: 768px) {
  body > .navbar > .container-fluid,
  body > .navbar ~ .container-fluid.py-4 {
    width: calc(100% - 40px);
    max-width: 1540px;
    margin-left: auto;
    margin-right: auto;
  }
  body > .navbar ~ .container-fluid.py-4 > .row {
    align-items: flex-start;
  }
  body > .navbar ~ .container-fluid.py-4 main > .container-fluid {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (min-width: 1800px) {
  body > .navbar > .container-fluid,
  body > .navbar ~ .container-fluid.py-4 {
    max-width: 1500px;
  }
}
