:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --leading-tight: 1.25;
  --leading-body: 1.45;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 42, 67, 0.05);
  --shadow-md: 0 8px 24px rgba(16, 42, 67, 0.06);
  --shadow-lg: 0 18px 40px rgba(16, 42, 67, 0.12);

  --color-bg: #f4f6f9;
  --color-bg-muted: #eef2f6;
  --color-surface: #ffffff;
  --color-surface-2: #f8fafc;
  --color-text: #102a43;
  --color-muted: #627d98;
  --color-faint: #9aa8b8;
  --color-border: #d9e2ec;
  --color-border-strong: #bcccdc;

  --color-primary: #0f4c81;
  --color-primary-hover: #0c3c65;
  --color-primary-active: #0a3356;
  --color-primary-soft: #e8f0f8;

  --color-success: #027a48;
  --color-success-soft: #ecfdf3;
  --color-warning: #b54708;
  --color-warning-soft: #fff7ed;
  --color-danger: #b42318;
  --color-danger-soft: #fef3f2;
  --color-info: #175cd3;
  --color-info-soft: #eff8ff;

  --color-sidebar: #0b1f33;
  --color-sidebar-text: rgba(255, 255, 255, 0.78);
  --color-live: #12b76a;

  --tap: 44px;
  --sidebar-w: 260px;
  --font: Inter, "IBM Plex Sans Arabic", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --focus: 0 0 0 3px rgba(15, 76, 129, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 16px;
  line-height: var(--leading-body);
  letter-spacing: -0.011em;
  -webkit-text-size-adjust: 100%;
}

html[dir="rtl"] {
  font-family: "IBM Plex Sans Arabic", Inter, ui-sans-serif, system-ui, sans-serif;
}

body {
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

img,
svg {
  max-width: 100%;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ——— App shell ——— */
.app-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  background: var(--color-sidebar);
  color: #fff;
  padding: var(--space-6) var(--space-4);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.brand-block {
  margin-bottom: var(--space-6);
  padding-inline: var(--space-2);
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.brand-block h1,
.login-card h1 {
  margin: 6px 0 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.nav-section {
  margin: var(--space-4) 0 var(--space-2);
  padding-inline: var(--space-3);
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: var(--space-3);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-sidebar-text);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link.active {
  background: #fff;
  color: var(--color-primary);
}

.workspace {
  display: flex;
  min-width: 0;
  min-height: 100dvh;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 12px var(--space-6);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.topbar-title {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.topbar-sub {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

.user-chip {
  display: grid;
  text-align: end;
}

.user-chip strong {
  font-size: var(--text-sm);
}

.user-chip span {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.nav-toggle,
.icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  flex: none;
}

.icon-btn {
  display: inline-flex;
}

.icon-btn svg,
.nav-toggle svg {
  width: 18px;
  height: 18px;
}

.nav-scrim {
  display: none;
}

.page {
  padding: var(--space-6);
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.page.inventory-view {
  padding: var(--space-4) var(--space-5) var(--space-6);
  max-width: none;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-header h2,
.section-header h2,
.modal h2 {
  margin: 0 0 6px;
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.03em;
  line-height: var(--leading-tight);
}

.page-header p,
.modal > p {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-md);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--color-primary-active);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-surface-2);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.95);
}

.btn-danger-ghost {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: #fecdca;
}

.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: var(--text-xs);
}

.btn-block {
  width: 100%;
}

.btn .spinner {
  width: 14px;
  height: 14px;
}

/* ——— Forms ——— */
.form-grid {
  display: grid;
  gap: var(--space-3);
}

.field {
  display: grid;
  gap: 6px;
}

.field-label,
label {
  display: grid;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-muted);
}

.req {
  color: var(--color-danger);
}

.help {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--color-faint);
}

.field-error {
  color: var(--color-danger);
  font-size: var(--text-sm);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #93c5fd;
  box-shadow: var(--focus);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--color-bg-muted);
  color: var(--color-muted);
}

.search-field {
  position: relative;
  min-width: min(280px, 100%);
  flex: 1;
}

.search-field svg {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-muted);
  pointer-events: none;
}

.search-field input {
  padding-inline-start: 38px;
  background: var(--color-surface-2);
}

.checkbox {
  width: auto;
  min-height: 0;
  accent-color: var(--color-primary);
}

/* ——— Surfaces ——— */
.card,
.panel,
.store-card,
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.stat-card {
  padding: var(--space-4);
}

.stat-card .label {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  margin: 6px 0 0;
  font-size: 1.375rem;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: var(--space-4);
  background: var(--color-surface);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.tab {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

.tab.active {
  background: var(--color-primary);
  color: #fff;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: var(--space-4);
}

.store-card {
  padding: var(--space-5);
  min-width: 0;
}

.store-card h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

.store-card-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: flex-start;
  margin-bottom: var(--space-3);
}

.store-meta {
  display: grid;
  gap: 6px;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.store-meta .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.mono,
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.num {
  text-align: end;
  font-weight: var(--weight-medium);
}

.muted {
  color: var(--color-muted);
}

.card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

/* ——— Status ——— */
.badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-full);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.status-badge.online,
.status-badge.success,
.status-badge.synced {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.status-badge.stale,
.status-badge.degraded,
.status-badge.warning,
.status-badge.syncing {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.status-badge.offline,
.status-badge.error,
.status-badge.danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.status-badge.info,
.status-badge.connecting {
  background: var(--color-info-soft);
  color: var(--color-info);
}

.status-badge.neutral,
.status-badge.inactive {
  background: var(--color-bg-muted);
  color: var(--color-muted);
}

.badge-pharmacy {
  background: #eef2ff;
  color: #3730a3;
}

.badge-retail {
  background: #ecfeff;
  color: #0f766e;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ——— Empty / error / loading ——— */
.empty-state,
.error-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-muted);
}

.empty-state h3,
.error-state h3 {
  margin: 0 0 8px;
  color: var(--color-text);
  font-size: var(--text-lg);
}

.empty-state p,
.error-state p {
  margin: 0 auto 16px;
  max-width: 36rem;
}

.tech-detail {
  margin-top: var(--space-3);
  text-align: start;
}

.tech-detail pre {
  margin: 8px 0 0;
  padding: 10px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  overflow: auto;
  font-size: 11px;
  color: var(--color-muted);
}

.skeleton {
  background: linear-gradient(90deg, #eef2f6 25%, #f8fafc 37%, #eef2f6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
  border-radius: var(--radius-md);
  min-height: 16px;
}

.skeleton-card {
  height: 148px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner.dark {
  border-color: rgba(15, 76, 129, 0.2);
  border-top-color: var(--color-primary);
}

/* ——— Login ——— */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--color-bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  box-shadow: var(--shadow-md);
}

.login-card p {
  margin: 8px 0 24px;
  color: var(--color-muted);
}

/* ——— Inventory ——— */
.inventory-crumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: 8px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right,
.toolbar-group,
.pager-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--color-bg-muted);
  color: var(--color-text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu {
  position: relative;
}

.menu summary {
  list-style: none;
  cursor: pointer;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu-list {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 4px);
  z-index: 12;
  min-width: 220px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: 8px;
  cursor: pointer;
  text-align: start;
}

.menu-item:hover {
  background: var(--color-surface-2);
}

.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: calc(100dvh - 220px);
  -webkit-overflow-scrolling: touch;
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none !important;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  font-size: var(--text-sm);
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--color-border);
  padding: 8px 12px;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--color-surface-2);
  text-align: start;
  z-index: 2;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
  font-weight: var(--weight-semibold);
}

.data-table tbody tr:hover {
  background: #f8fbff;
}

.data-table tbody tr.flash {
  animation: flash 1.1s ease;
}

.data-table tr.editing {
  background: #fffbeb;
}

.cell-input {
  min-width: 72px;
  min-height: 32px;
  height: 32px;
  padding: 2px 6px;
  font-size: var(--text-sm);
}

.check-col {
  width: 40px;
  text-align: center;
}

.item-name {
  font-weight: var(--weight-medium);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-actions {
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 8px 10px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  bottom: 0;
  flex-wrap: wrap;
}

.pager select {
  width: auto;
  min-width: 108px;
  min-height: 36px;
}

.inv-card-list {
  display: grid;
  gap: var(--space-3);
}

.inv-card {
  padding: var(--space-4);
  min-width: 0;
}

.inv-card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

.inv-card-meta {
  margin-top: 4px;
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.inv-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.inv-stat {
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-width: 0;
}

.inv-stat span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

.inv-stat strong {
  display: block;
  margin-top: 2px;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-card details {
  margin-top: var(--space-3);
}

.inv-card summary {
  cursor: pointer;
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

/* ——— Modal / drawer ——— */
[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 31, 51, 0.48);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 40;
}

.modal {
  width: min(560px, 100%);
  max-height: min(88dvh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pairing-box {
  background: var(--color-surface-2);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.toast-stack {
  position: fixed;
  inset-inline-end: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 24px));
}

.toast {
  background: #0f1f33;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
}

.toast.success {
  background: #065f46;
}

.toast.error {
  background: #9b1c1c;
}

.filters-drawer {
  display: none;
}

@keyframes flash {
  from { background: #d1fae5; }
  to { background: transparent; }
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ——— Responsive ——— */
@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(300px, 88vw);
    z-index: 30;
    transform: translateX(-110%);
    transition: transform 0.2s ease, visibility 0.2s ease;
    min-height: 100dvh;
    visibility: hidden;
    pointer-events: none;
  }

  html[dir="rtl"] .sidebar {
    transform: translateX(110%);
  }

  .app-shell.nav-open .sidebar {
    transform: none;
    visibility: visible;
    pointer-events: auto;
  }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(15, 31, 51, 0.45);
    border: 0;
    min-height: 0;
    padding: 0;
  }

  .nav-scrim[hidden] {
    display: none;
  }

  .topbar,
  .page,
  .page.inventory-view {
    padding: 12px 16px;
  }

  .page-header,
  .sheet-toolbar,
  .toolbar,
  .header-actions {
    flex-wrap: wrap;
  }

  .user-chip {
    display: none;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: block !important;
  }

  .inv-card-list.mobile-only {
    display: grid !important;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 767px) {
  .page-header,
  .sheet-toolbar,
  .toolbar,
  .header-actions,
  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header h2 {
    font-size: 1.25rem;
  }

  .btn,
  .tab {
    min-height: var(--tap);
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  }

  .toast-stack {
    inset-inline: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: none;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 430px) {
  .stat-grid,
  .inv-card-stats {
    grid-template-columns: 1fr 1fr;
  }

  .store-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1440px) {
  .page:not(.inventory-view) {
    max-width: 1440px;
  }
}
