:root {
  --pwa-safe-top: env(safe-area-inset-top, 0px);
  --pwa-safe-right: env(safe-area-inset-right, 0px);
  --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pwa-safe-left: env(safe-area-inset-left, 0px);
}

html {
  min-height: 100%;
  background: #f4f8fa;
}

body {
  min-height: 100%;
  padding-right: var(--pwa-safe-right);
  padding-bottom: var(--pwa-safe-bottom);
  padding-left: var(--pwa-safe-left);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  touch-action: manipulation;
}

.pwa-connection-indicator {
  position: fixed;
  z-index: 1000;
  right: max(12px, var(--pwa-safe-right));
  bottom: max(12px, var(--pwa-safe-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #b8dcd3;
  border-radius: 999px;
  color: #075e55;
  background: rgba(242, 249, 247, 0.96);
  box-shadow: 0 8px 28px rgba(23, 33, 37, 0.13);
  font-size: 11px;
  font-weight: 700;
  transition: opacity 180ms ease, transform 180ms ease;
}

.pwa-connection-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #70c465;
  box-shadow: 0 0 0 4px rgba(112, 196, 101, 0.16);
}

.pwa-connection-indicator.quiet {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.pwa-connection-indicator.offline {
  color: #8f2b1c;
  border-color: #f1b7ac;
  background: rgba(255, 241, 238, 0.98);
}

.pwa-connection-indicator.offline span {
  background: #f15b3d;
  box-shadow: 0 0 0 4px rgba(241, 91, 61, 0.15);
}

.pwa-install-button {
  position: fixed;
  z-index: 940;
  left: max(14px, var(--pwa-safe-left));
  bottom: max(14px, var(--pwa-safe-bottom));
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: #079ed2;
  box-shadow: 0 12px 34px rgba(7, 158, 210, 0.3);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.pwa-install-button[hidden] {
  display: none;
}

.pwa-install-button .material-symbols-rounded {
  font-size: 21px;
}

.pwa-install-help {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 20px max(16px, var(--pwa-safe-right))
    max(20px, var(--pwa-safe-bottom)) max(16px, var(--pwa-safe-left));
  background: rgba(23, 29, 27, 0.42);
  backdrop-filter: blur(8px);
}

.pwa-install-help.hidden {
  display: none;
}

.pwa-install-help-card {
  position: relative;
  width: min(430px, 100%);
  padding: 28px 24px 26px;
  border: 1px solid #dce3e0;
  border-radius: 28px;
  color: #171d1b;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(17, 29, 26, 0.24);
}

.pwa-install-help-card h2 {
  margin: 14px 0 8px;
  font-size: 24px;
}

.pwa-install-help-card p {
  margin: 0;
  color: #53605c;
  font-size: 14px;
  line-height: 1.6;
}

.pwa-install-help-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #005f7a;
  background: #cdeffd;
  font-size: 27px;
}

.pwa-install-help-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #53605c;
  background: #eff3f2;
  font-size: 24px;
  cursor: pointer;
}

@media (display-mode: standalone) {
  body {
    padding-top: var(--pwa-safe-top);
  }

  .app-header {
    top: var(--pwa-safe-top);
  }
}

@media (max-width: 720px) {
  .login-page {
    width: min(100% - 20px, 520px);
  }

  .login-form-card {
    order: -1;
  }

  .login-brand-card {
    min-height: 310px;
  }

  .login-copy h1 {
    font-size: clamp(34px, 11vw, 46px);
  }

  .login-copy p {
    display: none;
  }

  .brand-tags {
    gap: 6px;
  }

  .brand-tag {
    padding: 7px 10px;
    font-size: 10px;
  }

  .app-header {
    position: sticky;
    top: var(--pwa-safe-top);
    z-index: 90;
    padding: 13px 14px;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 10px 26px rgba(23, 29, 27, 0.09);
  }

  .header-brand {
    width: 100%;
  }

  .header-user {
    gap: 8px;
  }

  .header-user .user-meta {
    min-width: 0;
  }

  .header-user .user-meta strong,
  .header-user .user-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cashier-hero,
  .dashboard-hero {
    padding: 22px 20px;
  }

  .dashboard-sidebar {
    overflow: hidden;
  }

  .sidebar-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar-item {
    min-width: 156px;
    scroll-snap-align: start;
  }

  .field input,
  .field select,
  .field textarea,
  .btn {
    min-height: 48px;
    font-size: 16px;
  }

  .table-scroller {
    margin-right: -8px;
    margin-left: -8px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .modal-card {
    padding-bottom: calc(22px + var(--pwa-safe-bottom));
  }
}

@media (max-width: 430px) {
  .login-form-card {
    padding: 24px 18px;
  }

  .login-brand-card {
    min-height: 280px;
    padding: 22px 18px;
  }

  .official-logo-large {
    max-width: 250px;
  }

  .header-brand > div:last-child p {
    display: none;
  }

  .header-user .btn {
    min-height: 42px;
    padding: 8px 13px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-connection-indicator {
    transition: none;
  }
}
