/* Factux POS — PWA aislada del frontend Blazor.
   Misma dirección visual: papel de factura, tinta azul, un solo acento.
   IBM Plex se sirve localmente desde /fonts (licencia OFL). */

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url("/fonts/ibm-plex-sans-latin.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url("/fonts/ibm-plex-mono-latin.woff2") format("woff2");
}

:root {
    --fx-accent: #0b5ed7;
    --fx-accent-hover: #0849a8;
    --fx-accent-soft: #e8f0fd;
    --fx-ink: #111827;
    --fx-ink-2: #4b5565;
    --fx-muted: #6b7487;
    --fx-line: rgba(17, 24, 39, 0.10);
    --fx-line-strong: rgba(17, 24, 39, 0.18);
    --fx-bg: #f5f7fa;
    --fx-surface: #ffffff;
    --fx-raised: #eceff4;
    --fx-radius: 10px;
    --fx-radius-sm: 7px;
    --fx-ok: #0f7a4d;
    --fx-ok-soft: #eaf5ef;
    --fx-error: #b42318;
    --fx-error-soft: #fdecea;
    --fx-warn: #8a5300;
    --fx-warn-soft: #fff4dd;
    --fx-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
    --fx-shadow-lg: 0 22px 60px rgba(17, 24, 39, 0.22);
    --fx-header-h: 60px;
    --fx-nav-h: 50px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--fx-ink);
    background: var(--fx-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.mono {
    font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.muted {
    color: var(--fx-muted);
}

.small {
    font-size: 13px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------------------------------------------------------------- Login */

.login-view {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
        linear-gradient(var(--fx-line) 1px, transparent 1px) 0 0 / 100% 32px,
        linear-gradient(90deg, var(--fx-line) 1px, transparent 1px) 0 0 / 32px 100%,
        var(--fx-bg);
}

.login-card {
    width: min(420px, 100%);
    background: var(--fx-surface);
    border: 1px solid var(--fx-line);
    border-radius: 14px;
    box-shadow: var(--fx-shadow);
    padding: 28px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.login-brand img {
    width: 42px;
    height: 42px;
}

.login-brand h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.login-brand p {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--fx-ink-2);
}

.login-intro {
    margin: 0 0 20px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--fx-ink-2);
}

.login-error {
    display: none;
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--fx-error-soft);
    color: var(--fx-error);
    border: 1px solid rgba(180, 35, 24, 0.22);
    font-size: 13px;
    line-height: 1.4;
}

.login-error.is-visible {
    display: block;
}

.login-foot {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--fx-line);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 12.5px;
    color: var(--fx-muted);
}

.login-foot a {
    color: var(--fx-accent);
    text-decoration: none;
    font-weight: 500;
}

.login-foot a:hover {
    text-decoration: underline;
}

/* ------------------------------------------------------------ App shell */

.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.app-header {
    height: var(--fx-header-h);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    background: var(--fx-surface);
    border-bottom: 1px solid var(--fx-line);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-brand img {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
}

.app-brand-text {
    min-width: 0;
    line-height: 1.2;
}

.app-brand-text strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 34vw;
}

.app-brand-text span {
    display: block;
    font-size: 11.5px;
    color: var(--fx-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 34vw;
}

.app-header-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.punto-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 11px;
    border-radius: 8px;
    border: 1px solid var(--fx-line);
    background: var(--fx-raised);
    color: var(--fx-ink-2);
    font-size: 12.5px;
    font-weight: 500;
    max-width: 260px;
}

.punto-chip:hover {
    border-color: var(--fx-line-strong);
    background: #e6eaf1;
}

.punto-chip .serie {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11.5px;
    color: var(--fx-ink);
}

.app-nav {
    height: var(--fx-nav-h);
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    gap: 2px;
    padding: 0 12px;
    background: var(--fx-surface);
    border-bottom: 1px solid var(--fx-line);
    overflow-x: auto;
    scrollbar-width: none;
}

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

.nav-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: var(--fx-ink-2);
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
}

.nav-btn svg {
    width: 17px;
    height: 17px;
}

.nav-btn:hover:not(:disabled) {
    color: var(--fx-ink);
}

.nav-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.nav-btn.is-active {
    color: var(--fx-accent);
}

.nav-btn.is-active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 0;
    height: 2px;
    background: var(--fx-accent);
    border-radius: 2px 2px 0 0;
}

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px;
    overflow: auto;
}

.view {
    min-height: 100%;
}

/* --------------------------------------------------------------- Global */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--fx-line);
    background: var(--fx-surface);
    color: var(--fx-ink);
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.btn:hover {
    border-color: var(--fx-line-strong);
    background: #fafbfd;
}

.btn:focus-visible,
.nav-btn:focus-visible,
.punto-chip:focus-visible,
.producto-card:focus-visible {
    outline: 2px solid var(--fx-accent);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--fx-accent);
    border-color: var(--fx-accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--fx-accent-hover);
    border-color: var(--fx-accent-hover);
}

.btn-primary:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--fx-raised);
    border-color: var(--fx-line);
    color: var(--fx-muted);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--fx-ink-2);
}

.btn-ghost:hover {
    background: var(--fx-raised);
    border-color: transparent;
}

.btn-danger {
    color: var(--fx-error);
    background: var(--fx-error-soft);
    border-color: rgba(180, 35, 24, 0.25);
}

.btn-danger:hover {
    background: #fbdcd8;
    border-color: rgba(180, 35, 24, 0.35);
}

.btn-sm {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12.5px;
}

.btn-lg {
    min-height: 48px;
    font-size: 15px;
    padding: 0 18px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 32px;
    min-height: 32px;
    padding: 0;
    border-radius: 7px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

.badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.badge-ok {
    background: var(--fx-ok-soft);
    color: var(--fx-ok);
    border-color: rgba(15, 122, 77, 0.2);
}

.badge-warn {
    background: var(--fx-warn-soft);
    color: var(--fx-warn);
    border-color: rgba(138, 83, 0, 0.2);
}

.badge-error {
    background: var(--fx-error-soft);
    color: var(--fx-error);
    border-color: rgba(180, 35, 24, 0.2);
}

.badge-neutral {
    background: var(--fx-raised);
    color: var(--fx-ink-2);
    border-color: var(--fx-line);
}

.panel {
    background: var(--fx-surface);
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-radius);
    box-shadow: var(--fx-shadow);
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--fx-line);
}

.panel-head h2,
.panel-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.panel-head .spacer {
    margin-left: auto;
}

.panel-body {
    padding: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field > span,
.field > label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--fx-ink-2);
}

.input {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--fx-line);
    border-radius: 8px;
    background: var(--fx-surface);
    color: var(--fx-ink);
    font-size: 14px;
}

textarea.input {
    min-height: 76px;
    resize: vertical;
    line-height: 1.45;
}

.input:focus {
    outline: none;
    border-color: var(--fx-accent);
    box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.12);
}

.input::placeholder {
    color: var(--fx-muted);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-grid .span-2 {
    grid-column: 1 / -1;
}

.form-error {
    display: none;
    padding: 9px 11px;
    border-radius: 8px;
    background: var(--fx-error-soft);
    color: var(--fx-error);
    border: 1px solid rgba(180, 35, 24, 0.22);
    font-size: 12.5px;
    line-height: 1.4;
}

.form-error.is-visible {
    display: block;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--fx-ink-2);
    cursor: pointer;
    user-select: none;
}

.check input {
    width: 16px;
    height: 16px;
    accent-color: var(--fx-accent);
}

.search-box {
    position: relative;
    flex: 1 1 auto;
    min-width: 160px;
}

.search-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--fx-muted);
    pointer-events: none;
}

.search-box .input {
    padding-left: 34px;
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    border-radius: 9px;
    border: 1px solid rgba(138, 83, 0, 0.22);
    background: var(--fx-warn-soft);
    color: var(--fx-warn);
    font-size: 13px;
    line-height: 1.45;
}

.notice svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    margin-top: 1px;
}

.notice-error {
    border-color: rgba(180, 35, 24, 0.22);
    background: var(--fx-error-soft);
    color: var(--fx-error);
}

.notice-ok {
    border-color: rgba(15, 122, 77, 0.2);
    background: var(--fx-ok-soft);
    color: var(--fx-ok);
}

.notice .btn {
    margin-left: auto;
    flex: 0 0 auto;
}

/* --------------------------------------------------------------- Ventas */

.venta-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 386px;
    gap: 16px;
    height: 100%;
    min-height: 0;
}

.catalogo-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: transparent;
}

.catalogo-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.catalogo-head .search-box {
    min-width: 220px;
}

.catalogo-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    font-size: 12.5px;
    color: var(--fx-muted);
}

.catalogo-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
    gap: 12px;
    align-content: start;
    padding: 2px 4px 12px 2px;
    scrollbar-gutter: stable;
}

.producto-card {
    display: flex;
    flex-direction: column;
    text-align: left;
    padding: 0;
    overflow: hidden;
    background: var(--fx-surface);
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-radius);
    box-shadow: var(--fx-shadow);
    transition: border-color 0.12s ease, transform 0.12s ease;
}

.producto-card:hover:not(:disabled) {
    border-color: rgba(11, 94, 215, 0.45);
    transform: translateY(-1px);
}

.producto-card:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.producto-img {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--fx-raised);
    overflow: hidden;
}

.producto-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.producto-img .sin-img {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--fx-muted);
    font-size: 11.5px;
    text-align: center;
    padding: 8px;
}

.producto-img .sin-img svg {
    width: 22px;
    height: 22px;
}

.producto-img .chip {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.2;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--fx-line);
    color: var(--fx-ink-2);
    backdrop-filter: blur(3px);
}

.producto-img .chip-ok {
    color: var(--fx-ok);
    border-color: rgba(15, 122, 77, 0.25);
}

.producto-img .chip-error {
    color: var(--fx-error);
    border-color: rgba(180, 35, 24, 0.25);
}

.producto-img .chip-service {
    color: var(--fx-accent);
    border-color: rgba(11, 94, 215, 0.25);
}

.producto-info {
    padding: 10px 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.producto-nombre {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

.producto-codigo {
    font-family: "IBM Plex Mono", monospace;
    font-size: 10.5px;
    color: var(--fx-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.producto-precio {
    margin-top: 2px;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.producto-precio .iva {
    font-size: 10.5px;
    font-weight: 400;
    color: var(--fx-muted);
}

.catalogo-vacio {
    grid-column: 1 / -1;
    padding: 42px 16px;
    text-align: center;
    color: var(--fx-muted);
    font-size: 13.5px;
}

/* Ticket */

.ticket-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--fx-surface);
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-radius);
    box-shadow: var(--fx-shadow);
}

.ticket-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--fx-line);
}

.ticket-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.ticket-head .ticket-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--fx-muted);
}

.ticket-close {
    display: none;
}

.ticket-cliente {
    padding: 11px 14px;
    border-bottom: 1px solid var(--fx-line);
    background: #fbfcfe;
}

.cliente-resumen {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cliente-resumen .avatar {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--fx-accent-soft);
    color: var(--fx-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.cliente-resumen .datos {
    min-width: 0;
    flex: 1;
}

.cliente-resumen .datos strong {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cliente-resumen .datos span {
    display: block;
    font-size: 11px;
    color: var(--fx-muted);
    font-family: "IBM Plex Mono", monospace;
}

.ticket-lineas {
    flex: 1 1 auto;
    min-height: 80px;
    overflow: auto;
    padding: 6px 0;
}

.ticket-vacio {
    height: 100%;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    text-align: center;
    color: var(--fx-muted);
    font-size: 13px;
}

.ticket-vacio svg {
    width: 30px;
    height: 30px;
    opacity: 0.6;
}

.linea {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px 10px;
    align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid var(--fx-line);
}

.linea:last-child {
    border-bottom: 0;
}

.linea-info {
    min-width: 0;
}

.linea-info strong {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.linea-info span {
    display: block;
    font-size: 11px;
    color: var(--fx-muted);
    font-family: "IBM Plex Mono", monospace;
}

.linea-qty {
    display: flex;
    align-items: center;
    gap: 2px;
    border: 1px solid var(--fx-line);
    border-radius: 7px;
    background: var(--fx-surface);
    overflow: hidden;
}

.linea-qty button {
    width: 26px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--fx-ink-2);
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.linea-qty button:hover {
    background: var(--fx-raised);
}

.linea-qty input {
    width: 42px;
    height: 28px;
    border: 0;
    border-left: 1px solid var(--fx-line);
    border-right: 1px solid var(--fx-line);
    text-align: center;
    font-family: "IBM Plex Mono", monospace;
    font-size: 11.5px;
    background: transparent;
    -moz-appearance: textfield;
    appearance: textfield;
}

.linea-qty input::-webkit-outer-spin-button,
.linea-qty input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.linea-total {
    min-width: 62px;
    text-align: right;
    font-family: "IBM Plex Mono", monospace;
    font-size: 12.5px;
    font-weight: 500;
}

.linea-remove {
    grid-column: 1 / -1;
    justify-self: end;
    margin-top: -4px;
    border: 0;
    background: transparent;
    color: var(--fx-muted);
    font-size: 11px;
    padding: 0;
}

.linea-remove:hover {
    color: var(--fx-error);
    text-decoration: underline;
}

.ticket-totales {
    padding: 12px 14px;
    border-top: 1px solid var(--fx-line);
    background: #fbfcfe;
    display: grid;
    gap: 5px;
}

.tot-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12.5px;
    color: var(--fx-ink-2);
}

.tot-row .mono {
    font-size: 12.5px;
}

.tot-row.tot-final {
    margin-top: 5px;
    padding-top: 9px;
    border-top: 1px dashed var(--fx-line-strong);
    font-size: 15px;
    font-weight: 600;
    color: var(--fx-ink);
}

.tot-row.tot-final .mono {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.ticket-acciones {
    padding: 12px 14px 14px;
    border-top: 1px solid var(--fx-line);
    display: grid;
    gap: 8px;
}

.ticket-acciones .btn-primary {
    min-height: 48px;
    font-size: 15px;
}

.mobile-ticket-bar {
    display: none;
}

/* ---------------------------------------------------------------- Caja */

.caja-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.9fr);
    gap: 16px;
    align-items: start;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    background: var(--fx-surface);
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-radius);
    padding: 14px;
    box-shadow: var(--fx-shadow);
}

.stat-label {
    font-size: 11.5px;
    color: var(--fx-muted);
    text-transform: none;
    letter-spacing: 0;
}

.stat-value {
    margin-top: 5px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 21px;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.stat-value.ok {
    color: var(--fx-ok);
}

.stat-value.error {
    color: var(--fx-error);
}

.stat-value.warn {
    color: var(--fx-warn);
}

.caja-acciones {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.caja-form {
    display: grid;
    gap: 12px;
}

.caja-resumen-lista {
    display: grid;
    gap: 8px;
    margin: 0;
}

.caja-resumen-lista div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--fx-ink-2);
}

.caja-resumen-lista div span:last-child {
    font-family: "IBM Plex Mono", monospace;
    color: var(--fx-ink);
}

/* ------------------------------------------------------------- Tablas */

.tabla-wrap {
    overflow: auto;
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-radius);
    background: var(--fx-surface);
}

.tabla {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.tabla th {
    text-align: left;
    padding: 10px 12px;
    background: var(--fx-raised);
    color: var(--fx-ink-2);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--fx-line);
}

.tabla td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--fx-line);
    font-size: 13px;
    vertical-align: middle;
}

.tabla tbody tr:last-child td {
    border-bottom: 0;
}

.tabla tbody tr:hover {
    background: #fafbfd;
}

.tabla .num {
    text-align: right;
    font-family: "IBM Plex Mono", monospace;
    white-space: nowrap;
}

.tabla .acciones {
    text-align: right;
    white-space: nowrap;
}

.tabla .principal {
    font-weight: 500;
}

.tabla .secundario {
    display: block;
    font-size: 11.5px;
    color: var(--fx-muted);
    font-family: "IBM Plex Mono", monospace;
}

.tabla-vacia {
    padding: 42px 16px;
    text-align: center;
    color: var(--fx-muted);
    font-size: 13.5px;
}

.thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--fx-line);
    background: var(--fx-raised);
    display: block;
}

.thumb-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px dashed var(--fx-line-strong);
    background: var(--fx-raised);
    color: var(--fx-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-placeholder svg {
    width: 17px;
    height: 17px;
}

/* Miniatura y vista previa de la ficha de producto */
.thumb.img-slot,
.img-slot.thumb {
    padding: 0;
    overflow: hidden;
    color: var(--fx-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb img,
.img-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

.thumb.img-slot > svg,
.img-slot.thumb > svg {
    width: 18px;
    height: 18px;
}

.imagen-preview {
    width: 116px;
    height: 116px;
    flex: none;
    border-radius: 10px;
    border: 1px dashed var(--fx-line-strong);
    background: var(--fx-raised);
    color: var(--fx-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.imagen-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.imagen-preview > svg {
    width: 26px;
    height: 26px;
}

/* --------------------------------------------------------- Encabezados */

.vista-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.vista-head h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.vista-head p {
    margin: 3px 0 0;
    font-size: 13px;
    color: var(--fx-ink-2);
}

.vista-head .acciones {
    margin-left: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.toolbar .search-box {
    flex: 1 1 260px;
}

/* --------------------------------------------------------------- Modal */

.modal-host {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.46);
}

.modal {
    position: relative;
    width: min(560px, 100%);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--fx-surface);
    border-radius: 12px;
    box-shadow: var(--fx-shadow-lg);
    overflow: hidden;
    animation: subir 0.16s ease-out;
}

.modal-lg {
    width: min(780px, 100%);
}

.modal-sm {
    width: min(420px, 100%);
}

@keyframes subir {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--fx-line);
}

.modal-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.modal-head p {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--fx-muted);
}

.modal-head .btn-icon {
    margin-left: auto;
}

.modal-body {
    padding: 18px;
    overflow: auto;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 13px 18px;
    border-top: 1px solid var(--fx-line);
    background: #fbfcfe;
}

.modal-foot .izquierda {
    margin-right: auto;
}

/* Checkout */

.checkout-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 9px;
    background: var(--fx-accent-soft);
    margin-bottom: 16px;
}

.checkout-total span {
    font-size: 13px;
    color: var(--fx-ink-2);
}

.checkout-total strong {
    font-family: "IBM Plex Mono", monospace;
    font-size: 25px;
    letter-spacing: -0.02em;
    color: var(--fx-accent);
}

.pago-metodos {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.pago-metodo {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 11px;
    border: 1px solid var(--fx-line);
    border-radius: 9px;
    background: var(--fx-surface);
    font-size: 13px;
    cursor: pointer;
}

.pago-metodo:hover {
    border-color: var(--fx-line-strong);
}

.pago-metodo input {
    accent-color: var(--fx-accent);
}

.pago-metodo.is-selected {
    border-color: var(--fx-accent);
    background: var(--fx-accent-soft);
}

.efectivo-panel {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--fx-line);
    border-radius: 9px;
    background: #fbfcfe;
}

.quick-cash {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.quick-cash button {
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--fx-line);
    border-radius: 7px;
    background: var(--fx-surface);
    font-size: 12.5px;
    font-family: "IBM Plex Mono", monospace;
}

.quick-cash button:hover {
    border-color: var(--fx-accent);
    color: var(--fx-accent);
}

.vuelto {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 8px;
    border-top: 1px dashed var(--fx-line-strong);
    font-size: 13px;
    color: var(--fx-ink-2);
}

.vuelto strong {
    font-family: "IBM Plex Mono", monospace;
    font-size: 16px;
    color: var(--fx-ok);
}

.vuelto strong.error {
    color: var(--fx-error);
}

/* Recibo */

.recibo {
    font-size: 13px;
    color: var(--fx-ink);
}

.recibo-cab {
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--fx-line-strong);
    margin-bottom: 12px;
}

.recibo-cab img {
    max-height: 52px;
    max-width: 160px;
    object-fit: contain;
    margin-bottom: 6px;
}

.recibo-cab strong {
    display: block;
    font-size: 14px;
}

.recibo-cab span {
    display: block;
    font-size: 11.5px;
    color: var(--fx-muted);
}

.recibo-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 10px;
    font-size: 12px;
    margin-bottom: 12px;
}

.recibo-meta dt {
    color: var(--fx-muted);
}

.recibo-meta dd {
    margin: 0;
    text-align: right;
    font-family: "IBM Plex Mono", monospace;
}

.recibo-items {
    display: grid;
    gap: 6px;
    padding: 10px 0;
    border-top: 1px dashed var(--fx-line-strong);
    border-bottom: 1px dashed var(--fx-line-strong);
}

.recibo-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    font-size: 12px;
}

.recibo-item .det {
    color: var(--fx-muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 10.5px;
}

.recibo-item .imp {
    text-align: right;
    font-family: "IBM Plex Mono", monospace;
}

.recibo-totales {
    display: grid;
    gap: 4px;
    padding: 10px 0;
    font-size: 12px;
}

.recibo-totales div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.recibo-totales .total {
    font-size: 15px;
    font-weight: 600;
    padding-top: 6px;
    border-top: 1px solid var(--fx-line);
}

.recibo-pie {
    text-align: center;
    padding-top: 10px;
    border-top: 1px dashed var(--fx-line-strong);
    font-size: 10.5px;
    color: var(--fx-muted);
    line-height: 1.5;
    word-break: break-all;
}

.recibo-estado {
    margin-bottom: 12px;
}

/* -------------------------------------------------------------- Toasts */

.toast-host {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 11px 13px;
    border-radius: 9px;
    background: var(--fx-ink);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.2);
    animation: aparecer 0.16s ease-out;
}

.toast-ok {
    background: var(--fx-ok);
}

.toast-error {
    background: var(--fx-error);
}

.toast-warn {
    background: var(--fx-warn);
}

@keyframes aparecer {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* --------------------------------------------------------------- Busy */

.busy {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(245, 247, 250, 0.86);
    backdrop-filter: blur(2px);
    text-align: center;
    padding: 24px;
}

.busy p {
    margin: 0;
    font-size: 14px;
    color: var(--fx-ink-2);
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--fx-line);
    border-top-color: var(--fx-accent);
    border-radius: 50%;
    animation: girar 0.8s linear infinite;
}

@keyframes girar {
    to {
        transform: rotate(360deg);
    }
}

/* --------------------------------------------------------------- Print */

.print-area {
    display: none;
}

@media print {
    @page {
        margin: 4mm;
        size: 80mm auto;
    }

    body {
        background: #fff;
    }

    body > *:not(.print-area) {
        display: none !important;
    }

    .print-area {
        display: block !important;
        width: 72mm;
        margin: 0 auto;
        color: #000;
        font-family: "IBM Plex Mono", ui-monospace, monospace;
        font-size: 10.5px;
        line-height: 1.45;
    }

    .print-area .recibo-cab img {
        max-height: 44px;
    }

    .print-area .recibo-estado,
    .print-area .recibo-pie {
        display: block;
    }
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 1080px) {
    .venta-layout {
        grid-template-columns: minmax(0, 1fr) 340px;
    }

    .caja-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    :root {
        --fx-header-h: 56px;
    }

    .app-header {
        height: auto;
        min-height: var(--fx-header-h);
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 6px 10px;
    }

    .app-brand {
        flex: 1 1 180px;
        min-width: 0;
    }

    .app-brand-text strong,
    .app-brand-text span {
        max-width: 100%;
    }

    .app-header-meta {
        margin-left: auto;
        flex: 0 1 auto;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
        max-width: 100%;
    }

    .punto-chip {
        max-width: 200px;
    }

    .punto-chip .punto-nombre {
        display: none;
    }

    .app-main {
        padding: 12px;
    }

    .venta-layout {
        display: block;
        height: auto;
    }

    .catalogo-panel {
        height: auto;
    }

    .catalogo-grid {
        overflow: visible;
        grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
        padding-bottom: 84px;
    }

    .ticket-panel {
        position: fixed;
        inset: 0;
        z-index: 110;
        border-radius: 0;
        border: 0;
        transform: translateX(100%);
        transition: transform 0.2s ease;
    }

    .ticket-panel.is-open {
        transform: none;
    }

    .ticket-close {
        display: inline-flex;
    }

    /* Solo en la vista de venta; en caja/productos taparía los botones del formulario. */
    .mobile-ticket-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 80;
        display: none;
        align-items: center;
        gap: 10px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        background: var(--fx-surface);
        border-top: 1px solid var(--fx-line);
        box-shadow: 0 -4px 18px rgba(17, 24, 39, 0.08);
    }

    body.vista-ventas .mobile-ticket-bar {
        display: flex;
    }

    .mobile-ticket-bar .resumen {
        min-width: 0;
        flex: 1;
    }

    .mobile-ticket-bar .resumen strong {
        display: block;
        font-size: 11.5px;
        color: var(--fx-muted);
        font-weight: 500;
    }

    .mobile-ticket-bar .resumen span {
        display: block;
        font-family: "IBM Plex Mono", monospace;
        font-size: 17px;
        font-weight: 600;
    }

    .mobile-ticket-bar .btn {
        flex: 0 0 auto;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2 {
        grid-column: auto;
    }

    .toast-host {
        bottom: calc(76px + env(safe-area-inset-bottom));
    }

    .modal-host {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        width: 100%;
        max-height: 92dvh;
        border-radius: 14px 14px 0 0;
    }

    .pago-metodos {
        grid-template-columns: 1fr;
    }

    .vista-head .acciones {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .app-header {
        row-gap: 8px;
        padding: 9px 12px;
    }

    .app-brand {
        flex: 1 1 100%;
    }

    .app-brand-text {
        display: block;
    }

    .app-header-meta {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
        padding-top: 7px;
        border-top: 1px solid var(--fx-line);
    }

    .punto-chip {
        max-width: 140px;
        padding: 0 9px;
        min-height: 30px;
    }

    .app-header-meta .btn-sm {
        min-height: 30px;
        padding: 0 9px;
    }

    .app-header-meta .salir-texto {
        display: none;
    }
}

@media (max-width: 460px) {
    .punto-chip {
        max-width: 130px;
    }

    .catalogo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .producto-info {
        padding: 8px 9px 10px;
    }

    .producto-nombre {
        font-size: 12.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
