:root {
  --mobile-bar-height: 64px;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-nav-toggle,
.mobile-nav-backdrop {
  display: none;
}

@media (max-width: 1024px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

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

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

  .sidebar {
    position: fixed !important;
    z-index: 1100;
    inset: 0 auto 0 0;
    width: min(86vw, 320px) !important;
    height: 100dvh;
    padding: 22px 18px calc(22px + var(--mobile-safe-bottom)) !important;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform .22s ease, box-shadow .22s ease;
    box-shadow: none;
  }

  body.mobile-nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 18px 0 50px rgba(0, 0, 0, .48);
  }

  .sidebar .brand {
    margin-bottom: 22px;
  }

  .sidebar nav {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 7px !important;
    overflow: visible !important;
  }

  .sidebar nav button {
    width: 100%;
    min-height: 48px;
    text-align: left;
    white-space: normal;
  }

  .sidebar-bottom {
    margin-top: 24px;
  }

  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    z-index: 1090;
    inset: 0;
    border: 0;
    background: rgba(1, 8, 20, .72);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .22s ease, visibility .22s ease;
  }

  body.mobile-nav-open .mobile-nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-nav-toggle {
    display: inline-grid;
    place-items: center;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 13px;
    border: 1px solid #345276;
    background: #14263d;
    color: #fff;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
  }

  .content {
    width: 100%;
    min-width: 0;
    padding: 18px !important;
  }

  .content > header {
    position: sticky;
    z-index: 900;
    top: 0;
    display: grid !important;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin: -18px -18px 18px !important;
    padding: 10px 18px;
    min-height: var(--mobile-bar-height);
    background: rgba(7, 20, 38, .94);
    border-bottom: 1px solid #203a59;
    backdrop-filter: blur(12px);
  }

  .content > header > div:first-of-type {
    min-width: 0;
  }

  .content > header .eyebrow {
    display: none;
  }

  .content > header h1 {
    margin: 0 !important;
    font-size: clamp(1.25rem, 4.5vw, 1.75rem) !important;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #refreshButton {
    min-height: 44px;
    padding: 10px 13px;
    white-space: nowrap;
  }

  .page,
  .stats,
  .two-columns,
  .settings-grid,
  .pin-grid,
  .health-grid,
  .operations-summary {
    min-width: 0;
  }

  .stats,
  .two-columns,
  .settings-grid,
  .pin-grid,
  .health-grid,
  .operations-summary {
    grid-template-columns: 1fr !important;
  }

  .card,
  .stat,
  .login-card {
    border-radius: 16px !important;
  }

  .card {
    padding: 18px !important;
  }

  .card-head,
  .filters,
  .inline-form,
  .row-actions,
  .actions {
    gap: 10px !important;
  }

  .card-head,
  .filters {
    align-items: stretch !important;
  }

  .form-grid,
  .inline-form,
  .filters,
  .dialog-form .form-grid {
    grid-template-columns: 1fr !important;
  }

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

  input,
  select,
  textarea {
    width: 100%;
    max-width: 100%;
  }

  textarea {
    min-height: 132px;
  }

  .filters > *,
  .inline-form > * {
    width: 100% !important;
  }

  .row-actions,
  .actions {
    display: flex !important;
    flex-wrap: wrap;
  }

  .row-actions button,
  .actions button {
    flex: 1 1 130px;
  }

  dialog {
    width: calc(100vw - 24px) !important;
    max-width: 680px !important;
    max-height: calc(100dvh - 24px) !important;
    margin: auto;
    padding: 0 !important;
    overflow: hidden;
    border-radius: 18px !important;
  }

  dialog .dialog-form {
    max-height: calc(100dvh - 24px);
    padding: 18px !important;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .toast {
    position: fixed !important;
    z-index: 2000;
    top: auto !important;
    right: 12px !important;
    bottom: calc(12px + var(--mobile-safe-bottom)) !important;
    left: 12px !important;
    width: auto !important;
    max-width: none !important;
    text-align: center;
  }

  .table-wrap {
    overflow: visible !important;
  }

  table.mobile-card-table,
  table.mobile-card-table tbody,
  table.mobile-card-table tr,
  table.mobile-card-table td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  table.mobile-card-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

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

  table.mobile-card-table tbody tr {
    padding: 14px;
    border: 1px solid #294462;
    border-radius: 14px;
    background: rgba(12, 30, 52, .72);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .14);
  }

  table.mobile-card-table tbody tr:hover {
    background: rgba(17, 40, 67, .9);
  }

  table.mobile-card-table tbody td {
    display: grid;
    grid-template-columns: minmax(92px, 36%) minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    min-height: 0;
    padding: 9px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(80, 111, 145, .28) !important;
    overflow-wrap: anywhere;
  }

  table.mobile-card-table tbody td:last-child {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  table.mobile-card-table tbody td::before {
    content: attr(data-label);
    color: #8fc3f7;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: .045em;
    text-transform: uppercase;
  }

  table.mobile-card-table tbody td[colspan] {
    display: block;
    text-align: center;
  }

  table.mobile-card-table tbody td[colspan]::before,
  table.mobile-card-table tbody td:empty::before {
    content: none;
  }

  table.mobile-card-table .row-actions,
  table.mobile-card-table select,
  table.mobile-card-table input {
    width: 100%;
  }

  .recipient-list {
    max-height: 280px;
  }

  .recipient-item,
  .pending-item,
  .list-card,
  .job-card {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 12px !important;
  }

  .content > header {
    margin: -12px -12px 14px !important;
    padding: 9px 12px;
  }

  #refreshButton {
    width: 46px;
    padding: 0;
    overflow: hidden;
    color: transparent;
    position: relative;
  }

  #refreshButton::after {
    content: "↻";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 24px;
  }

  .card {
    padding: 15px !important;
  }

  .card h2,
  .card h3 {
    overflow-wrap: anywhere;
  }

  table.mobile-card-table tbody td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .row-actions button,
  .actions button {
    flex-basis: 100%;
  }
}

@media (min-width: 1025px) {
  .sidebar,
  .content {
    min-width: 0;
  }

  .table-wrap {
    max-width: 100%;
  }
}

/* MAXSTREAM EARLY TABLE CARDS 1168 BEGIN */
@media (max-width: 1168px) {
  :is(#page-devices, #page-dashboard, #page-operations, #page-history) .table-wrap { overflow: visible !important; }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table,
  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody,
  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tr,
  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody {
    display: grid;
    gap: 12px;
  }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody tr {
    padding: 14px;
    border: 1px solid #294462;
    border-radius: 14px;
    background: rgba(12, 30, 52, .72);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .14);
  }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody td {
    display: grid;
    grid-template-columns: minmax(92px, 36%) minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    min-height: 0;
    padding: 9px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(80, 111, 145, .28) !important;
    overflow-wrap: anywhere;
  }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody td:last-child {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody td::before {
    content: attr(data-label);
    color: #8fc3f7;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: .045em;
    text-transform: uppercase;
  }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody td[colspan] {
    display: block;
    text-align: center;
  }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody td[colspan]::before,
  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table tbody td:empty::before { content: none; }

  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table .row-actions,
  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table select,
  :is(#page-devices, #page-dashboard, #page-operations, #page-history) table.mobile-card-table input { width: 100%; }
}
/* MAXSTREAM EARLY TABLE CARDS 1168 END */
