/* ============================================================
   TurboPOS — Sistema de diseño v2 "Día / Noche"
   Requiere turbopos-tokens.css cargado ANTES de este archivo.
   Todos los colores salen de tokens --tp-*: ningún par
   texto/fondo fuera de los definidos ahí (WCAG 2.2 AA).
   Los nombres de clase .tp-* se mantienen: los templates
   existentes migran sin cambios estructurales.
   ============================================================ */

* {
    box-sizing: border-box;
}

body.tp-app {
    margin: 0;
    position: relative;
    background: var(--tp-bg);
    color: var(--tp-ink);
    font-family: var(--tp-font-ui);
    font-size: var(--tp-text-base);
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: var(--tp-font-display);
}

/* Toda cifra CLP: mono con dígitos tabulares */
.cifra,
.tp-kpi-value,
.tp-display-amount,
.tp-ticket-input,
.tp-keypad-btn,
.tp-product-tile-precio {
    font-family: var(--tp-font-mono);
    font-variant-numeric: tabular-nums;
}

/* ---------- Navbar: "visor" oscuro en ambos temas ---------- */

.tp-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--tp-border-strong);
    background: var(--tp-visor);
    color: var(--tp-visor-ink);
}

.tp-ticker {
    overflow: hidden;
    white-space: nowrap;
    border-bottom: 1px solid var(--tp-border);
    background: var(--tp-brand-soft);
    padding: 0.15rem 0;
}

.tp-ticker-track {
    display: inline-flex;
    width: max-content;
    animation: tp-ticker-scroll 32s linear infinite;
}

.tp-ticker-item {
    display: inline-block;
    padding: 0 1.8rem;
    color: var(--tp-brand-text);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

@keyframes tp-ticker-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .tp-ticker-track { animation: none; }
}

.tp-nav-inner {
    margin: 0 auto;
    max-width: 1100px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 0.5rem;
    justify-content: space-between;
    padding: 0.3rem 1rem;
}

.tp-brand {
    display: inline-flex;
    align-items: center;
    font-family: var(--tp-font-display);
    font-weight: 700;
    font-size: 1rem;
    color: var(--tp-visor-ink);
    letter-spacing: 0.03em;
    text-decoration: none;
}

/* Marca "código de barras": referencia directa a "escaneas y se completa
   solo" (el diferenciador real de TurboPOS). Ambos colores ya definidos en
   la paleta, ningún color nuevo inventado. */
.tp-brand-mark {
    width: 1.4rem;
    height: 1.4rem;
    margin-right: 0.45rem;
    flex-shrink: 0;
}

.tp-brand-mark-bg {
    fill: var(--tp-brand);
}

.tp-brand-mark-bar {
    fill: var(--tp-visor);
}

.tp-nav-brand-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.tp-role-badge {
    display: inline-block;
    border-radius: 999px;
    border: 1px solid rgba(251, 246, 236, 0.28);
    background: rgba(251, 246, 236, 0.1);
    color: var(--tp-visor-ink);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.25rem 0.6rem;
    white-space: nowrap;
}

.tp-nav-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem;
    row-gap: 0.25rem;
}

.tp-nav-actions .tp-link,
.tp-nav-actions .tp-ghost-button {
    white-space: nowrap;
}

/* Links y botones dentro del visor oscuro del navbar */
.tp-nav .tp-link {
    color: var(--tp-visor-ink);
    border-radius: 0.55rem;
    border: 1px solid transparent;
    background: none;
    padding: 0.28rem 0.6rem;
    min-height: auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.08rem;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.1;
    transition: background-color 0.15s ease;
}

/* Navbar compacta (Sesion Cowork): icono arriba + etiqueta micro abajo */
.tp-nav-ico {
    font-size: 1.05rem;
    line-height: 1;
}

.tp-nav-lbl {
    display: block;
}

.tp-nav .tp-link:hover {
    background: rgba(251, 246, 236, 0.18);
}

.tp-nav .tp-link.tp-link-active {
    background: var(--tp-brand);
    border-color: var(--tp-brand);
    color: var(--tp-on-brand);
    font-weight: 700;
}

.tp-nav .tp-ghost-button {
    color: var(--tp-visor-ink);
    border: 1px solid rgba(251, 246, 236, 0.3);
    background: rgba(251, 246, 236, 0.08);
}

.tp-nav .tp-ghost-button:hover {
    background: rgba(251, 246, 236, 0.18);
    border-color: rgba(251, 246, 236, 0.5);
}

/* Dropdown nativo (<details>/<summary>) para agrupar botones del navbar
   (ej. "Configuración" = Usuarios + Autorizaciones, y el menú de usuario) —
   sin JS, teclado funciona solo (Enter/Espacio en el summary). */
.tp-nav-dropdown {
    position: relative;
}

.tp-nav-dropdown > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.tp-nav-dropdown > summary::-webkit-details-marker {
    display: none;
}

.tp-nav-dropdown > summary::after {
    content: '▾';
    font-size: 0.55rem;
    line-height: 1;
}

.tp-nav-dropdown[open] > summary {
    background: rgba(251, 246, 236, 0.18);
}

.tp-nav-dropdown-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    z-index: 40;
    display: flex;
    flex-direction: column;
    min-width: 12rem;
    border-radius: var(--tp-radius-md);
    border: 1px solid var(--tp-border-strong);
    background: var(--tp-surface);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
    padding: 0.4rem;
    gap: 0.2rem;
}

.tp-nav-dropdown-item {
    display: block;
    border-radius: 0.55rem;
    padding: 0.6rem 0.75rem;
    min-height: var(--tp-tap-min);
    color: var(--tp-ink);
    background: none;
    border: none;
    text-align: left;
    font-family: var(--tp-font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

.tp-nav-dropdown-item:hover {
    background: var(--tp-surface-2);
}

.tp-nav-dropdown-item.tp-link-active {
    background: var(--tp-brand-soft);
    color: var(--tp-brand-text);
}

.tp-nav-dropdown-item-danger {
    color: var(--tp-danger);
}

.tp-nav-dropdown-info {
    margin: 0.2rem 0.75rem 0.4rem;
    font-size: 0.8rem;
    color: var(--tp-muted);
    white-space: nowrap;
}

.tp-nav-dropdown-info-email {
    font-weight: 700;
    color: var(--tp-ink);
    margin-bottom: 0;
}

/* Trigger del menú de cuenta: un avatar compacto (inicial del email) en vez
   del correo completo — el correo entero ocupaba demasiado ancho del
   navbar (pedido explícito). El correo completo sigue disponible en el
   tooltip (title) y como primera línea dentro del panel desplegable. */
.tp-user-menu > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tp-user-menu > summary::-webkit-details-marker {
    display: none;
}

.tp-user-menu > summary::after {
    content: none;
}

.tp-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    border: 1px solid rgba(251, 246, 236, 0.28);
    background: rgba(251, 246, 236, 0.14);
    color: var(--tp-visor-ink);
    font-family: var(--tp-font-ui);
    font-size: 0.95rem;
    font-weight: 700;
}

.tp-user-menu[open] .tp-user-avatar {
    background: var(--tp-brand);
    border-color: var(--tp-brand);
    color: var(--tp-on-brand);
}

.tp-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.tp-breadcrumb .tp-link {
    font-weight: 500;
}

@media (max-width: 620px) {
    .tp-nav-inner {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .tp-nav-actions {
        flex-wrap: wrap;
        gap: 0.3rem;
        width: 100%;
        justify-content: flex-end;
    }

    .tp-nav-actions .tp-link,
    .tp-nav-actions .tp-ghost-button {
        font-size: 0.85rem;
        padding: 0.45rem 0.6rem;
    }
}

/* ---------- Enlaces y botones base (contenido) ---------- */

.tp-link {
    text-decoration: none;
    color: var(--tp-ink);
    font-weight: 600;
}

.tp-link-button {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

.tp-ghost-button {
    border-radius: 0.65rem;
    border: 1px solid var(--tp-border-strong);
    background: var(--tp-surface);
    color: var(--tp-ink);
    font-family: var(--tp-font-ui);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.55rem 0.85rem;
    min-height: var(--tp-tap-min);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tp-ghost-button:hover {
    background: var(--tp-surface-2);
    border-color: var(--tp-ink);
}

.tp-button {
    border: 0;
    border-radius: var(--tp-radius-md);
    background: linear-gradient(180deg, var(--tp-brand) 0%, var(--tp-brand-deep) 100%);
    color: var(--tp-on-brand);
    font-family: var(--tp-font-ui);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.85rem 1.1rem;
    min-height: var(--tp-tap-min);
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.tp-button:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.tp-button:active {
    filter: brightness(0.96);
    transform: translateY(0);
}

/* ---------- Layout ---------- */

.tp-main {
    margin: 0 auto;
    max-width: 1100px;
    padding: 2rem 1rem 2.5rem;
    position: relative;
    z-index: 1;
}

.tp-shell {
    border: 1px solid var(--tp-border);
    background: var(--tp-surface);
    box-shadow: 0 8px 24px rgba(36, 31, 22, 0.08);
}

.tp-panel {
    position: relative;
    overflow: hidden;
    border-radius: var(--tp-radius-lg);
    padding: 1.6rem;
}

.tp-shell-sm { max-width: 28rem; }
.tp-shell-md { max-width: 500px; }
.tp-shell-lg { max-width: 700px; }
.tp-shell-xl { max-width: 800px; }

.tp-page-heading {
    margin: 0;
    font-size: 1.6rem;
    color: var(--tp-ink);
}

/* ---------- Formularios ---------- */

.tp-input {
    width: 100%;
    border-radius: var(--tp-radius-sm);
    border: 1px solid var(--tp-border-strong);
    background: var(--tp-surface);
    padding: 0.75rem 0.9rem;
    min-height: var(--tp-tap-min);
    color: var(--tp-ink);
    font-family: var(--tp-font-ui);
    font-size: var(--tp-text-base);
}

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

.tp-field {
    margin-top: 0.9rem;
}

.tp-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 700;
    color: var(--tp-ink);
}

.tp-form-title {
    margin: 0;
    color: var(--tp-ink);
    font-size: 1.8rem;
}

.tp-form-help {
    margin-top: 0.45rem;
    color: var(--tp-muted);
}

.tp-error-box {
    margin-top: 0.95rem;
    border-radius: var(--tp-radius-sm);
    border: 1px solid var(--tp-danger);
    background: var(--tp-danger-bg);
    color: var(--tp-danger);
    padding: 0.7rem 0.85rem;
}

.tp-field-error {
    margin-top: 0.35rem;
    color: var(--tp-danger);
    font-size: 0.9rem;
    font-weight: 600;
}

.tp-field-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 600px) {
    .tp-field-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

/* ---------- Badges y estados ---------- */

.tp-badge {
    display: inline-block;
    border-radius: 999px;
    background: var(--tp-brand-soft);
    color: var(--tp-brand-text);
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Estados: nunca solo color — los templates acompañan con texto/ícono */
.tp-status-ok { color: var(--tp-success); font-weight: 700; }
.tp-status-warn { color: var(--tp-brand-text); font-weight: 700; }
.tp-status-off { color: var(--tp-danger); font-weight: 700; }

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

/* Chip de estado de conexión (caja): "● Sin internet, sigues vendiendo" */
.tp-chip-conexion {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--tp-success-border);
    background: var(--tp-success-bg);
    color: var(--tp-success);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
}

.tp-chip-conexion[data-estado="offline"] {
    border-color: var(--tp-border-strong);
    background: var(--tp-surface-2);
    color: var(--tp-ink);
}

/* ---------- Diálogos / modales ---------- */

.tp-dialog-sm {
    max-width: 24rem;
    border: 1px solid var(--tp-border-strong);
    background: var(--tp-surface);
    color: var(--tp-ink);
    border-radius: var(--tp-radius-md);
    position: fixed;
    inset: 0;
    margin: auto;
}

.tp-modal-alert {
    background: var(--tp-surface);
    color: var(--tp-ink);
    border: 2px solid var(--tp-danger);
    border-radius: var(--tp-radius-md);
    padding: 2rem;
    position: fixed;
    inset: 0;
    margin: auto;
    z-index: 9999;
    max-width: 26rem;
    text-align: center;
}

.tp-modal-alert::backdrop {
    background: rgba(12, 10, 7, 0.55);
}

.tp-modal-alert-title {
    color: var(--tp-danger);
    font-size: 1.5rem;
    margin: 0;
}

.tp-modal-success {
    border-color: var(--tp-success);
}

.tp-modal-success .tp-modal-alert-title {
    color: var(--tp-success);
}

.tp-modal-alert-text {
    margin: 1rem 0;
}

.tp-modal-alert-button {
    background: var(--tp-danger);
    color: #ffffff;
    border: none;
    padding: 0.75rem 2rem;
    min-height: var(--tp-tap-min);
    border-radius: var(--tp-radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.tp-modal-success-button {
    background: var(--tp-success);
    color: #ffffff;
}

.tp-modal-warning {
    border-color: var(--tp-brand-deep);
}

.tp-modal-warning .tp-modal-alert-title {
    color: var(--tp-brand-text);
}

.tp-modal-warning-button {
    background: var(--tp-brand);
    color: var(--tp-on-brand);
}

[data-theme="noche"] .tp-modal-alert-button {
    color: var(--tp-visor);
}

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

.tp-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tp-table-scroll table {
    min-width: 480px;
}

.tp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.tp-table thead tr {
    border-bottom: 1px solid var(--tp-border-strong);
    text-align: left;
    color: var(--tp-muted);
}

.tp-table th {
    padding: 0.6rem 0.75rem;
    font-weight: 600;
}

.tp-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--tp-border);
    color: var(--tp-ink);
}

.tp-table tbody tr:last-child td {
    border-bottom: none;
}

.tp-table tbody tr:nth-child(even) {
    background: var(--tp-surface-2);
}

@media (max-width: 520px) {
    .tp-table-scroll table { min-width: 400px; }
    .tp-table-scroll th,
    .tp-table-scroll td {
        white-space: nowrap;
        padding: 0.5rem 0.5rem;
    }
}

/* ---------- Mensajes flash ---------- */

.tp-flash {
    border-radius: var(--tp-radius-sm);
    padding: 0.8rem 0.9rem;
    font-weight: 600;
}

.tp-flash-error {
    border: 1px solid var(--tp-danger);
    background: var(--tp-danger-bg);
    color: var(--tp-danger);
}

.tp-flash-ok {
    border: 1px solid var(--tp-success-border);
    background: var(--tp-success-bg);
    color: var(--tp-success);
}

.tp-stock-alerts {
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
}

.tp-footer {
    text-align: center;
    padding: 1rem 1rem 2rem;
    color: var(--tp-muted);
    font-size: 0.85rem;
}

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

.tp-login-page .tp-main {
    min-height: calc(100vh - 74px);
    display: flex;
    align-items: center;
}

.tp-login-grid {
    width: 100%;
    display: grid;
    gap: 1.2rem;
    grid-template-columns: 1.1fr 1fr;
}

/* Panel de marca: visor oscuro también en modo día (identidad de caja) */
.tp-login-brand-panel {
    background: var(--tp-visor);
    color: var(--tp-visor-ink);
    border-color: transparent;
}

.tp-login-brand-panel .tp-login-heading,
.tp-login-brand-panel .tp-kpi-value {
    color: var(--tp-visor-ink);
}

.tp-login-brand-panel .tp-subtitle,
.tp-login-brand-panel .tp-kpi-label,
.tp-login-brand-panel .tp-indicadores-meta {
    color: rgba(251, 246, 236, 0.78);
}

.tp-login-brand-panel .tp-badge {
    background: rgba(255, 193, 7, 0.18);
    color: #ffdf85;
}

.tp-login-brand-panel .tp-kpi {
    border: 1px solid rgba(251, 246, 236, 0.18);
    background: rgba(251, 246, 236, 0.06);
}

.tp-login-heading {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1.12;
    color: var(--tp-ink);
}

.tp-subtitle {
    margin-top: 0.8rem;
    color: var(--tp-muted);
    max-width: 52ch;
}

.tp-kpis {
    margin-top: 1.4rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
}

.tp-kpis-2 {
    margin-top: 0.65rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tp-kpi {
    border-radius: var(--tp-radius-sm);
    border: 1px solid var(--tp-border);
    background: var(--tp-surface-2);
    padding: 0.75rem;
}

.tp-kpi-label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tp-muted);
}

.tp-kpi-value {
    display: block;
    margin-top: 0.3rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--tp-ink);
}

.tp-kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.4rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-family: var(--tp-font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.4;
    border: 1px solid transparent;
}

.tp-kpi-trend:empty {
    display: none;
}

.tp-kpi-trend--up {
    color: var(--tp-success);
    background: var(--tp-success-bg);
    border-color: var(--tp-success-border);
}

.tp-kpi-trend--down {
    color: var(--tp-danger);
    background: var(--tp-danger-bg);
}

/* Panel de login: visor siempre oscuro (día y noche), se fijan los tonos
   pensados para fondo oscuro en vez de heredar los del tema claro. */
.tp-login-brand-panel .tp-kpi-trend--up {
    color: #7ed9a0;
    background: rgba(31, 122, 61, 0.28);
    border-color: rgba(126, 217, 160, 0.4);
}

.tp-login-brand-panel .tp-kpi-trend--down {
    color: #ffb4a9;
    background: rgba(179, 38, 30, 0.28);
    border-color: rgba(255, 180, 169, 0.4);
}

.tp-indicadores-meta {
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: var(--tp-muted);
}

.tp-login-footer {
    margin-top: 0.9rem;
    font-size: 0.9rem;
    color: var(--tp-muted);
}

.tp-login-footer .tp-link {
    color: var(--tp-brand-text);
}

[data-theme="noche"] .tp-login-footer .tp-link {
    color: var(--tp-brand-text);
}

/* Glows decorativos suaves (solo relleno de marca, sin texto encima) */
.tp-panel-glow::before {
    content: '';
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    width: 230px;
    height: 230px;
    right: -80px;
    top: -70px;
    background: radial-gradient(circle, rgba(255, 193, 7, 0.28) 0%, rgba(255, 193, 7, 0) 70%);
}

.tp-animated {
    animation: tp-fade-up 560ms ease-out;
}

.tp-animated-delay {
    animation: tp-fade-up 700ms ease-out;
}

@keyframes tp-fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 940px) {
    .tp-login-grid { grid-template-columns: 1fr; }
    .tp-kpis { grid-template-columns: 1fr; }
}

/* ---------- Caja (pantalla de venta) ---------- */

.tp-caja-page .tp-main {
    max-width: 1180px;
}

.tp-caja-shell {
    display: grid;
    gap: 1rem;
}

.tp-caja-header {
    border-radius: var(--tp-radius-lg);
    border: 1px solid var(--tp-border);
    background: var(--tp-surface);
    color: var(--tp-ink);
    padding: 1rem;
}

.tp-caja-title {
    margin: 0;
    font-size: clamp(1.5rem, 4vw, 2.1rem);
}

.tp-caja-subtitle {
    margin-top: 0.4rem;
    color: var(--tp-muted);
    font-size: var(--tp-text-base);
}

/* Visor de total: oscuro en ambos temas, como caja registradora real */
.tp-display {
    display: block;
    margin-top: 0.9rem;
    border-radius: var(--tp-radius-md);
    border: 1px solid var(--tp-border-strong);
    background: var(--tp-visor);
    padding: 0.9rem 1rem;
}

.tp-display-label {
    display: block;
    color: rgba(251, 246, 236, 0.72);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tp-display-amount {
    display: block;
    margin-top: 0.35rem;
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 700;
    line-height: 1;
    color: var(--tp-visor-ink);
}

.tp-caja-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1.15fr 0.85fr;
}

.tp-ticket-panel,
.tp-keypad-panel {
    border-radius: var(--tp-radius-lg);
    border: 1px solid var(--tp-border);
    background: var(--tp-surface);
    padding: 1rem;
}

.tp-ticket-title {
    margin: 0;
    color: var(--tp-ink);
    font-size: 1.15rem;
}

.tp-pos-card {
    border-radius: var(--tp-radius-md);
    border: 1px solid var(--tp-border);
    background: var(--tp-surface-2);
    padding: 0.9rem;
}

.tp-pos-card + .tp-pos-card {
    margin-top: 0.9rem;
}

.tp-product-grid {
    margin-top: 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.6rem;
    max-height: 26rem;
    overflow-y: auto;
}

.tp-product-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    border-radius: var(--tp-radius-sm);
    border: 1px solid var(--tp-border-strong);
    background: var(--tp-surface);
    padding: 0.65rem 0.75rem;
    min-height: var(--tp-tap-min);
    text-align: left;
    color: var(--tp-ink);
    cursor: pointer;
    font-family: var(--tp-font-ui);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.tp-product-tile:hover:not(:disabled) {
    border-color: var(--tp-brand-deep);
    background: var(--tp-brand-soft);
}

.tp-product-tile:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.tp-product-tile-nombre {
    font-weight: 600;
    font-size: var(--tp-text-base);
}

.tp-product-tile-precio {
    color: var(--tp-brand-text);
    font-weight: 700;
    font-size: var(--tp-text-base);
}

.tp-product-tile-stock {
    font-size: 0.85rem;
    color: var(--tp-muted);
}

.tp-cart-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tp-cart-item,
.tp-pago-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-radius: var(--tp-radius-sm);
    border: 1px solid var(--tp-border);
    background: var(--tp-surface);
    padding: 0.55rem 0.7rem;
    font-size: var(--tp-text-base);
}

.tp-cart-item-nombre {
    flex: 1;
}

.tp-cart-remove {
    background: none;
    border: none;
    color: var(--tp-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    min-width: var(--tp-tap-min);
    min-height: var(--tp-tap-min);
}

.tp-cart-remove:hover {
    color: var(--tp-danger);
}

.tp-cart-stepper {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.tp-cart-stepper-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tp-tap-min);
    min-height: var(--tp-tap-min);
    border-radius: var(--tp-radius-sm);
    border: 1px solid var(--tp-border-strong);
    background: var(--tp-surface);
    color: var(--tp-ink);
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tp-cart-stepper-btn:hover {
    background: var(--tp-brand-soft);
    border-color: var(--tp-brand-deep);
}

.tp-cart-stepper-cantidad {
    min-width: 2.2rem;
    text-align: center;
}

.tp-scan-feedback {
    margin: 0.4rem 0 0;
    padding: 0.4rem 0.6rem;
    border-radius: var(--tp-radius-sm);
    background: var(--tp-brand-soft);
    color: var(--tp-brand-text);
    font-size: 0.9rem;
    font-weight: 600;
}

.tp-ticket-help {
    margin: 0.3rem 0 0.65rem;
    color: var(--tp-muted);
    font-size: var(--tp-text-base);
}

.tp-ticket-input {
    width: 100%;
    border-radius: var(--tp-radius-sm);
    border: 1px solid var(--tp-border-strong);
    background: var(--tp-surface);
    color: var(--tp-ink);
    padding: 0.7rem 0.75rem;
    min-height: var(--tp-tap-min);
    font-size: var(--tp-text-base);
}

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

.tp-keypad-grid {
    margin-top: 0.8rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.tp-keypad-btn {
    border: 1px solid var(--tp-border-strong);
    border-radius: var(--tp-radius-sm);
    background: var(--tp-surface);
    color: var(--tp-ink);
    font-weight: 700;
    font-size: var(--tp-text-base);
    min-height: var(--tp-tap-min);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tp-keypad-btn:hover {
    background: var(--tp-brand-soft);
    border-color: var(--tp-brand-deep);
}

.tp-keypad-btn:active {
    background: var(--tp-surface-2);
}

.tp-submit {
    margin-top: 0.9rem;
    width: 100%;
    border: 0;
    border-radius: var(--tp-radius-md);
    background: linear-gradient(180deg, var(--tp-brand) 0%, var(--tp-brand-deep) 100%);
    color: var(--tp-on-brand);
    font-family: var(--tp-font-ui);
    font-size: 1.15rem;
    font-weight: 700;
    padding: 0.95rem 1rem;
    min-height: var(--tp-tap-min);
    cursor: pointer;
    transition: filter 0.15s ease;
}

.tp-submit:hover { filter: brightness(1.06); }
.tp-submit:active { filter: brightness(0.96); }

@media (max-width: 980px) {
    .tp-caja-grid { grid-template-columns: 1fr; }
    .tp-keypad-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .tp-keypad-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .tp-panel { padding: 1rem; }
    .tp-main { padding: 1rem 0.75rem 1.5rem; }
    .tp-caja-header { padding: 0.75rem; }
    .tp-ticket-panel,
    .tp-keypad-panel { padding: 0.75rem; }
    .tp-caja-grid { gap: 0.75rem; }
}

/* ---------- Home: Resumen del día ---------- */

.tp-resumen-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-radius: var(--tp-radius-md);
    border: 1px solid var(--tp-success-border);
    background: var(--tp-success-bg);
    color: var(--tp-success);
    font-weight: 700;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
}

.tp-resumen-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

.tp-resumen-kpi {
    border-radius: var(--tp-radius-md);
    border: 1px solid var(--tp-border);
    background: var(--tp-surface);
    padding: 1rem;
}

.tp-resumen-kpi-valor {
    display: block;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 700;
    color: var(--tp-ink);
}

.tp-resumen-kpi-conclusion {
    display: block;
    margin-top: 0.3rem;
    color: var(--tp-muted);
    font-size: var(--tp-text-base);
}

/* ---------- Utilidades ---------- */

.tp-stack-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tp-textarea-mono {
    font-family: var(--tp-font-mono);
    resize: vertical;
}

@media (max-width: 520px) {
    .tp-ghost-button,
    .tp-button {
        font-size: 0.95rem;
        padding: 0.6rem 0.75rem;
    }

    .tp-submit {
        font-size: 1.05rem;
        padding: 0.85rem 0.75rem;
    }
}

/* Selector de tema (navbar): 3 botones de solo ícono (☀️/🌙/🕐) en vez de un
   <select> con texto — ahorra espacio en la navbar (pedido explícito). El
   estado activo se marca con fondo + borde, nunca solo con color (D-018). */
.tp-theme-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(251, 246, 236, 0.18);
    background: rgba(251, 246, 236, 0.05);
    padding: 0.15rem;
}

.tp-theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Excepción consciente a la regla de targets ≥48px (D-008/D-018): pedido
       explícito de Alexis de que este control quede muy compacto y en
       vertical, y que la columna completa quepa en la altura normal de la
       navbar — 3 targets de 48px apilados (≈150px) rompían el layout. Es
       un control de preferencia de tema, no una acción operativa bajo
       presión de tiempo (como cobrar), así que el riesgo de accesibilidad
       es bajo comparado con el resto de los botones de la app. */
    min-height: 1.1rem;
    min-width: 1.1rem;
    padding: 0;
    border-radius: 0.4rem;
    border: 1px solid transparent;
    background: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tp-theme-btn:hover {
    background: rgba(251, 246, 236, 0.12);
}

.tp-theme-btn-active {
    background: rgba(251, 246, 236, 0.2);
    border-color: rgba(251, 246, 236, 0.4);
}

.tp-theme-btn-icon {
    display: inline-block;
    font-size: 0.5rem;
    opacity: 0.7;
    transition: font-size 0.15s ease, opacity 0.15s ease;
}

.tp-theme-btn-active .tp-theme-btn-icon {
    font-size: 0.65rem;
    opacity: 1;
}
