/* Wiggy Mobile PWA v1 - additive mobile styles; desktop application remains untouched. */
:root {
  --wiggy-navy: #142039;
  --wiggy-navy-soft: #20304f;
  --wiggy-pink: #e51263;
  --wiggy-pink-dark: #be0c4d;
  --wiggy-green: #139a70;
  --wiggy-surface: #ffffff;
  --wiggy-page: #f4f6fa;
  --wiggy-border: #dbe1eb;
  --wiggy-muted: #63728d;
  --wiggy-mobile-nav-height: 68px;
}

.wiggy-mobile-nav,
.wiggy-more-overlay,
.wiggy-install-help,
.wiggy-network-status,
.wiggy-install-banner,
.wiggy-pwa-toasts {
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wiggy-mobile-nav,
.wiggy-more-overlay,
.wiggy-install-help,
.wiggy-install-banner,
.wiggy-network-status {
  display: none;
}

.wiggy-pwa-toasts {
  position: fixed;
  z-index: 2147483646;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(390px, calc(100vw - 32px));
  gap: 10px;
  pointer-events: none;
}

.wiggy-pwa-toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  color: #17223a;
  background: #fff;
  border: 1px solid #dce3ed;
  border-left: 4px solid #42699e;
  border-radius: 13px;
  box-shadow: 0 14px 42px rgba(20, 32, 57, .2);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(12px);
  transition: .22s ease;
  pointer-events: auto;
}

.wiggy-pwa-toast.is-visible { opacity: 1; transform: none; }
.wiggy-pwa-toast.is-warning { border-left-color: #dc8a18; }
.wiggy-pwa-toast.is-error { border-left-color: #d13a4b; }
.wiggy-pwa-toast.is-success { border-left-color: var(--wiggy-green); }
.wiggy-pwa-toast button {
  min-height: 36px;
  padding: 0 13px;
  color: #fff;
  background: var(--wiggy-navy);
  border: 0;
  border-radius: 9px;
  font: inherit;
  cursor: pointer;
}

@media (max-width: 900px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background: var(--wiggy-page);
  }

  body {
    overscroll-behavior-y: none;
    padding-bottom: calc(var(--wiggy-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  html.wiggy-pwa-standalone body {
    padding-top: env(safe-area-inset-top, 0px);
  }

  body.wiggy-sheet-open { overflow: hidden !important; }

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

  button,
  [role="button"] {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .wiggy-mobile-nav {
    position: fixed;
    z-index: 2147483000;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: calc(var(--wiggy-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 5px 6px env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--wiggy-border);
    box-shadow: 0 -10px 34px rgba(20, 32, 57, .12);
    backdrop-filter: blur(18px);
  }

  /* Keep native React dialogs (camera, stock, refund, barcode designer, etc.)
     completely unobstructed. The class is maintained by the companion JS. */
  body.wiggy-native-modal-open .wiggy-mobile-nav,
  body.wiggy-native-modal-open .wiggy-install-banner {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .wiggy-mobile-nav button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 54px;
    padding: 4px 2px;
    color: #6d7890;
    background: transparent;
    border: 0;
    border-radius: 13px;
    font: 700 11px/1.2 Inter, "Segoe UI", sans-serif;
    cursor: pointer;
  }

  .wiggy-mobile-nav button > svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .wiggy-mobile-nav button[data-screen="dashboard"] > svg path {
    fill: currentColor;
    stroke: none;
  }

  .wiggy-mobile-nav button.is-active { color: var(--wiggy-pink); }

  .wiggy-mobile-nav button.is-active::before {
    content: "";
    position: absolute;
    top: -5px;
    width: 22px;
    height: 3px;
    background: var(--wiggy-pink);
    border-radius: 0 0 5px 5px;
  }

  .wiggy-mobile-nav .wiggy-mobile-scan {
    overflow: visible;
    color: var(--wiggy-navy);
    transform: translateY(-12px);
  }

  .wiggy-mobile-scan-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    color: #fff;
    background: linear-gradient(145deg, #f12671, var(--wiggy-pink-dark));
    border: 4px solid #fff;
    border-radius: 18px;
    box-shadow: 0 8px 22px rgba(229, 18, 99, .35);
  }

  .wiggy-mobile-scan-icon svg {
    width: 25px;
    height: 25px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .wiggy-more-overlay,
  .wiggy-install-help {
    position: fixed;
    z-index: 2147483500;
    inset: 0;
    display: flex;
    visibility: hidden;
    align-items: flex-end;
    justify-content: center;
    padding: 18px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(9, 17, 34, .58);
    opacity: 0;
    transition: opacity .22s ease, visibility .22s;
    backdrop-filter: blur(5px);
  }

  .wiggy-more-overlay.is-open,
  .wiggy-install-help.is-open {
    visibility: visible;
    opacity: 1;
  }

  .wiggy-more-sheet {
    width: min(100%, 520px);
    max-height: min(82vh, 720px);
    padding: 8px 16px 16px;
    overflow: auto;
    color: #17223a;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
    transform: translateY(28px);
    transition: transform .24s ease;
  }

  .wiggy-more-overlay.is-open .wiggy-more-sheet { transform: none; }

  .wiggy-sheet-grabber {
    width: 42px;
    height: 4px;
    margin: 1px auto 13px;
    background: #d7dce5;
    border-radius: 999px;
  }

  .wiggy-sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
  }

  .wiggy-sheet-head small,
  .wiggy-install-help section > small {
    color: var(--wiggy-pink);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .12em;
  }

  .wiggy-sheet-head h2,
  .wiggy-install-help h2 {
    margin: 3px 0 0;
    color: var(--wiggy-navy);
    font-size: 22px;
    line-height: 1.25;
  }

  .wiggy-sheet-head > button,
  .wiggy-install-help section > button[data-close]:first-child {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    color: #65728a;
    background: #f6f8fb;
    border: 1px solid var(--wiggy-border);
    border-radius: 13px;
  }

  .wiggy-sheet-head svg,
  .wiggy-install-help section > button[data-close]:first-child svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
  }

  .wiggy-sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
  }

  .wiggy-sheet-grid button {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 56px;
    padding: 10px 12px;
    color: #273652;
    background: #f7f9fc;
    border: 1px solid #e1e6ef;
    border-radius: 14px;
    font: 750 13px/1.25 Inter, "Segoe UI", sans-serif;
    text-align: left;
  }

  .wiggy-sheet-grid svg,
  .wiggy-install-sheet-button > svg {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: var(--wiggy-pink);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .wiggy-install-sheet-button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 62px;
    margin-top: 12px;
    padding: 10px 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--wiggy-navy), #263c66);
    border: 0;
    border-radius: 15px;
    text-align: left;
  }

  .wiggy-install-sheet-button > svg { stroke: #fff; margin-right: 12px; }
  .wiggy-install-sheet-button span { display: grid; gap: 2px; }
  .wiggy-install-sheet-button strong { font-size: 14px; }
  .wiggy-install-sheet-button small { color: #cbd5e8; font-size: 11px; }

  .wiggy-network-status {
    position: fixed;
    z-index: 2147483400;
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: 50%;
    display: flex;
    align-items: center;
    gap: 7px;
    max-width: calc(100vw - 24px);
    padding: 9px 13px;
    color: #155d49;
    background: #e8f7f1;
    border: 1px solid #bfe6d8;
    border-radius: 999px;
    box-shadow: 0 10px 28px rgba(20, 32, 57, .16);
    font-size: 12px;
    font-weight: 800;
    opacity: 0;
    transform: translate(-50%, -14px);
    transition: .2s ease;
    pointer-events: none;
  }

  .wiggy-network-status.is-visible { opacity: 1; transform: translate(-50%, 0); }
  .wiggy-network-status.is-offline { color: #8d381d; background: #fff2e9; border-color: #f3c7ad; }
  .wiggy-network-status span { width: 8px; height: 8px; background: var(--wiggy-green); border-radius: 999px; }
  .wiggy-network-status.is-offline span { background: #dc5b36; }

  .wiggy-install-banner {
    position: fixed;
    z-index: 2147483300;
    left: 10px;
    right: 10px;
    bottom: calc(var(--wiggy-mobile-nav-height) + 10px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: 42px 1fr auto 36px;
    align-items: center;
    gap: 10px;
    padding: 11px;
    color: #17223a;
    background: rgba(255,255,255,.98);
    border: 1px solid var(--wiggy-border);
    border-radius: 17px;
    box-shadow: 0 18px 52px rgba(20, 32, 57, .25);
  }

  .wiggy-install-mini-logo,
  .wiggy-install-logo {
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, #ff8c42, var(--wiggy-pink));
    font-weight: 900;
  }

  .wiggy-install-mini-logo { width: 42px; height: 42px; border-radius: 13px; font-size: 12px; }
  .wiggy-install-banner > div:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
  .wiggy-install-banner strong { font-size: 13px; line-height: 1.2; }
  .wiggy-install-banner span { overflow: hidden; color: var(--wiggy-muted); font-size: 10px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
  .wiggy-install-banner [data-install] { min-height: 38px; padding: 0 14px; color: #fff; background: var(--wiggy-pink); border: 0; border-radius: 11px; font-weight: 800; }
  .wiggy-install-banner [data-dismiss] { display: grid; place-items: center; width: 36px; height: 36px; color: #6d7890; background: transparent; border: 0; }
  .wiggy-install-banner [data-dismiss] svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; }

  .wiggy-install-help { align-items: center; }
  .wiggy-install-help section {
    position: relative;
    width: min(100%, 430px);
    padding: 24px;
    color: #24314d;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 24px 70px rgba(0,0,0,.28);
    text-align: center;
    transform: scale(.96);
    transition: transform .22s ease;
  }
  .wiggy-install-help.is-open section { transform: none; }
  .wiggy-install-help section > button[data-close]:first-child { position: absolute; top: 14px; right: 14px; }
  .wiggy-install-logo { width: 66px; height: 66px; margin: 8px auto 14px; border-radius: 21px; font-size: 18px; box-shadow: 0 10px 30px rgba(229,18,99,.25); }
  .wiggy-install-help p { margin: 12px 0; color: var(--wiggy-muted); font-size: 14px; }
  .wiggy-install-help ol { margin: 0 0 18px; padding: 13px 13px 13px 36px; color: #35415a; background: #f6f8fb; border-radius: 14px; font-size: 14px; line-height: 1.55; text-align: left; }
  .wiggy-install-help li + li { margin-top: 7px; }
  .wiggy-install-understood { width: 100%; min-height: 46px; color: #fff; background: var(--wiggy-pink); border: 0; border-radius: 13px; font-weight: 850; }

  .wiggy-pwa-toasts {
    right: 10px;
    bottom: calc(var(--wiggy-mobile-nav-height) + 12px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 20px);
  }

  .wiggy-pwa-toast { font-size: 13px; }

  /* Existing React application: mobile-only usability safeguards. */
  .page-header,
  .section-header,
  .content-header,
  main > header {
    flex-wrap: wrap;
  }

  .header-actions,
  .page-actions,
  .action-group {
    flex-wrap: wrap !important;
    max-width: 100%;
    gap: 8px !important;
  }

  [role="dialog"] {
    max-width: calc(100vw - 16px);
  }

  table {
    min-width: max-content;
  }

  .table-wrap,
  .table-container,
  .data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 430px) {
  .wiggy-mobile-nav button { font-size: 10.5px; }
  .wiggy-sheet-grid { grid-template-columns: 1fr; }
  .wiggy-install-banner { grid-template-columns: 40px 1fr auto 32px; }
  .wiggy-install-banner span { max-width: 150px; }
}

@media print {
  .wiggy-mobile-nav,
  .wiggy-more-overlay,
  .wiggy-install-help,
  .wiggy-install-banner,
  .wiggy-network-status,
  .wiggy-pwa-toasts { display: none !important; }
}
