* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-height: 100%;
  background: var(--ds-bg, #101217);
  color-scheme: dark;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(115, 59, 229, .22), transparent 34%),
    var(--ds-bg, #101217);
  color: var(--ds-text, rgba(255, 255, 255, .92));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button { cursor: pointer; }

.pwa-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}

.pwa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
}

.pwa-brand,
.pwa-brand > span:last-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pwa-brand > span:last-child { align-items: flex-start; flex-direction: column; gap: 2px; }
.pwa-brand small { color: var(--ds-text-muted); font-size: 12px; }

.pwa-brand__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: #733be5;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.pwa-brand__mark--large { width: 70px; height: 70px; border-radius: 22px; font-size: 22px; }

.pwa-icon-button,
.pwa-back {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--ds-border);
  border-radius: 12px;
  background: var(--ds-surface-1);
  color: var(--ds-text);
}

.pwa-sync-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0 0 16px;
  padding: 8px 10px;
  border: 1px solid var(--ds-border);
  border-radius: 12px;
  background: rgba(20, 24, 35, .88);
  color: var(--ds-text-muted);
  font-size: 13px;
}

.pwa-sync-bar__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ds-text-dim); }
.pwa-sync-bar__dot.is-online { background: var(--ds-success); }
.pwa-sync-bar__dot.is-error { background: var(--ds-danger); }
.pwa-sync-bar button { margin-left: auto; border: 0; background: transparent; color: #a98cff; }

.pwa-main { min-height: calc(100dvh - 150px); }
.pwa-view { display: grid; align-content: start; gap: 14px; padding-bottom: 24px; }

.pwa-login {
  min-height: calc(100dvh - 90px);
  align-content: center;
}

.pwa-login__brand { display: grid; justify-items: center; margin-bottom: 12px; text-align: center; }
.pwa-login__brand h1 { margin: 14px 0 4px; font-size: 28px; }
.pwa-login__brand p { margin: 0; color: var(--ds-text-muted); }

.pwa-heading,
.pwa-view-header,
.pwa-section__heading,
.pwa-count-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pwa-heading { align-items: flex-start; margin: 8px 0; }
.pwa-heading h1,
.pwa-view-header h1 { margin: 3px 0 0; font-size: clamp(23px, 7vw, 30px); line-height: 1.15; }
.pwa-view-header { justify-content: flex-start; }
.pwa-view-header > div { min-width: 0; flex: 1; }
.pwa-view-header .pwa-count-badge { flex: 0 0 auto; }

.pwa-eyebrow { margin: 0; color: #a98cff; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.pwa-pending,
.pwa-count-badge { padding: 7px 9px; border: 1px solid var(--ds-border); border-radius: 999px; background: var(--ds-surface-1); color: var(--ds-text-muted); font-size: 12px; white-space: nowrap; }

.pwa-card,
.pwa-action,
.pwa-activity__item,
.pwa-continue {
  border: 1px solid var(--ds-border);
  border-radius: 18px;
  background: var(--ds-surface-2);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .18);
}

.pwa-action {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  padding: 14px;
  color: var(--ds-text);
  text-align: left;
}

.pwa-action > span:nth-child(2) { display: grid; gap: 4px; }
.pwa-action small { color: var(--ds-text-muted); }
.pwa-action__icon { display: grid; width: 50px; height: 50px; place-items: center; border-radius: 15px; background: rgba(115, 59, 229, .16); color: #bba7ff; font-size: 24px; }

.pwa-form { display: grid; gap: 18px; padding: 18px; }
.pwa-form h2 { margin: 0 0 5px; font-size: 20px; }
.pwa-form p { margin: 0; color: var(--ds-text-muted); }
.pwa-form label { display: grid; gap: 8px; }
.pwa-form label > span { color: var(--ds-text-muted); font-size: 13px; }

.pwa-form input,
.pwa-form select,
.pwa-form textarea,
.pwa-inline-form input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--ds-border-strong);
  border-radius: 13px;
  outline: none;
  background: var(--ds-surface-1);
  color: var(--ds-text);
}

.pwa-form textarea { min-height: 104px; resize: vertical; }
.pwa-form input:focus,
.pwa-form select:focus,
.pwa-form textarea:focus,
.pwa-inline-form input:focus { border-color: rgba(169, 140, 255, .75); box-shadow: 0 0 0 3px rgba(115, 59, 229, .18); }

.pwa-button {
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid var(--ds-border-strong);
  border-radius: 14px;
  background: var(--ds-surface-1);
  color: var(--ds-text);
}

.pwa-button--primary { border-color: #733be5; background: #733be5; color: #fff; }
.pwa-button:disabled { opacity: .55; cursor: not-allowed; }

.pwa-inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.pwa-inline-form button { padding: 0 16px; border: 1px solid var(--ds-border-strong); border-radius: 13px; background: var(--ds-surface-2); color: var(--ds-text); }

.pwa-scanner {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 8px;
  overflow: hidden;
  border: 1px dashed rgba(169, 140, 255, .55);
  border-radius: 22px;
  background: rgba(20, 24, 35, .8);
  color: var(--ds-text-muted);
  text-align: center;
}

.pwa-scanner > span { color: #a98cff; font-size: 48px; }
.pwa-scanner p { margin: 0; }
.pwa-scanner video { border-radius: 18px; }

.pwa-product { display: flex; align-items: center; gap: 12px; }
.pwa-product > div { display: grid; gap: 4px; }
.pwa-product small { color: var(--ds-text-muted); }
.pwa-product__icon { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 15px; background: var(--ds-surface-3); color: #a98cff; }
.pwa-product-form input[name="cantidad"] { min-height: 76px; font-size: 32px; text-align: center; }

.pwa-readonly-badge { padding: 7px 9px; border: 1px solid rgba(169, 140, 255, .35); border-radius: 999px; background: rgba(115, 59, 229, .12); color: #c5b5ff; font-size: 12px; white-space: nowrap; }
.pwa-lookup-card { display: grid; gap: 18px; padding: 18px; }
.pwa-lookup-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0; }
.pwa-lookup-details > div { display: grid; min-width: 0; gap: 4px; }
.pwa-lookup-details dt { color: var(--ds-text-muted); font-size: 12px; }
.pwa-lookup-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.pwa-lookup-stock { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--ds-border); }
.pwa-lookup-stock > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pwa-lookup-stock > div:first-child span { color: var(--ds-text-muted); }
.pwa-lookup-stock > div:first-child strong { color: #c5b5ff; font-size: 22px; text-align: right; }
.pwa-lookup-warehouses { display: grid; gap: 8px; }
.pwa-lookup-warehouses > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--ds-border); border-radius: 12px; background: var(--ds-surface-1); }
.pwa-lookup-warehouses span { color: var(--ds-text-muted); }
.pwa-lookup-warehouses strong { text-align: right; }

.pwa-warning,
.pwa-note,
.pwa-error { padding: 11px 12px; border-radius: 12px; font-size: 13px; }
.pwa-warning { border: 1px solid rgba(255, 190, 92, .3); background: rgba(255, 190, 92, .08); color: #ffc978 !important; }
.pwa-note { border: 1px solid var(--ds-border); background: var(--ds-surface-1); }
.pwa-error { border: 1px solid rgba(255, 92, 122, .35); background: rgba(255, 92, 122, .08); color: var(--ds-danger) !important; }

.pwa-section { display: grid; gap: 10px; margin-top: 8px; }
.pwa-section h2 { margin: 0; font-size: 17px; }
.pwa-section__heading button { border: 0; background: transparent; color: #a98cff; }
.pwa-activity { display: grid; gap: 9px; }
.pwa-activity__item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 13px; }
.pwa-activity__item > div { display: grid; gap: 4px; }
.pwa-activity__item small { color: var(--ds-text-muted); }
.pwa-activity__status { color: #a98cff; font-size: 12px; text-align: right; }
.pwa-empty { margin: 0; padding: 18px; border: 1px dashed var(--ds-border); border-radius: 14px; color: var(--ds-text-muted); text-align: center; }

.pwa-continue-list { display: grid; gap: 9px; }
.pwa-continue { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 14px; }
.pwa-continue > div { display: grid; gap: 4px; }
.pwa-continue small { color: var(--ds-text-muted); }
.pwa-continue button { min-height: 44px; padding: 0 13px; border: 0; border-radius: 11px; background: rgba(115, 59, 229, .18); color: #c5b5ff; }

.pwa-receipt-upload { display: grid; gap: 8px; }
.pwa-receipt-upload > span,
.pwa-receipt-upload > small { color: var(--ds-text-muted); font-size: 13px; }
.pwa-receipt-upload__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pwa-receipt-upload__choice { display: grid; min-height: 50px; place-items: center; padding: 10px; border: 1px solid var(--ds-border-strong); border-radius: 13px; background: var(--ds-surface-1); color: var(--ds-text); cursor: pointer; text-align: center; }
.pwa-receipt-upload__choice:focus-visible,
.pwa-receipt-upload__choice:focus-within { border-color: rgba(169, 140, 255, .75); box-shadow: 0 0 0 3px rgba(115, 59, 229, .18); outline: none; }
.pwa-receipt-camera { display: grid; gap: 8px; padding: 8px; border: 1px solid var(--ds-border); border-radius: 14px; background: #0b0e15; }
.pwa-receipt-camera video { display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 10px; background: #05070b; object-fit: cover; }
.pwa-receipt-camera > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.pwa-receipt-camera button { min-height: 44px; padding: 9px 12px; border: 1px solid var(--ds-border-strong); border-radius: 10px; background: var(--ds-surface-2); color: var(--ds-text); }
.pwa-receipt-camera button:first-child { border-color: #733be5; background: #733be5; color: #fff; }
.pwa-receipt-upload__selection { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--ds-border); border-radius: 12px; background: var(--ds-surface-1); }
.pwa-receipt-upload__selection span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pwa-receipt-upload__selection button { flex: 0 0 auto; min-height: 36px; padding: 0 10px; border: 0; border-radius: 9px; background: rgba(115, 59, 229, .18); color: #c5b5ff; }

.pwa-count-footer { margin-top: 4px; }
.pwa-count-footer .pwa-button { flex: 1; }

.pwa-toast {
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 688px;
  margin: auto;
  padding: 13px 15px;
  border: 1px solid var(--ds-border-strong);
  border-radius: 13px;
  background: var(--ds-surface-3);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .35);
  color: var(--ds-text);
}

@media (min-width: 721px) {
  .pwa-shell { padding-inline: 24px; }
}

@media (max-width: 430px) {
  .pwa-lookup-details { grid-template-columns: 1fr; }
}
