/* Pantallas pensadas para el móvil: una columna, botones grandes y formularios cortos. */
:root { --pico-font-size: 106.25%; }
body { background: var(--pico-background-color); }
main.container { max-width: 40rem; padding: 0.75rem 1rem 6rem; }

/* Barra superior siempre visible */
.app-header { position: sticky; top: 0; z-index: 20; background: var(--pico-background-color); border-bottom: 1px solid var(--pico-muted-border-color); padding-top: env(safe-area-inset-top); }
.app-header nav { max-width: 40rem; padding: 0 1rem; }
.app-header nav ul { margin: 0; }
.app-header nav li { padding: 0.5rem 0.25rem; }
.brand { font-weight: 700; text-decoration: none; }
.demo-badge { font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.4rem; }
.header-actions form { margin: 0; }
.header-actions button { margin: 0; padding: 0.3rem 0.6rem; font-size: 0.85rem; }

h1 { font-size: 1.5rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.25rem; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--pico-muted-color); }
.error-box { border-left: 4px solid #b91c1c; }
.warning { background: #fef3c7; color: #78350f; padding: 0.75rem 1rem; border-radius: 0.4rem; }
.danger { background: #fee2e2; color: #7f1d1d; padding: 0.75rem 1rem; border-radius: 0.4rem; }
.ok-box { background: #dcfce7; color: #14532d; padding: 0.75rem 1rem; border-radius: 0.4rem; }

/* Botones grandes */
.big-buttons { display: grid; gap: 0.75rem; margin: 1rem 0; }
.big-buttons a[role="button"], .big-buttons button { width: 100%; padding: 1.1rem; font-size: 1.15rem; margin: 0; }
.button-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.button-row > * { flex: 1 1 auto; margin: 0; }
button.small, a.small[role="button"] { padding: 0.3rem 0.7rem; font-size: 0.85rem; margin: 0; width: auto; }

/* Listas con miniatura */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; margin: 0; border-bottom: 1px solid var(--pico-muted-border-color); list-style: none; }
.thumb { flex: 0 0 4rem; width: 4rem; height: 4rem; object-fit: cover; border-radius: 0.4rem; background: var(--pico-muted-border-color); }
.item-info { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.item-info small { display: block; color: var(--pico-muted-color); }
.item-side { flex: 0 0 auto; text-align: right; }
.price { font-weight: 700; white-space: nowrap; }
.code { font-family: ui-monospace, monospace; letter-spacing: 0.05em; }
.badge { display: inline-block; font-size: 0.75rem; padding: 0.05rem 0.4rem; border-radius: 0.3rem; background: var(--pico-muted-border-color); }
.badge-warn { background: #fde68a; color: #78350f; }
.badge-bad { background: #fecaca; color: #7f1d1d; }
.badge-ok { background: #bbf7d0; color: #14532d; }

/* Avisos temporales (snackbars), abajo */
#snackbars { position: fixed; left: 1rem; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; max-width: 30rem; }
.snackbar { padding: 0.8rem 1rem; border-radius: 0.4rem; background: #1f2937; color: #f9fafb; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); cursor: pointer; animation: snackbar-in 0.25s ease-out; transition: opacity 0.3s, transform 0.3s; }
.snackbar-success { background: #166534; }
.snackbar-error { background: #991b1b; }
.snackbar-hide { opacity: 0; transform: translateY(1rem); }
.snackbar-persistent { cursor: default; }
.snackbar-persistent p { margin: 0.4rem 0 0; color: inherit; }
.snackbar-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.7rem; }
.snackbar-actions button { margin: 0; padding: 0.45rem 0.9rem; font-size: 0.95rem; width: auto; }
@keyframes snackbar-in { from { opacity: 0; transform: translateY(1rem); } to { opacity: 1; transform: none; } }

/* Uso exclusivo como PWA instalada: fuera de ella solo se ve la pantalla de instalación */
html:not(.pwa-standalone) .app-shell { display: none; }
html.pwa-standalone .install-gate { display: none; }
.install-gate { max-width: 32rem; padding: 2rem 1.25rem; text-align: left; }
.install-gate img { border-radius: 1.2rem; margin-bottom: 1rem; }
.install-gate button { width: 100%; padding: 1rem; font-size: 1.15rem; }
.install-steps li { margin-bottom: 0.6rem; }
.ios-icon { width: 1.4em; height: 1.4em; vertical-align: -0.3em; color: #1d4ed8; }
.copy-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.copy-row input { flex: 1 1 14rem; margin: 0; }
.copy-row button { flex: 0 0 auto; width: auto; margin: 0; }

/* Entrar */
.code-input { font-size: 1.6rem; letter-spacing: 0.3em; text-align: center; font-family: ui-monospace, monospace; }
.demo-help ul { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.demo-help li { list-style: none; margin-bottom: 0.4rem; }
.user-line { margin: 0 0 0.25rem; font-size: 0.85rem; }
.email-preview { border-left: 4px solid #1d4ed8; }
.email-preview pre { white-space: pre-wrap; font-size: 0.9rem; }
.email-preview dl { margin: 0; }
.email-preview dt { font-weight: 600; }
.email-preview dd { margin: 0 0 0.3rem; }
.offline { margin-top: 2rem; }

/* Formularios */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 22rem) { .grid-2 { grid-template-columns: 1fr; } }
label.check { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
label.check input { margin: 0; }
a.wide[role="button"] { width: 100%; margin-bottom: 1rem; }
form.inline { margin: 0; }
.photo-preview { max-height: 14rem; border-radius: 0.5rem; margin: -0.5rem 0 1rem; }
.regime-hint { margin-top: -0.5rem; font-size: 0.85rem; }
.hint-ok { color: #15803d; }
.hint-bad { color: #b91c1c; }
.barcode-hint { min-height: 1.3rem; margin: -0.6rem 0 0.8rem; }
.new-party { margin-top: 1.5rem; }
.new-party summary[role="button"] { width: 100%; }
.small-text { font-size: 0.85rem; }
.hash { font-size: 0.75rem; overflow-wrap: anywhere; }
.signed-box { border-left: 4px solid #15803d; }
.email-form { margin: 0; }
.sign-summary { font-size: 0.9rem; }

/* Código de barras con botón de cámara */
.barcode-field { display: flex; gap: 0.5rem; }
.barcode-field input { flex: 1 1 auto; margin-bottom: 0.75rem; font-size: 1.3rem; }
.barcode-field button { flex: 0 0 auto; width: auto; margin: 0 0 0.75rem; }

/* Lector con la cámara */
dialog.scanner article { padding: 0.75rem; width: min(30rem, 96vw); max-width: none; position: relative; }
dialog.scanner video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; border-radius: 0.4rem; display: block; }
.scanner-frame { position: absolute; left: 12%; right: 12%; top: calc(0.75rem + 18%); height: 22%; border: 3px solid rgba(255, 255, 255, 0.85); border-radius: 0.4rem; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.0); pointer-events: none; }
.scanner-status { margin: 0.6rem 0; min-height: 2.6rem; }
.scanner-cancel { width: 100%; margin: 0; }

/* Firma */
.signature-pad { position: relative; border: 2px dashed var(--pico-muted-border-color); border-radius: 0.5rem; background: #fff; margin-bottom: 0.75rem; }
.signature-pad canvas { display: block; width: 100%; height: 13rem; touch-action: none; cursor: crosshair; }
.signature-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9ca3af; pointer-events: none; font-size: 1.1rem; }

/* Ficha del artículo */
.article-photo { width: 100%; max-height: 22rem; object-fit: contain; border-radius: 0.5rem; background: var(--pico-muted-border-color); }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.9rem; }
dl.facts dt { font-weight: 600; }
dl.facts dd { margin: 0; }
.filters-row { display: flex; gap: 0.5rem; }
.filters-row > * { margin: 0; }
.filters-row input { flex: 1 1 auto; }
.filters-row select { flex: 0 0 9rem; }
.big-price { font-size: 1.6rem; margin: 0.5rem 0; }

/* Venta */
#scan-form { margin: 0; }
.check-card { text-align: center; border: 2px solid #1d4ed8; }
.check-photo { width: 100%; max-height: 55vh; object-fit: contain; border-radius: 0.5rem; background: #000; }
.check-title { font-size: 1.6rem; margin: 0.6rem 0 0.2rem; }
.check-price { font-size: 2.4rem; font-weight: 800; margin: 0; }
.regime-choice { text-align: left; }
.line-regime { margin: 0.25rem 0 0; padding: 0.2rem 0.5rem; height: auto; font-size: 0.9rem; width: auto; }
.total { font-size: 1.6rem; font-weight: 800; text-align: right; margin: 0.75rem 0; }
.pending-actions { margin-top: 0.6rem; }
.recent { margin-top: 1.5rem; }
dialog.terminal article { width: min(26rem, 94vw); }
.terminal-amount { font-size: 2.2rem; font-weight: 800; text-align: center; font-family: ui-monospace, monospace; }

/* Depósitos y portada */
.settlement header { display: flex; justify-content: space-between; gap: 0.5rem; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { list-style: none; margin-bottom: 0.5rem; }
.alert-link { display: block; margin-bottom: 0.6rem; text-decoration: none; }
.info-box { background: #e0f2fe; color: #0c4a6e; padding: 0.75rem 1rem; border-radius: 0.4rem; }
main h1 { margin-top: 0.4rem; }
h3 { font-size: 1.05rem; margin-top: 1rem; }
.settlement header { align-items: flex-start; }
.settlement header small { display: block; font-weight: normal; }
