/* Responsive shell for phones and small tablets. Desktop styles stay unchanged. */
.mobile-nav-toggle,
.mobile-nav-backdrop {
  display: none;
}

@media (max-width: 1100px), (orientation: portrait) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .workspace {
    width: 100%;
    min-width: 0;
  }

  .sidebar {
    position: fixed;
    z-index: 60;
    inset: 0 auto 0 0;
    display: flex;
    width: min(86vw, 320px);
    height: 100dvh;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 12px 0 35px #06161d66;
  }

  body.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar .account {
    display: flex;
  }

  .sidebar #main-nav {
    display: block;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .sidebar .sidebar-foot {
    display: block;
  }

  .mobile-nav-backdrop {
    position: fixed;
    z-index: 50;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #06171f99;
    backdrop-filter: blur(2px);
  }

  body.mobile-nav-open .mobile-nav-backdrop {
    display: block;
  }

  .topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 8px;
    width: 100%;
    height: auto;
    min-height: 58px;
    padding: 8px 10px;
    box-shadow: 0 3px 13px #102d3530;
  }

  .mobile-nav-toggle {
    display: grid;
    place-content: center;
    gap: 4px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid #ffffff47;
    border-radius: 7px;
    background: #277da2;
    cursor: pointer;
  }

  .mobile-nav-toggle span {
    display: block;
    width: 19px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
  }

  .topbar-left {
    min-width: 0;
    gap: 7px;
  }

  .topbar-left b {
    display: none;
  }

  .topbar-left > span {
    display: block;
    overflow: hidden;
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quick-action {
    display: none;
  }

  .topbar-right {
    gap: 5px;
  }

  .top-icon {
    width: 40px;
    height: 40px;
  }

  .topbar-right .environment {
    padding: 6px 7px;
    font-size: 9px;
  }

  .top-profile-button {
    min-width: 42px;
    padding: 3px;
  }

  .top-profile-button .profile-copy,
  .top-profile-button .profile-chevron {
    display: none;
  }

  .top-popover,
  .top-profile-menu {
    position: fixed;
    top: 65px;
    right: 10px;
    left: 10px;
    width: auto;
    max-width: none;
  }

  .safety-banner {
    margin: 10px 10px 0;
    padding: 10px 11px;
    font-size: 11px;
    line-height: 1.45;
    text-align: left;
  }

  .page {
    width: 100%;
    padding: 14px 10px 28px;
  }

  .page-head {
    gap: 12px;
    margin-bottom: 12px;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .page-head p {
    font-size: 12px;
    line-height: 1.45;
  }

  .head-actions,
  .form-actions,
  .table-foot,
  .section-head,
  .customer-toolbar,
  .finance-actions {
    width: 100%;
    align-items: stretch;
    flex-wrap: wrap;
  }

  .head-actions .button,
  .form-actions .button {
    flex: 1 1 130px;
    min-height: 42px;
  }

  .card {
    min-width: 0;
    margin-top: 11px;
    padding: 13px;
  }

  .kpi {
    min-height: 98px;
    padding: 15px;
  }

  .kpi strong {
    font-size: 23px;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .data-table th,
  .data-table td {
    padding: 10px 9px;
  }

  .filters {
    gap: 10px;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .button,
  .row-action {
    min-height: 40px;
  }

  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92dvh;
    overflow: auto;
    border-radius: 14px 14px 0 0;
  }

  .modal-head,
  .modal-body,
  .modal-actions {
    padding: 15px;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    flex-wrap: wrap;
    background: #fff;
  }

  #toast-root {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .toast {
    width: 100%;
  }

  .login-screen {
    width: 100vw;
    min-height: 100dvh;
    padding: 14px 11px 50px;
    overflow-x: hidden;
  }

  .login-card {
    width: calc(100vw - 22px);
    max-width: 430px;
    min-width: 0;
    overflow: hidden;
  }

  .access-login-form,
  .captcha-field,
  .captcha-row,
  .login-input,
  .login-heading {
    min-width: 0;
  }

  .login-heading p {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 1100px), (orientation: portrait) {
  .topbar {
    grid-template-columns: 42px minmax(0, 1fr) auto;
  }

  .topbar-right .top-tool:nth-of-type(2),
  .topbar-right .environment {
    display: none;
  }

  .topbar-left > span {
    font-size: 12px;
  }

  .kpi-grid,
  .service-grid,
  .dashboard-grid,
  .two-col,
  .form-grid,
  .filters,
  .migration-steps,
  .addon-service-grid,
  .addon-kpis,
  .addon-mini-kpis,
  .addon-form-grid,
  .addon-list-filter,
  .topup-kpis,
  .topup-search,
  .report-reset-kpis,
  .report-reset-modules,
  .report-reset-options,
  .report-reset-impact-list,
  .export-summary,
  .export-filter-grid,
  .export-column-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 20px 16px 18px;
  }

  .login-brand {
    min-height: 80px;
    padding-bottom: 9px;
  }

  .login-brand img {
    width: 245px;
    height: 90px;
  }

  .login-heading {
    padding: 13px 0;
  }

  .access-login-form {
    gap: 12px;
  }

  .captcha-row { grid-template-columns: 1fr; }

  .login-state {
    padding-top: 14px;
  }

  .login-screen > footer {
    width: calc(100% - 20px);
    font-size: 9px;
  }

  .login-screen > footer strong {
    padding: 6px 10px;
    font-size: 9px;
  }
}

@media (max-width: 360px) {
  .topbar-right .top-tool:first-child {
    display: none;
  }

  .captcha-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}
