/* ── Mobile shell and drawer ───────────────────────────────────────────── */
@media (max-width: 900px) {
  body.nav-locked {
    overflow: hidden;
  }

  .btn,
  .btn-small {
    min-height: 44px;
  }

  .topbar {
    flex-wrap: nowrap;
    gap: 10px;
    min-height: 60px;
    padding: 8px 16px;
    background: var(--surface);
  }

  .topbar-brand {
    flex: 0 0 auto;
    gap: 8px;
  }

  .topbar-brand > div {
    display: flex;
    align-items: baseline;
    gap: 0;
  }

  .topbar-brand strong {
    font-size: 14px;
  }

  .topbar-sub {
    display: none;
  }

  .brand-mark.small {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    font-size: 10px;
  }

  .topbar-current {
    min-width: 0;
    margin: 0 0 0 2px;
    padding: 0;
    overflow: hidden;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-current::before {
    content: '/';
    margin-right: 8px;
    color: #516158;
  }

  .topbar-scope,
  .topbar-user {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .panel-body {
    display: block;
    min-height: auto;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(2, 4, 3, 0.68);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 180ms ease,
      visibility 180ms ease;
  }

  .panel-screen.drawer-open .nav-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: none;
    padding: calc(12px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto;
    border: 0;
    background: var(--surface);
    transform: translateX(100%);
    visibility: hidden;
    transition:
      transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
      visibility 220ms;
  }

  .panel-screen.drawer-open .sidebar {
    transform: none;
    visibility: visible;
  }

  .drawer-head {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 52px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }

  .drawer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
  }

  .drawer-brand > div {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
  }

  .drawer-brand strong {
    font-size: 16px;
  }

  .drawer-brand .small {
    margin-top: 2px;
    color: var(--muted);
  }

  .drawer-close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
  }

  .drawer-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .nav-item {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 16px;
  }

  .nav-item + .nav-item {
    margin-top: 2px;
  }

  /* The chat group heading matches the drawer's 48 px rows (nav-groups.js
     opens it whenever the drawer opens). */
  .nav-group {
    flex: 0 0 auto;
    margin-top: 2px;
  }

  .nav-group-toggle {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px;
  }

  .nav-icon {
    width: 22px;
    font-size: 18px;
  }

  .sidebar-foot {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    margin-top: 14px;
    padding: 12px;
    border-top: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
  }

  /* The drawer already shows the tenant in its scope control; trim the two
     redundant footer lines so the full-size nav and logout fit one screen. */
  .sidebar-foot > .muted.small {
    display: none;
  }

  .drawer-scope {
    display: block;
    width: 100%;
  }

  .drawer-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }

  .drawer-scope .select {
    width: 100%;
    min-height: 44px;
    background: var(--surface);
  }

  .drawer-scope .tenant-pill {
    min-height: 44px;
    width: 100%;
  }

  .drawer-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .drawer-user-name {
    color: var(--ink);
    font-size: 15px;
    font-weight: 650;
  }

  .drawer-user-email {
    flex-basis: 100%;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 12px;
  }

  .drawer-logout {
    display: inline-flex;
    width: 100%;
    min-height: 44px;
    margin-top: 2px;
    background: var(--surface);
  }

  .content {
    padding: 20px 16px calc(48px + env(safe-area-inset-bottom));
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 20px;
  }

  .section-head h2 {
    font-size: 22px;
  }

  .section-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
    gap: 8px;
  }

  .section-tools .select,
  .section-tools .btn {
    width: 100%;
    min-height: 44px;
  }

  .section-tools:has(> .select + .select) {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-card {
    min-height: 112px;
  }

  .stat-value {
    font-size: 34px;
  }

  .flag-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .flag-controls {
    justify-content: flex-start;
    gap: 12px;
  }

  .switch {
    min-height: 44px;
  }

  .inline-field {
    min-height: 44px;
  }

  .report-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-actions .btn,
  .forum-actions .btn,
  .campaign-actions .btn {
    min-height: 44px;
  }

  .forum-block + .forum-block {
    margin-top: 26px;
  }

  .forum-block-head {
    align-items: stretch;
    flex-direction: column;
  }

  .forum-filters {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .forum-filters .select {
    width: 100%;
    min-width: 0;
  }

  .forum-block-head p {
    max-width: none;
  }

  .campaign-form-grid,
  .modal-form .campaign-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .campaign-span-2,
  .campaign-span-all {
    grid-column: 1 / -1;
  }

  .campaign-form {
    padding: 16px;
  }

  .campaign-create {
    margin-bottom: 14px;
  }

  .campaign-create > summary {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .campaign-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .campaign-form-actions .btn {
    width: 100%;
    min-height: 48px;
  }

  .staff-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
  }

  .staff-form .field {
    width: 100%;
    flex: none;
  }

  .staff-submit {
    width: 100%;
    min-height: 48px;
  }

  .rewards-form {
    padding: 16px;
  }

  .rewards-form-grid {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .rewards-period-field {
    flex: 1 1 auto;
  }

  .rewards-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .rewards-actions .btn {
    min-height: 48px;
  }

  .rewards-result {
    padding: 16px;
  }

  .rewards-result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .rewards-result-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .rewards-result-item dd {
    font-size: 16px;
  }

  /* Every data table becomes a card list on mobile. */
  .table-wrap {
    overflow: visible;
    border-radius: 0;
    background: transparent;
  }

  .data-table {
    display: block;
    width: 100%;
    font-size: 15px;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: grid;
    gap: 12px;
  }

  .data-table tbody tr {
    display: grid;
    gap: 0;
    padding: 6px 16px;
    border-radius: var(--radius);
    background: var(--surface);
  }

  .data-table tbody tr:nth-child(even),
  .data-table tbody tr:hover {
    background: var(--surface);
  }

  .data-table td {
    display: grid;
    grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
    padding: 10px 0;
    border: 0;
    text-align: left;
    vertical-align: baseline;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
  }

  .data-table td:not([data-label])::before,
  .data-table td[data-label='']::before {
    display: none;
  }

  .data-table td:first-child {
    color: var(--ink);
    font-weight: 650;
  }

  .data-table td.nowrap {
    white-space: normal;
  }

  .data-table td.audit-diff,
  .data-table td.dlq-error {
    max-width: none;
    overflow-wrap: anywhere;
  }

  .data-table td.table-message-cell,
  .data-table td[colspan] {
    display: block;
    grid-template-columns: 1fr;
    padding: 16px 0;
    color: var(--muted);
    font-weight: 500;
    text-align: center;
  }

  .data-table td.table-message-cell::before,
  .data-table td[colspan]::before {
    display: none;
  }

  .data-table td .select {
    width: 100%;
    max-width: 240px;
    min-height: 44px;
  }

  .data-table td > * {
    min-width: 0;
  }

  .data-table td > .status-badge,
  .data-table td > .type-badge,
  .data-table td > .campaign-winner,
  .data-table td > .btn {
    justify-self: start;
  }

  .data-table .campaign-actions,
  .data-table .forum-actions,
  .data-table .dlq-actions,
  .data-table .staff-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    white-space: normal;
  }

  .table-foot .btn {
    min-width: 160px;
    min-height: 44px;
  }

  .dlq-error,
  .audit-diff {
    font-size: 12px;
  }

  /* Dialog becomes a full-screen sheet with a sticky action footer. */
  .modal {
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
  }

  .modal-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    padding: calc(14px + env(safe-area-inset-top)) 16px 0;
    overflow-y: auto;
  }

  .modal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    flex: 0 0 auto;
    padding-bottom: 12px;
    background: var(--surface);
  }

  .modal-head .btn-small {
    min-height: 44px;
  }

  .modal-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
  }

  .modal .campaign-form-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: auto -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface);
  }

  .modal .campaign-form-actions .btn {
    min-height: 48px;
  }

  .toast {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 16px;
    max-width: none;
  }
}
