:root {
  --pwa-brand: #1a51f5;
  --pwa-brand-dark: #0d39d8;
  --pwa-tab-h: 4.25rem;
  --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pwa-safe-top: env(safe-area-inset-top, 0px);
}

html.pwa-standalone {
  overscroll-behavior: none;
}

html.pwa-standalone body {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

html.pwa-standalone input,
html.pwa-standalone textarea,
html.pwa-standalone select,
html.pwa-standalone [contenteditable] {
  user-select: auto;
  -webkit-user-select: auto;
}

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

.pwa-topbar {
  padding-top: var(--pwa-safe-top);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.92);
}

html.pwa-standalone .pwa-topbar {
  border-bottom-color: rgba(229, 231, 235, 0.8);
}

.pwa-main {
  padding-bottom: calc(var(--pwa-tab-h) + var(--pwa-safe-bottom) + 0.5rem);
}

@media (min-width: 1024px) {
  .pwa-main {
    padding-bottom: 0;
  }
}

.pwa-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  height: calc(var(--pwa-tab-h) + var(--pwa-safe-bottom));
  padding-bottom: var(--pwa-safe-bottom);
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid rgba(229, 231, 235, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
}

@media (min-width: 1024px) {
  .pwa-bottom-nav {
    display: none;
  }
}

.pwa-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: var(--pwa-tab-h);
  padding: 0.35rem 0.25rem 0.5rem;
  color: #6b7280;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: color 0.15s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.pwa-tab i {
  font-size: 1.125rem;
  line-height: 1;
}

.pwa-tab.is-active {
  color: var(--pwa-brand);
}

.pwa-tab.is-active i {
  transform: scale(1.05);
}

.pwa-tab:active {
  transform: scale(0.96);
}

.pwa-install-banner {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(var(--pwa-tab-h) + var(--pwa-safe-bottom) + 0.75rem);
  z-index: 46;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, #1a51f5 0%, #0d39d8 100%);
  color: #fff;
  box-shadow: 0 12px 32px rgba(26, 81, 245, 0.35);
}

@media (min-width: 1024px) {
  .pwa-install-banner {
    left: auto;
    right: 1rem;
    bottom: 1rem;
    max-width: 22rem;
  }
}

.pwa-install-banner[hidden] {
  display: none !important;
}

.pwa-install-banner__icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.pwa-install-banner__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pwa-install-banner__text {
  flex: 1;
  min-width: 0;
}

.pwa-install-banner__text strong {
  display: block;
  font-size: 0.875rem;
  line-height: 1.3;
}

.pwa-install-banner__text span {
  display: block;
  font-size: 0.75rem;
  opacity: 0.88;
  margin-top: 0.125rem;
}

.pwa-install-banner__actions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex-shrink: 0;
}

.pwa-install-banner__actions button {
  border: 0;
  border-radius: 0.625rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.pwa-install-banner__install {
  background: #fff;
  color: var(--pwa-brand-dark);
}

.pwa-install-banner__dismiss {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
}

html.pwa-standalone .pwa-install-banner {
  display: none !important;
}

@media (max-width: 1023px) {
  html.pwa-standalone .pwa-topbar .lg\\:hidden {
    visibility: visible;
  }

  .pwa-app-shell .bg-white.rounded-xl,
  .pwa-app-shell table {
    border-radius: 1rem;
  }

  .pwa-app-shell main {
    -webkit-overflow-scrolling: touch;
  }

  .pwa-app-shell .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }
}

/* Horizontal scroll rows (filters, tabs) */
.scrollbar-thin {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.scrollbar-thin::-webkit-scrollbar {
  height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.55);
  border-radius: 999px;
}
