/* BIMAS Mobile App — focused PWA polish (Jun 2026) */

@media (max-width: 1024px) {
  html {
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
  }

  body {
    overscroll-behavior-y: none;
  }

  #app-content {
    padding: calc(var(--topbar-h, 3.65rem) + 0.65rem) 0.75rem calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  #app-content > .page-container {
    animation: mobilePageIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  @keyframes mobilePageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Modern glass bottom nav */
  #app-bottomnav {
    display: flex !important;
    align-items: stretch;
    justify-content: space-around;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    height: calc(4.15rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid rgba(148, 163, 184, 0.22) !important;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.08) !important;
  }

  [data-theme="dark"] #app-bottomnav {
    background: rgba(15, 23, 42, 0.94) !important;
    border-top-color: rgba(148, 163, 184, 0.14) !important;
  }

  #app-bottomnav .bottomnav-item {
    flex: 1;
    min-width: 0;
    max-width: 4.75rem;
    min-height: 3.25rem;
    padding: 0.35rem 0.25rem;
    border-radius: 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-display, 'Plus Jakarta Sans', Inter, sans-serif);
    transition: color 0.18s ease, background 0.18s ease, transform 0.12s ease;
  }

  #app-bottomnav .bottomnav-item:active {
    transform: scale(0.96);
  }

  #app-bottomnav .bottomnav-item .material-symbols-outlined {
    font-size: 1.35rem;
    line-height: 1;
  }

  #app-bottomnav .bottomnav-item span:last-child {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  #app-bottomnav .bottomnav-item.active {
    color: var(--brand-blue);
    background: linear-gradient(180deg, rgba(0, 70, 153, 0.14), rgba(0, 70, 153, 0.05));
    box-shadow: inset 0 0 0 1px rgba(0, 70, 153, 0.1);
  }

  #app-bottomnav .bottomnav-menu-btn {
    cursor: pointer;
  }

  #app-bottomnav .bottomnav-menu-btn.active {
    color: var(--brand-orange);
    background: rgba(249, 115, 22, 0.1);
  }

  /* Compact topbar on phone */
  #app-topbar {
    padding-inline: 0.55rem !important;
  }

  #app-topbar .topbar-actions .icon-btn:not(#sync-status-btn):not(#notification-btn):not(#global-search-btn) {
    display: none;
  }

  #app-topbar .topbar-actions #global-search-btn,
  #app-topbar .topbar-actions #sync-status-btn,
  #app-topbar .topbar-actions #notification-btn {
    display: inline-flex !important;
  }

  /* Touch-friendly forms */
  .form-input,
  .form-select,
  .form-textarea,
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="tel"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    min-height: 2.75rem;
    border-radius: 12px;
  }

  /* Card-based table fallback */
  .data-table-wrap,
  .table-responsive,
  .table-scroll {
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
  }

  .card {
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  }

  .btn {
    min-height: 2.75rem;
    border-radius: 12px;
  }

  .page-header h1 {
    font-size: 1.2rem;
    letter-spacing: -0.02em;
  }

  /* Hide desktop-only chrome */
  .sidebar-overlay {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
}

/* Warehouse mobile module */
.mobile-container {
  max-width: 100%;
  margin: 0 auto;
}

.mobile-mode {
  padding: 0.25rem;
}

.mobile-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, #004699 0%, #0a3d7a 55%, #071a33 100%);
  color: #fff;
  border-radius: 18px;
  margin-bottom: 0.85rem;
  position: relative;
  box-shadow: 0 12px 28px rgba(0, 70, 153, 0.22);
}

.mobile-header h1 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  font-family: var(--font-display, 'Plus Jakarta Sans', sans-serif);
}

.mobile-logo {
  font-size: 1.85rem;
}

.mobile-badge {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  background: var(--error, #ef4444);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.mobile-menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 1.15rem 0.75rem;
  background: var(--surface-0, #fff);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  min-height: 7.5rem;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.mobile-menu-btn:active {
  transform: scale(0.98);
}

.mobile-menu-btn .material-symbols-outlined,
.mobile-menu-btn > span:first-child {
  font-size: 2.1rem;
  color: var(--brand-blue);
  margin-bottom: 0.15rem;
}

.mobile-menu-btn > span:nth-child(2) {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}

.mobile-menu-btn small {
  font-size: 0.62rem;
  color: var(--text-muted);
}

.mobile-quick-actions {
  display: flex;
  gap: 0.65rem;
}

.mobile-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.85rem;
  background: var(--surface-1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 3rem;
}

.mobile-offline-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 14px;
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: var(--warning, #d97706);
}

.scan-interface {
  position: fixed;
  inset: 0;
  background: var(--surface-0);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 0.85rem 0.75rem;
  background: linear-gradient(135deg, #004699, #071a33);
  color: #fff;
}

.scan-area {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.scan-input-container {
  width: 100%;
  max-width: 420px;
  position: relative;
}

.scan-input {
  width: 100%;
  padding: 1rem 3.25rem 1rem 1rem;
  font-size: 16px !important;
  border: 2px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.06em;
  min-height: 3rem;
}

.scan-input:focus {
  border-color: var(--brand-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 70, 153, 0.12);
}

.scan-button {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--brand-blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  min-height: 2.35rem;
}

.scan-success { color: var(--success, #16a34a); }
.scan-error { color: var(--error, #ef4444); }

.scan-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.scan-input-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  gap: 0.5rem;
}

.scan-input-wrap input {
  flex: 1;
  font-size: 16px !important;
  min-height: 3rem;
  border-radius: 12px;
}

.scan-camera-wrap {
  width: 100%;
  max-width: 420px;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  position: relative;
}

.scan-camera-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-camera-wrap .scan-camera-stop {
  position: absolute;
  bottom: 0.65rem;
  right: 0.65rem;
  border: none;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.scan-feedback {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 1rem;
  border-radius: 14px;
  background: var(--surface-1);
}

.scan-history-list {
  width: 100%;
  max-width: 420px;
}

.scan-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  margin-bottom: 0.45rem;
  background: var(--surface-0);
}

.scan-actions {
  display: flex;
  gap: 0.65rem;
  padding: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--surface-0);
}

.scan-actions .btn-cancel,
.scan-actions .btn-complete {
  flex: 1;
  min-height: 3rem;
  border-radius: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.scan-actions .btn-cancel {
  background: var(--surface-2);
  color: var(--text-primary);
}

.scan-actions .btn-complete {
  background: var(--brand-blue);
  color: #fff;
}

@media (max-width: 400px) {
  .mobile-menu {
    grid-template-columns: 1fr;
  }

  .mobile-menu-btn {
    min-height: 5.5rem;
    flex-direction: row;
    justify-content: flex-start;
    padding-inline: 1rem;
    gap: 0.75rem;
  }

  .mobile-menu-btn .material-symbols-outlined {
    margin-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #app-content > .page-container {
    animation: none;
  }

  #app-bottomnav .bottomnav-item:active {
    transform: none;
  }
}

/* Skeleton loaders */
.mobile-skeleton-wrap { display: flex; flex-direction: column; gap: 0.65rem; }
.mobile-skeleton {
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(148,163,184,.16) 25%, rgba(148,163,184,.28) 50%, rgba(148,163,184,.16) 75%);
  background-size: 200% 100%;
  animation: mobileShimmer 1.1s ease-in-out infinite;
}
.mobile-skeleton-title { height: 1.35rem; width: 55%; }
.mobile-skeleton-card { height: 4.5rem; }
.mobile-skeleton-row { height: 3.25rem; }
.mobile-skeleton-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0.55rem; }
@keyframes mobileShimmer { to { background-position: -200% 0; } }

/* Pull to refresh */
.mobile-pull-indicator {
  position: fixed;
  top: calc(var(--topbar-h, 3.65rem) + 0.25rem);
  left: 50%;
  transform: translate(-50%, -120%);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  transition: transform 0.18s ease;
  pointer-events: none;
}
.mobile-pull-indicator.ready { background: var(--brand-blue); }
.mobile-pull-indicator.spinning .material-symbols-outlined { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Sync banner */
.mobile-sync-banner {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid rgba(148,163,184,.2);
}
@media (max-width: 1024px) {
  .mobile-sync-banner { display: flex; }
}
.mobile-sync-banner[data-state="offline"] { background: rgba(239,68,68,.1); color: #b91c1c; }
.mobile-sync-banner[data-state="pending"] { background: rgba(245,158,11,.12); color: #b45309; }
.mobile-sync-banner[data-state="online"] { background: rgba(16,185,129,.1); color: #047857; }

/* Mobile task cards */
.mobile-card-list { display: flex; flex-direction: column; gap: 0.65rem; }
.mobile-task-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,.2);
  background: var(--surface-0);
  box-shadow: 0 4px 14px rgba(15,23,42,.05);
  border-left: 4px solid var(--card-tone, var(--brand-blue));
}
.mobile-task-card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--card-tone, var(--brand-blue)), color-mix(in srgb, var(--card-tone, var(--brand-blue)) 68%, #0f172a));
  color: #fff;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--card-tone, var(--brand-blue)) 28%, transparent);
  flex-shrink: 0;
}
.mobile-task-card-icon .material-symbols-outlined {
  font-size: 1.2rem;
}

/* Mobile notification cards */
.mobile-notif-list { gap: 0.8rem; }
.mobile-notif-card {
  position: relative;
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  padding: 0.95rem 1rem 0.95rem 1.05rem;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--notif-tone, #2563eb) 32%, #bfdbfe);
  border-left: 5px solid var(--notif-tone, #2563eb);
  background:
    linear-gradient(128deg,
      color-mix(in srgb, var(--notif-tone, #2563eb) 16%, #fff) 0%,
      color-mix(in srgb, var(--notif-tone, #2563eb) 8%, #fff) 52%,
      #fff 100%);
  box-shadow:
    0 12px 28px color-mix(in srgb, var(--notif-tone, #2563eb) 18%, rgba(15,23,42,.08)),
    inset 0 1px 0 color-mix(in srgb, #fff 70%, var(--notif-tone, #2563eb));
  overflow: hidden;
}
.mobile-notif-card.is-unread {
  border-color: color-mix(in srgb, var(--notif-tone, #2563eb) 44%, #93c5fd);
  border-left-color: var(--notif-tone, #2563eb);
  box-shadow:
    0 14px 32px color-mix(in srgb, var(--notif-tone, #2563eb) 24%, rgba(15,23,42,.1)),
    inset 0 1px 0 color-mix(in srgb, #fff 55%, var(--notif-tone, #2563eb));
}
.mobile-notif-card-glow {
  position: absolute;
  top: -2rem;
  right: -1.25rem;
  width: 6.5rem;
  height: 6.5rem;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--notif-tone, #2563eb) 28%, transparent) 0%, transparent 72%);
  pointer-events: none;
}
.mobile-notif-card-icon {
  position: relative;
  z-index: 1;
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 15px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(145deg, var(--notif-tone, #2563eb), color-mix(in srgb, var(--notif-tone, #2563eb) 62%, #0f172a));
  box-shadow: 0 10px 22px color-mix(in srgb, var(--notif-tone, #2563eb) 34%, transparent);
  border: 1px solid color-mix(in srgb, #fff 24%, var(--notif-tone, #2563eb));
}
.mobile-notif-card-icon .material-symbols-outlined {
  font-size: 1.35rem;
}
.mobile-notif-card-body {
  position: relative;
  z-index: 1;
  min-width: 0;
  flex: 1;
}
.mobile-notif-card-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.28rem;
}
.mobile-notif-severity {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--notif-severity, var(--notif-tone, #2563eb));
  background: color-mix(in srgb, var(--notif-severity, var(--notif-tone, #2563eb)) 16%, #fff);
  border: 1px solid color-mix(in srgb, var(--notif-severity, var(--notif-tone, #2563eb)) 26%, #e2e8f0);
}
.mobile-notif-unread {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--notif-tone, #2563eb);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--notif-tone, #2563eb) 18%, transparent);
}
.mobile-notif-title {
  display: block;
  font-size: 0.92rem;
  line-height: 1.3;
  color: var(--text-primary, #0f172a);
}
.mobile-notif-card.is-unread .mobile-notif-title {
  font-weight: 800;
}
.mobile-notif-sub {
  margin: 0.28rem 0 0;
  color: var(--text-secondary, #475569);
  font-size: 0.8rem;
  line-height: 1.45;
}
.mobile-notif-meta {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted, #94a3b8);
  font-size: 0.68rem;
  font-weight: 700;
}
.mobile-notif-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}
.mobile-notif-card[data-severity="critical"] { --notif-tone: #dc2626; }
.mobile-notif-card[data-severity="urgent"] { --notif-tone: #ea580c; }
.mobile-notif-card[data-severity="today"] { --notif-tone: #2563eb; }
.mobile-notif-card[data-severity="watch"] { --notif-tone: #64748b; }

[data-theme="dark"] .mobile-notif-card {
  background: linear-gradient(128deg,
    color-mix(in srgb, var(--notif-tone, #2563eb) 24%, #1e293b) 0%,
    color-mix(in srgb, var(--notif-tone, #2563eb) 12%, #0f172a) 55%,
    #0f172a 100%);
  border-color: color-mix(in srgb, var(--notif-tone, #2563eb) 36%, #334155);
  border-left-color: var(--notif-tone, #2563eb);
}
[data-theme="dark"] .mobile-notif-title { color: #f8fafc; }
[data-theme="dark"] .mobile-notif-sub { color: #cbd5e1; }
[data-theme="dark"] .mobile-notif-severity {
  color: #fff;
  background: color-mix(in srgb, var(--notif-severity, var(--notif-tone, #2563eb)) 72%, #0f172a);
  border-color: color-mix(in srgb, var(--notif-severity, var(--notif-tone, #2563eb)) 40%, #334155);
}

/* Notifications page — colored KPI tiles on phone */
@media (max-width: 1024px) {
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-kpi-card {
    min-height: 5.5rem;
    border: 1px solid color-mix(in srgb, var(--notif-tone, #2563eb) 30%, #bfdbfe) !important;
    border-radius: 16px !important;
    background: linear-gradient(145deg,
      color-mix(in srgb, var(--notif-tone, #2563eb) 20%, #fff) 0%,
      color-mix(in srgb, var(--notif-tone, #2563eb) 10%, #fff) 58%,
      #fff 100%) !important;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--notif-tone, #2563eb) 16%, rgba(15,23,42,.07)) !important;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-kpi-card::before {
    height: 4px !important;
    background: linear-gradient(90deg, var(--notif-tone, #2563eb), color-mix(in srgb, var(--notif-tone, #2563eb) 45%, #fff)) !important;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-kpi-icon {
    width: 2.35rem !important;
    height: 2.35rem !important;
    border-radius: 12px !important;
    color: #fff !important;
    background: linear-gradient(145deg, var(--notif-tone, #2563eb), color-mix(in srgb, var(--notif-tone, #2563eb) 62%, #0f172a)) !important;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--notif-tone, #2563eb) 30%, transparent) !important;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-severity-filter button {
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    font-size: 0.68rem;
    text-transform: capitalize;
    padding: 0.42rem 0.35rem;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-severity-filter button[data-severity="all"].active {
    color: #1e40af;
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border-color: #93c5fd;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-severity-filter button[data-severity="critical"].active {
    color: #991b1b;
    background: linear-gradient(135deg, #fecaca, #fee2e2);
    border-color: #fca5a5;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-severity-filter button[data-severity="urgent"].active {
    color: #9a3412;
    background: linear-gradient(135deg, #fed7aa, #ffedd5);
    border-color: #fdba74;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-severity-filter button[data-severity="today"].active {
    color: #1d4ed8;
    background: linear-gradient(135deg, #bfdbfe, #dbeafe);
    border-color: #93c5fd;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-severity-filter button[data-severity="watch"].active {
    color: #334155;
    background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
    border-color: #cbd5e1;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-tabbar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 0.28rem;
    gap: 0.25rem;
  }
  html[data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-tabbar button.active {
    color: #1d4ed8;
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(37,99,235,.12);
  }
  html[data-theme="dark"][data-auth-ready="app"] body[data-route="notifications"] #app-content .notifications-kpi-card {
    background: linear-gradient(145deg,
      color-mix(in srgb, var(--notif-tone, #2563eb) 28%, #1e293b) 0%,
      color-mix(in srgb, var(--notif-tone, #2563eb) 14%, #0f172a) 100%) !important;
    border-color: color-mix(in srgb, var(--notif-tone, #2563eb) 34%, #334155) !important;
  }
}
.mobile-task-card-body { min-width: 0; flex: 1; }
.mobile-task-card-head { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.2rem; }
.mobile-task-card-head strong { font-size: 0.92rem; line-height: 1.25; }
.mobile-task-card-sub { margin: 0; color: var(--text-secondary); font-size: 0.82rem; line-height: 1.4; }
.mobile-task-card-meta { color: var(--text-muted); font-size: 0.68rem; font-weight: 700; }
.mobile-task-card-actions { display: flex; gap: 0.45rem; margin-top: 0.55rem; flex-wrap: wrap; }
.mobile-card-badge {
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--badge-tone, var(--brand-blue)) 12%, white);
  color: var(--badge-tone, var(--brand-blue));
}

/* Role home */
.mobile-role-home { margin-bottom: 0.85rem; }
.mobile-role-home-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-primary);
}
.mobile-role-home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}
.mobile-role-home-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,.22);
  background: linear-gradient(180deg, #fff, #f8fafc);
  cursor: pointer;
  text-align: left;
  min-height: 5.5rem;
}
.mobile-role-home-btn .material-symbols-outlined { color: var(--brand-blue); font-size: 1.35rem; }
.mobile-role-home-label { font-weight: 800; font-size: 0.82rem; color: var(--text-primary); }
.mobile-role-home-btn small { font-size: 0.62rem; color: var(--text-muted); }

/* Onboarding */
.mobile-onboard {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(7, 26, 51, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: end center;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}
.mobile-onboard-card {
  width: min(100%, 24rem);
  background: var(--surface-0);
  border-radius: 18px;
  padding: 1.1rem;
  box-shadow: 0 20px 50px rgba(15,23,42,.25);
}
.mobile-onboard-step { display: none; text-align: center; }
.mobile-onboard-step.active { display: block; }
.mobile-onboard-step .material-symbols-outlined { font-size: 2rem; color: var(--brand-blue); margin-bottom: 0.35rem; }
.mobile-onboard-nav { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.85rem; }

/* Session lock + biometric */
.session-lock-screen {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: rgba(7, 26, 51, 0.94);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.session-lock-card {
  width: min(100%, 22rem);
  text-align: center;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.session-lock-icon { font-size: 2.5rem; color: #93c5fd; }
.session-lock-card h2 { margin: 0; font-family: var(--font-display); }
.session-lock-card p { margin: 0; color: rgba(255,255,255,.78); line-height: 1.5; font-size: 0.9rem; }
.session-lock-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
}
.session-lock-actions.hidden { display: none; }
.session-lock-unlock-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
}
.session-lock-unlock-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,.88);
}
.session-lock-unlock-input {
  width: 100%;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,255,255,.25);
  color: #0b1528;
}
.session-lock-unlock-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.session-lock-card .btn { width: 100%; justify-content: center; }

@media (max-width: 1024px) {
  .data-table, .data-table-premium { display: block; overflow-x: auto; }
  .mobile-card-list + .data-table-wrap { margin-top: 0.75rem; }

  table.mobile-table-hidden,
  .mobile-table-hidden {
    display: none !important;
  }

  .mobile-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
  }

  .production-mobile-list {
    margin-top: 0.25rem;
  }

  .mobile-table-card {
    background: var(--surface-0, #fff);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    padding: 0.85rem 0.95rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  }

  .mobile-table-card--interactive {
    cursor: pointer;
  }

  .mobile-table-card--interactive:active {
    transform: scale(0.995);
  }

  .mobile-table-card-title {
    font-weight: 800;
    font-size: 0.92rem;
    color: var(--text-primary);
    margin-bottom: 0.55rem;
    line-height: 1.35;
  }

  .mobile-table-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
  }

  .mobile-table-card-row {
    display: grid;
    grid-template-columns: minmax(5.5rem, 38%) 1fr;
    gap: 0.55rem;
    align-items: start;
    font-size: 0.78rem;
  }

  .mobile-table-card-label {
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.62rem;
  }

  .mobile-table-card-value {
    color: var(--text-secondary);
    min-width: 0;
    word-break: break-word;
  }

  #app-bottomnav .bottomnav-item {
    position: relative;
  }

  #app-bottomnav .bottomnav-badge {
    position: absolute;
    top: 0.15rem;
    right: 0.35rem;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--error, #ef4444);
    color: #fff;
    font-size: 0.58rem;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
  }

  #app-bottomnav .bottomnav-search-btn {
    cursor: pointer;
    color: var(--text-muted);
  }

  #app-bottomnav .bottomnav-search-btn:active {
    color: var(--brand-blue);
    background: rgba(0, 70, 153, 0.08);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  #app-content > .page-container,
  .mobile-role-home,
  .mobile-table-card--interactive {
    animation: none !important;
    transition: none !important;
  }

  #app-launch-screen,
  #app-launch-screen * {
    animation: none !important;
    transition: none !important;
  }
}

/* Shared focus rings for shell controls */
.btn:focus-visible,
.icon-btn:focus-visible,
.bottomnav-item:focus-visible,
.nav-item:focus-visible,
.nav-group-header:focus-visible,
.mobile-menu-btn:focus-visible,
.mobile-action-btn:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
  outline: 2px solid var(--brand-blue, #0057ff);
  outline-offset: 2px;
}

.bottomnav-item:focus-visible {
  border-radius: 14px;
}

.nav-item:focus-visible,
.nav-group-header:focus-visible {
  border-radius: 10px;
}

/* Phone alerts — all screen sizes */
.phone-alerts-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  margin: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(0, 70, 153, 0.14);
  background: linear-gradient(135deg, rgba(0, 70, 153, 0.08), rgba(249, 115, 22, 0.06));
}

.phone-alerts-banner--compact {
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  padding: 0.75rem 1rem;
}

.phone-alerts-banner--on {
  border-color: rgba(34, 197, 94, 0.22);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(0, 70, 153, 0.04));
}

.phone-alerts-banner img {
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0, 70, 153, 0.22);
  width: 44px;
  height: 44px;
}

.phone-alerts-prompt__icon img {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(0, 70, 153, 0.24);
}

.phone-alerts-banner strong {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 0.12rem;
}

.phone-alerts-banner span {
  display: block;
  font-size: 0.66rem;
  line-height: 1.35;
  color: var(--text-muted, #64748b);
}

.phone-alerts-sheet-hero {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.phone-alerts-sheet-hero img {
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(0, 70, 153, 0.24);
  width: 72px;
  height: 72px;
}

.phone-alerts-sheet-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--surface-1, #f8fafc);
  font-size: 0.8rem;
}

/* Inventory + module polish on phone */
@media (max-width: 1024px) {
  body[data-route^="inventory"] #app-content,
  body[data-route="inventory"] #app-content {
    padding-inline: 0.55rem !important;
  }

  body[data-route^="inventory"] #app-content .page-container {
    padding-inline: 0 !important;
  }

  .inv-module--phone .inv-manager-bar {
    padding-bottom: 0.15rem;
  }

  .inv-module--phone .inv-branch-pill {
    border-radius: 12px;
    min-height: 2.5rem;
    padding: 0.45rem 0.7rem;
  }

  .mobile-sync-banner {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.01em;
  }

  .mobile-task-card {
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  }

  .mobile-task-card-actions .btn {
    min-height: 2.35rem;
    padding-inline: 0.75rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 800;
  }

  .inv-overview-v2 .inv-overview-head {
    display: none;
  }

  .inv-overview-v2 .inv-overview-actions {
    display: none;
  }

  .phone-alerts-prompt {
    position: fixed;
    left: 0.65rem;
    right: 0.65rem;
    bottom: calc(4.85rem + env(safe-area-inset-bottom, 0px));
    z-index: 1200;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.65rem;
    align-items: center;
    padding: 0.75rem 0.8rem;
    border-radius: 16px;
    border: 1px solid rgba(0, 70, 153, 0.14);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.16);
    animation: mobilePageIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  [data-theme="dark"] .phone-alerts-prompt {
    background: rgba(15, 23, 42, 0.94);
    border-color: rgba(148, 163, 184, 0.18);
  }

  .phone-alerts-prompt__icon img {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 14px;
    box-shadow: 0 8px 22px rgba(0, 70, 153, 0.24);
  }

  .phone-alerts-prompt__copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .phone-alerts-prompt__copy strong {
    font-size: 0.78rem;
    color: var(--text-primary, #0f172a);
  }

  .phone-alerts-prompt__copy span {
    font-size: 0.66rem;
    line-height: 1.35;
    color: var(--text-muted, #64748b);
  }

  .phone-alerts-prompt__actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
}

/* ── Phone stability — scroll, viewport, modals, overflow ── */
@media (max-width: 1024px) {
  :root {
    --app-vh: 100vh;
  }

  @supports (height: 100dvh) {
    :root { --app-vh: 100dvh; }
  }

  html {
    height: 100%;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
  }

  body {
    min-height: var(--app-vh);
    min-height: -webkit-fill-available;
    overflow-x: clip;
    max-width: 100vw;
    position: relative;
  }

  body.sidebar-is-open {
    overflow: hidden !important;
    touch-action: none;
  }

  #app-main,
  #app-content,
  #app-content > .page-container,
  #app-content > div {
    max-width: 100%;
    min-width: 0;
  }

  #app-content {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-behavior: auto;
  }

  .btn,
  .bottomnav-item,
  .nav-item,
  .icon-btn,
  .mobile-menu-btn,
  .mobile-action-btn {
    touch-action: manipulation;
  }

  .modal-overlay,
  .modal-backdrop {
    padding: env(safe-area-inset-top, 0px) 0.65rem env(safe-area-inset-bottom, 0px);
    align-items: flex-end;
  }

  .modal,
  .modal-dialog,
  .modal-box {
    width: min(100%, 32rem);
    max-height: min(88dvh, calc(var(--app-vh, 100vh) - 2rem));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: env(safe-area-inset-bottom, 0px);
  }

  .data-table-wrap,
  .table-responsive,
  .table-scroll,
  .sec-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  img,
  video,
  canvas,
  svg {
    max-width: 100%;
    height: auto;
  }

  [style*="grid-template-columns"] {
    min-width: 0;
  }

  .mobile-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-width: 0;
  }

  .mobile-table-card {
    border: 1px solid var(--border, rgba(148, 163, 184, 0.28));
    border-radius: 14px;
    background: var(--surface-0, #fff);
    padding: 0.85rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  }

  .mobile-sync-banner {
    cursor: pointer;
    user-select: none;
  }
}
