* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
/* Pantallas con tablas anchas (Nueva cotización): usan todo el ancho disponible */
.container-amplio { max-width: none; }
.main-header { position: sticky; top: 0; z-index: 1200; background: #2c3e50; color: #fff; padding: 12px 0; }
.main-header .container { display: flex; align-items: center; justify-content: flex-start; gap: 20px; position: relative; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 0.95rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.logo-img { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; flex: 0 0 auto; }
.main-nav { display: flex; align-items: center; }
.main-nav a { color: #fff; text-decoration: none; margin-left: 6px; font-size: 0.85rem; white-space: nowrap; padding: 4px 9px; border-top: 2px solid transparent; border-bottom: 2px solid transparent; }
.main-nav a:hover { text-decoration: none; background: rgba(255,255,255,0.12); }
.main-nav a.activo { border-top-color: #7fc4e8; border-bottom-color: #7fc4e8; }

/* Submenú del menú (agrupación Cotizaciones en admin) */
.nav-grupo { position: relative; display: inline-block; }
.nav-grupo-toggle { cursor: pointer; }
.caret { font-size: 0.7rem; opacity: 0.85; }
.nav-submenu { display: none; position: absolute; top: 100%; left: 0; background: #34495e; min-width: 225px; border-radius: 0 0 6px 6px; box-shadow: 0 6px 14px rgba(0,0,0,0.3); z-index: 1001; padding: 4px 0; }
.nav-submenu a { display: block; margin-left: 0; padding: 9px 16px; border: 0 none; }
.nav-submenu a:hover { background: #2c6e91; }
.nav-submenu a.activo { background: rgba(127,196,232,0.22); border-left: 3px solid #7fc4e8; padding-left: 13px; }
.nav-grupo.open .nav-submenu { display: block; }
.nav-logout { font-weight: 600; }
.main-content { padding: 25px 20px; flex: 1; }
.main-footer { background: #2c3e50; color: #fff; text-align: center; padding: 15px 0; margin-top: 40px; }
.main-footer p { margin: 0; font-size: 0.85rem; }

h1, h2, h3 { color: #2c3e50; }
.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); margin-bottom: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; font-family: inherit; line-height: normal; padding: 8px 16px; border-radius: 4px; border: none; cursor: pointer; text-decoration: none; color: #fff; background: #2c6e91; font-size: 0.9rem; }
.btn:hover { opacity: 0.9; }
.btn-success { background: #27ae60; }
.btn-danger { background: #c0392b; }
.btn-warning { background: #f39c12; color: #000; }
.btn-secondary { background: #7f8c8d; }
.btn-wa { background: #25d366; }

/* Efecto de relleno al pasar el mouse: el color baja desde arriba y el texto se pone blanco.
   Solo en dispositivos con mouse (en celular/tablet táctil se conservan los botones sólidos). */
@media (hover: hover) {
    .btn {
        --btn-color: #2c6e91;
        border: 2px solid var(--btn-color);
        border-radius: 50px;
        background: transparent;
        color: var(--btn-color);
        padding: 6px 16px;
        position: relative;
        overflow: hidden;
        isolation: isolate;
        z-index: 0;
        transition: all 0.35s;
    }
    .btn-success   { --btn-color: #27ae60; }
    .btn-danger    { --btn-color: #c0392b; }
    .btn-warning   { --btn-color: #d68910; }
    .btn-secondary { --btn-color: #7f8c8d; }
    .btn-wa        { --btn-color: #25d366; }

    .btn::before,
    .btn::after {
        content: '';
        position: absolute;
        width: 100%;
        height: 100%;
        top: -100%;
        left: 0;
        background: var(--btn-color);
        z-index: -1;
        transition: all 0.35s;
    }
    .btn::before { opacity: 0.5; }
    .btn::after  { transition-delay: 0.2s; }

    .btn:hover { color: #fff; opacity: 1; }
    .btn:hover::before,
    .btn:hover::after { top: 0; }
}

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 6px; overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eee; }
.table th { background: #2c6e91; color: #fff; }
.table tr:hover { background: #f9f9f9; }
.table tr.fila-coincide td { background: #fff8dc; }
.table tr.fila-coincide:hover td { background: #fff3cd; }
.table tr.fila-coincide td:first-child { border-left: 3px solid #f39c12; padding-left: 9px; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 0.95rem; }
.alert { padding: 12px 15px; border-radius: 4px; margin-bottom: 15px; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* Notificación flotante (arriba a la derecha) */
#toast-cont { position: fixed; top: 14px; right: 14px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 340px; padding: 11px 12px 11px 14px; border-radius: 6px; color: #fff; font-size: 0.92rem; line-height: 1.3; box-shadow: 0 6px 18px rgba(0,0,0,0.18); animation: toastEntra 0.18s ease-out; }
.toast-success { background: #27ae60; }
.toast-danger { background: #c0392b; }
.toast-warning { background: #d68910; }
.toast-info { background: #2c6e91; }
.toast-cerrar { background: none; border: 0; color: inherit; font-size: 1.15rem; line-height: 1; padding: 0 2px; cursor: pointer; opacity: 0.85; }
.toast-cerrar:hover { opacity: 1; }
.toast-saliendo { opacity: 0; transition: opacity 0.2s ease-in; }
@keyframes toastEntra { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .toast-saliendo { transition: none; } }

.login-container { max-width: 380px; margin: 80px auto; }
.login-card { background: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.login-logo { display: block; width: 144px; height: 144px; object-fit: contain; margin: 0 auto 18px; }
@media (max-width: 480px) { .login-logo { width: 112px; height: 112px; margin-bottom: 14px; } }

.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.dashboard-item { background: #fff; padding: 20px; border-radius: 8px; text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.dashboard-item a { color: #2c3e50; text-decoration: none; font-weight: 600; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 0.75rem; color: #fff; }
.badge-danger { background: #c0392b; }
.badge-warning { background: #f39c12; }
.badge-success { background: #27ae60; }
.badge-info { background: #3498db; }
.badge-secondary { background: #7f8c8d; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions a, .actions button { margin-right: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.menu-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }

.ayuda { background: #eef4f8; border-left: 4px solid #2c6e91; padding: 10px 14px; border-radius: 4px; color: #33566b; font-size: 0.92rem; margin: 10px 0 20px; }
.ayuda code { background: #fff; padding: 1px 5px; border-radius: 3px; }

.acciones-inicio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 20px 0 25px; }
.accion-card { display: block; background: #fff; border: 1px solid #e2e8ee; border-radius: 10px; padding: 22px 20px; text-decoration: none; box-shadow: 0 2px 6px rgba(0,0,0,0.06); transition: box-shadow 0.2s, border-color 0.2s; }
.accion-card:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.12); border-color: #2c6e91; }
.accion-titulo { display: block; font-size: 1.25rem; font-weight: 700; color: #2c3e50; margin-bottom: 6px; }
.accion-desc { display: block; color: #667; font-size: 0.9rem; }
.accion-primaria { background: #2c6e91; border-color: #2c6e91; }
.accion-primaria .accion-titulo, .accion-primaria .accion-desc { color: #fff; }
.accion-primaria:hover { background: #245b78; border-color: #245b78; }

.fila-campos { display: flex; gap: 18px; flex-wrap: wrap; }
.fila-campos > .form-group { flex: 1; min-width: 240px; margin-bottom: 0; }

.buscador-form { display: flex; gap: 10px; align-items: center; }
.buscador-form .buscador-clave { flex: 1; }
.buscador-form .btn { margin: 0; white-space: nowrap; }

.producto-ficha { border-left: 4px solid #27ae60; }
.info-lista-cot { background: #eef4f8; border-left: 4px solid #2c6e91; border-radius: 4px; padding: 10px 14px; color: #33566b; font-size: 0.92rem; }
.sin-stock { color: #c0392b; font-weight: 600; font-size: 0.85rem; }
.solo-pc { display: none; }

/* Nueva cotización: dos columnas en PC y tabletas */
.cot-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
/* min-width:0: las columnas pueden encogerse; el contenido ancho hace scroll
   dentro de su propia tarjeta en vez de desbordar la pantalla. */
.cot-col-izq, .cot-col-der { min-width: 0; }
.cot-col-der { position: sticky; top: 70px; }
.cot-col-der .card:last-child { margin-bottom: 0; }
.cot-col-der .table th, .cot-col-der .table td { padding: 8px; font-size: 0.85rem; }
.cot-col-der .table td:first-child { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cot-col-der .input-cantidad { width: 70px; padding: 6px; }

/* Título dentro de la barra del menú (solo PC) */
.header-titulo { display: none; margin: 0 0 0 12px; font-size: 0.95rem; font-weight: 600; color: #fff; padding-left: 12px; border-left: 1px solid rgba(255,255,255,0.3); white-space: nowrap; }

/* PC y tabletas (≥769 px). El modo celular NO se toca. */
@media (min-width: 769px) {
    /* Título en la barra y compactado vertical */
    .header-titulo { display: inline-block; }
    .main-content > h1 { display: none; }
    .main-header { padding: 8px 0; }
    .main-content { padding: 10px 20px 20px; }
    .main-footer { margin-top: 16px; padding: 10px 0; }
    .card { padding: 12px 14px; margin-bottom: 10px; }
    .card > h2:first-child, .card > h3:first-child { margin: 0 0 8px; font-size: 1.05rem; }
    .ayuda { padding: 6px 10px; margin: 6px 0 10px; font-size: 0.85rem; line-height: 1.35; }
    .buscador-clave { font-size: 1rem; padding: 6px 12px; }
    .buscador-form { gap: 8px; }
    .buscador-titulo { display: none; }
    .producto-ficha { margin-top: 10px !important; }
    .form-group { margin-bottom: 8px; }
    .form-group label { margin-bottom: 3px; }
    .form-group input, .form-group select, .form-group textarea { padding: 8px 10px; }
    .fila-campos { gap: 12px; }
    .table th, .table td { padding: 8px 10px; }
    .totales-barra { padding: 10px 14px; margin-top: 6px; }
    .acciones-finales { margin-top: 10px; }

    /* 58/42: la ficha de acabados necesita más ancho que el resumen de la cotización */
    .cot-layout { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); }
    .cot-col-izq .table th, .cot-col-izq .table td { padding: 7px 8px; font-size: 0.85rem; }
    /* Compacto para que la tabla quepa completa (incluido el botón Quitar) */
    .cot-col-der .table th, .cot-col-der .table td { padding: 7px 8px; font-size: 0.85rem; }
    .cot-col-der .table td:first-child { max-width: none; overflow: visible; text-overflow: clip; white-space: normal; }
    .cot-col-der .input-cantidad { width: 70px; }
    .cot-col-der .table .btn { padding: 7px 10px; font-size: 0.85rem; }
    .solo-pc { display: table-cell; }
    th.solo-pc { display: table-cell; }
}
.bloque-lista { background: #fff; border-radius: 8px; padding: 18px 20px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); margin-bottom: 18px; }
.bloque-lista h3 { margin: 0 0 10px; border-bottom: 2px solid #2c6e91; padding-bottom: 6px; }

.totales-barra { display: flex; gap: 25px; justify-content: flex-end; align-items: center; flex-wrap: wrap; background: #f7fafc; border: 1px solid #e2e8ee; border-radius: 8px; padding: 14px 18px; margin-top: 10px; }
.total-cot-flotante { position: fixed; top: 189px; right: 18px; bottom: auto; z-index: 1100; display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: #fff; border: 1px solid #d7e2e9; border-left: 4px solid #27ae60; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); color: #34495e; pointer-events: none; }
.total-cot-flotante strong { color: #27ae60; font-size: 1.15rem; white-space: nowrap; }
.total-cot-flotante[hidden] { display: none; }
.total-grande { font-size: 1.25rem; color: #27ae60; }
.acciones-finales { display: flex; gap: 12px; margin-top: 15px; }
.acciones-finales .btn { margin: 0; }
.input-cantidad { width: 90px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 0.95rem; }

/* Ficha de producto: acciones de pieza completa y de corte */
.acciones-ficha { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.acciones-ficha .form-corte { display: flex; align-items: center; gap: 6px; }
.input-metros { width: 74px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 0.95rem; }
.cant-con-unidad { display: inline-flex; align-items: center; gap: 4px; }
.unidad { color: #687783; font-size: 0.85rem; font-weight: 400; }
.mov-rapido { display: flex; gap: 6px; align-items: center; margin: 0; }
.mov-rapido .btn { display: inline-block; width: auto; margin: 0; padding: 8px 12px; font-weight: 700; }

.filtro-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 15px 0; }
.filtro-tab { padding: 8px 16px; border-radius: 20px; background: #fff; color: #2c6e91; text-decoration: none; font-weight: 600; font-size: 0.9rem; border: 1px solid #d0d7de; }
.filtro-tab.activo { background: #2c6e91; color: #fff; border-color: #2c6e91; }

.buscador-clave { font-size: 1.05rem; padding: 6px 12px; width: 100%; border: 1px solid #2c6e91; border-radius: 8px; }
.buscador-resultado { margin-top: 20px; }

.resumen-cot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 15px; margin: 20px 0; }
.resumen-cot > div { flex: 1; min-width: 200px; background: #fff; padding: 14px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); z-index: 2000; overflow-y: auto; -webkit-overflow-scrolling: touch; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.modal-overlay.open { display: block; }
.modal { position: relative; margin: 8vh auto 20px; background: #fff; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 4px 20px rgba(0,0,0,0.3); z-index: 2001; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid #eee; }
.modal-header h2 { margin: 0; font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: #666; line-height: 1; padding: 0 4px; }
.modal-body { padding: 15px 20px 20px; }
.modal-body p { margin: 0 0 12px; }
body.perfil-modal-abierto { overflow: hidden; }
.perfil-header { display: flex; align-items: center; gap: 8px; max-width: 230px; padding: 4px 12px 4px 4px; border: 1px solid #d7e2e9; border-radius: 24px; background: #fff; color: #34495e; text-align: left; cursor: pointer; font-family: inherit; }
.perfil-header:hover { background: #eef3f7; }
.perfil-header .perfil-avatar { width: 34px; height: 34px; flex-basis: 34px; }
.perfil-header .perfil-avatar-inicial { font-size: 0.95rem; }
.perfil-avatar { width: 42px; height: 42px; flex: 0 0 42px; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 50%; background: #2c6e91; color: #fff; font-weight: 700; }
.perfil-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.perfil-avatar-inicial { font-size: 1.05rem; }
.perfil-header-texto { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.perfil-header-texto strong, .perfil-header-texto small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perfil-header-texto strong { font-size: 0.85rem; }
.perfil-header-texto small { color: #6b7688; font-size: 0.74rem; }
.perfil-modal { max-width: 680px; margin: 3vh auto 20px; }
.perfil-modal-usuario { color: #6b7688; font-size: 0.85rem; }
.perfil-avatar-edicion { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; color: #66727d; font-size: 0.9rem; }
.perfil-avatar-grande { width: 72px; height: 72px; flex-basis: 72px; }
.perfil-avatar-grande .perfil-avatar-inicial { font-size: 1.5rem; }
.perfil-form { border-top: 1px solid #e6ebef; margin-top: 16px; padding-top: 14px; }
.perfil-form h3 { margin: 0 0 12px; font-size: 1rem; }
.perfil-form .fila-campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.perfil-form .form-group { margin-bottom: 10px; }
.perfil-form input[type="file"] { padding: 8px; }
.perfil-form small { display: block; margin-top: 6px; color: #687783; }
.perfil-modal-mensaje { display: none; margin: 12px 0; padding: 9px 12px; border-radius: 5px; }
.perfil-modal-mensaje:not(:empty) { display: block; }
.perfil-mensaje-ok { background: #d4edda; color: #155724; }
.perfil-mensaje-error { background: #f8d7da; color: #721c24; }

/* Pantallas medianas (769–1150 px): compactar la barra para que quepa en una línea */
@media (min-width: 769px) and (max-width: 1150px) {
    .main-header .container { gap: 12px; }
    .logo { font-size: 0.8rem; }
    .main-nav a { margin-left: 3px; padding: 4px 6px; }
    .header-titulo { margin-left: 8px; padding-left: 8px; font-size: 0.85rem; }
    .perfil-header { padding: 3px; }
    .perfil-header-texto { display: none; }
}
@media (min-width: 769px) and (max-width: 900px) {
    .header-titulo { display: none; }
    .main-content > h1 { display: block; }
    .logo { font-size: 0.75rem; }
    .main-nav a { margin-left: 2px; padding: 4px 4px; font-size: 0.8rem; }
    .main-nav a .etq-nuevo, .main-nav .etq-nuevo { font-size: 0.62rem; padding: 1px 4px; }
    .main-header .container { gap: 8px; padding: 0 12px; }
}

@media (max-width: 768px) {
    .main-header .container { padding-right: 50px; }
    .menu-toggle { display: block; position: absolute; right: 20px; top: 50%; margin-top: -14px; }
    .main-nav { display: none; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: #2c3e50; padding: 5px 0; z-index: 1000; }
    .main-nav.open { display: flex; }
    .main-nav a { display: block; margin: 0; padding: 12px 20px; border-top: 0; border-bottom: 1px solid #34495e; }
    .main-nav a.activo { background: #24343f; }
    .nav-grupo { display: block; }
    .nav-submenu { position: static; min-width: 0; border-radius: 0; box-shadow: none; background: #24343f; padding: 0; }
    .nav-submenu a { padding: 12px 20px 12px 36px; border-bottom: 1px solid #2c3e50; }
    .nav-submenu a.activo { border-left: 0; padding-left: 36px; }
    .main-nav a:last-child { border-bottom: none; }
    .main-content { padding: 15px 15px; }
    h1 { font-size: 1.4rem; }
    .btn { display: flex; width: 100%; text-align: center; margin-bottom: 8px; }
    .actions .btn, .actions button, .actions a { display: inline-block; width: auto; margin: 0; padding: 6px 10px; font-size: 0.85rem; }
    .table th, .table td { padding: 8px 10px; font-size: 0.9rem; }
    .card { padding: 15px; }
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .dashboard-item { padding: 15px 10px; }
    .dashboard-item h3 { font-size: 1.3rem; margin: 0 0 6px; }
    .dashboard-item a { font-size: 0.85rem; }
    .resumen-cot { flex-direction: column; }
    .resumen-cot > div { min-width: 0; }
    .cot-layout { grid-template-columns: 1fr; }
    .cot-col-der { position: static; }
    .acciones-inicio { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .accion-card { padding: 16px 14px; }
    .accion-titulo { font-size: 1.05rem; }
    .buscador-form { flex-direction: column; align-items: stretch; }
    .totales-barra { justify-content: space-between; }
    .acciones-finales { flex-direction: column; }
    .total-cot-flotante { top: auto; left: 10px; right: 10px; bottom: 10px; justify-content: center; gap: 10px; padding: 10px 12px; }
    .perfil-header { padding: 3px; }
    .perfil-header-texto { display: none; }
    .perfil-modal { width: calc(100% - 20px); margin: 10px auto; }
    .perfil-modal .modal-body { padding: 12px; }
    .perfil-form .fila-campos { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 480px) {
    .container { padding: 0 15px; }
    .logo { font-size: 0.8rem; }
    .btn { padding: 10px 14px; }
    .dashboard-grid { gap: 8px; }
    .dashboard-item { padding: 12px 8px; }
    .dashboard-item h3 { font-size: 1.15rem; }
    .dashboard-item a { font-size: 0.8rem; }
    #toast-cont { left: 10px; right: 10px; align-items: stretch; }
    .toast { max-width: none; }
    .total-cot-flotante { left: 10px; right: 10px; bottom: 10px; justify-content: center; gap: 10px; padding: 10px 12px; }
}

/* ==================== Novedades (etiqueta NUEVO + aviso en Inicio) ==================== */
.etq-nuevo { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 3px; background: #e74c3c; color: #fff; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.5px; vertical-align: middle; animation: etq-nuevo-latido 1.6s ease-in-out infinite; }
@keyframes etq-nuevo-latido { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.aviso-novedades { position: relative; background: #eaf5fc; border: 1px solid #7fc4e8; border-left: 5px solid #2980b9; border-radius: 6px; padding: 14px 46px 14px 16px; margin-bottom: 20px; }
.aviso-novedades h3 { margin: 0 0 6px; font-size: 1rem; color: #2471a3; }
.aviso-novedades ul { margin: 6px 0; padding-left: 20px; font-size: 0.9rem; }
.aviso-novedades .aviso-cerrar { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 1.3rem; color: #6b7688; cursor: pointer; line-height: 1; padding: 2px 6px; }
.aviso-novedades .aviso-cerrar:hover { color: #2c3e50; }

/* ==================== Existencias: tabla compacta y acciones siempre visibles ====================
   La pantalla trae 10 columnas (con Traspaso a tienda en la vista Bodega) y no cabía
   en el ancho disponible, dejando el botón Ajustar fuera de vista. */
.tabla-existencias { border-collapse: separate; border-spacing: 0; font-size: 0.85rem; overflow: visible; }
.tabla-existencias th:first-child { border-top-left-radius: 6px; }
.tabla-existencias th:last-child { border-top-right-radius: 6px; }
.tabla-existencias th, .tabla-existencias td { padding: 6px 8px; }
.tabla-existencias .input-cantidad { width: 58px !important; padding: 5px 6px; }
.tabla-existencias .mov-rapido { gap: 4px; }
.tabla-existencias .mov-rapido .btn { padding: 6px 9px; }
.tabla-existencias .btn { padding: 6px 11px; }
.tabla-existencias th:last-child, .tabla-existencias td:last-child {
    position: sticky; right: 0; background: #fff;
    box-shadow: -7px 0 8px -6px rgba(0,0,0,0.35);
}
.tabla-existencias th:last-child { background: #2c6e91; }
.tabla-existencias tbody tr:hover td:last-child { background: #f9f9f9; }

/* ==================== Cotizaciones: buscador y botones en la misma fila ==================== */
.barra-cot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.barra-cot .form-group { flex: 1 1 220px; max-width: 520px; margin-bottom: 0; }
.barra-cot .actions { margin-left: auto; }
.barra-cot-conteo { display: block; color: #687783; font-size: 0.85rem; margin-bottom: 10px; }

/* ==================== Menú lateral (solo PC ≥769 px) ====================
   En celular no existe: sigue el menú ☰ de siempre. */
.sidebar { display: none; }

@media (min-width: 769px) {
    .sidebar {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0; width: 235px;
        background: #2c3e50; color: #fff; z-index: 1300;
    }
    body { padding-left: 235px; }
    body.sb-plegado { padding-left: 60px; }
    body.sb-plegado .sidebar { width: 60px; }

    /* La barra superior queda delgada: solo el título de la pantalla */
    .main-header .logo,
    .main-header .menu-toggle,
    .main-header .main-nav,
    .main-header .perfil-header { display: none; }
    .header-titulo { display: inline-block; margin: 0; padding: 0; border-left: 0; font-size: 1rem; }
    .main-content > h1 { display: none; }

    /* Marca + botón de plegar */
    .sb-marca { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid rgba(255,255,255,0.12); }
    .sb-logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 0.82rem; line-height: 1.25; display: inline-flex; align-items: center; gap: 8px; }
    .sb-logo-img { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; flex: 0 0 auto; }
    .sb-logo-txt { min-width: 0; }
    .sb-plegar { margin-left: auto; background: none; border: 0; color: #cfe0ea; font-size: 1.05rem; cursor: pointer; padding: 2px 7px; border-radius: 4px; }
    .sb-plegar:hover { background: rgba(255,255,255,0.14); color: #fff; }

    /* Perfil */
    .sb-perfil { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; background: none; border: 0; border-bottom: 1px solid rgba(255,255,255,0.12); color: #fff; cursor: pointer; font-family: inherit; text-align: left; }
    .sb-perfil:hover { background: rgba(255,255,255,0.08); }
    .sb-perfil .perfil-avatar { width: 36px; height: 36px; flex: 0 0 36px; }
    .sb-perfil-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
    .sb-perfil-txt strong, .sb-perfil-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sb-perfil-txt strong { font-size: 0.85rem; }
    .sb-perfil-txt small { color: #9db2c0; font-size: 0.74rem; }

    /* Opciones */
    .sb-nav { flex: 1; overflow-y: auto; padding: 6px 0; }
    .sb-link, .sb-grupo-t { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px; color: #d5dde4; text-decoration: none; font-size: 0.88rem; background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; }
    .sb-link:hover, .sb-grupo-t:hover { background: rgba(255,255,255,0.08); color: #fff; }
    .sb-link.activo { background: #2c6e91; color: #fff; }
    .sb-grupo-t.activo { color: #fff; box-shadow: inset 3px 0 0 #7fc4e8; }
    .sb-ico { width: 18px; height: 18px; flex: 0 0 18px; }
    .sb-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .caret-sb { margin-left: auto; font-size: 0.62rem; transition: transform 0.15s; }
    .sb-grupo.open .caret-sb { transform: rotate(180deg); }
    .sb-sub { display: none; }
    .sb-grupo.open .sb-sub { display: block; }
    .sb-sub a { display: block; padding: 9px 16px 9px 44px; color: #cdd8e0; text-decoration: none; font-size: 0.84rem; }
    .sb-sub a:hover { background: rgba(255,255,255,0.08); color: #fff; }
    .sb-sub a.activo { background: rgba(127,196,232,0.2); color: #fff; box-shadow: inset 3px 0 0 #7fc4e8; }
    .sb-pie { border-top: 1px solid rgba(255,255,255,0.12); padding: 4px 0; }

    /* Plegado: solo íconos; los grupos abren su submenú al pasar el mouse */
    body.sb-plegado .sb-logo-txt,
    body.sb-plegado .sb-perfil-txt,
    body.sb-plegado .sb-txt,
    body.sb-plegado .caret-sb { display: none; }
    body.sb-plegado .sb-logo { justify-content: center; }
    body.sb-plegado .sb-marca { justify-content: center; padding: 11px 0; }
    body.sb-plegado .sb-plegar { margin: 0; }
    body.sb-plegado .sb-perfil { justify-content: center; padding: 12px 0; }
    body.sb-plegado .sb-link, body.sb-plegado .sb-grupo-t { justify-content: center; padding: 11px 0; }
    body.sb-plegado .sb-nav { overflow: visible; }
    body.sb-plegado .sb-grupo { position: relative; }
    body.sb-plegado .sb-sub { position: absolute; left: 100%; top: 0; width: 215px; background: #34495e; border-radius: 0 6px 6px 0; box-shadow: 0 6px 14px rgba(0,0,0,0.3); padding: 4px 0; }
    body.sb-plegado .sb-grupo:hover .sb-sub,
    body.sb-plegado .sb-grupo.open .sb-sub { display: block; }
    body.sb-plegado .sb-sub a { justify-content: flex-start; padding: 9px 16px; }
    body.sb-plegado .sb-pie { padding: 4px 0; }
}

/* ==================== Tutor: ayudas contextuales "?" ==================== */
.ctx-chip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; padding: 0; border: none; border-radius: 50%;
    background: #2c6e91; color: #fff; font-size: 0.72rem; font-weight: 700;
    line-height: 1; cursor: pointer; vertical-align: middle; font-family: inherit;
}
.ctx-chip:hover { background: #215873; }
/* Parpadeo cada 5 segundos: una pulsación breve al inicio de cada ciclo */
.ctx-chip.parpadea { animation: ctxParpadeo 5s infinite; }
.ctx-chip.visto { background: #b6c2c9; }
@keyframes ctxParpadeo {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(44, 110, 145, 0.55); }
    6%   { transform: scale(1.35); box-shadow: 0 0 0 7px rgba(44, 110, 145, 0); }
    12%  { transform: scale(1);    box-shadow: 0 0 0 0 rgba(44, 110, 145, 0); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(44, 110, 145, 0); }
}
.ctx-pop {
    display: none; position: fixed; z-index: 3000; background: #fff;
    border: 1px solid #cfd8dd; border-radius: 8px; padding: 12px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); font-size: 0.85rem;
}
.ctx-pop h4 { margin: 0 0 5px; font-size: 0.95rem; color: #2c3e50; }
.ctx-pop p { margin: 0 0 10px; color: #444; }
.ctx-pop-pie { display: flex; justify-content: flex-end; gap: 6px; }
.ctx-pop-pie .btn { padding: 5px 10px; font-size: 0.8rem; }
.ctx-toast {
    position: fixed; z-index: 3001; background: #2c3e50; color: #fff;
    font-size: 0.82rem; padding: 6px 10px; border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); opacity: 1;
    transition: opacity 0.4s; pointer-events: none; white-space: nowrap;
}
.ctx-toast.fuera { opacity: 0; }

/* ==================== Tutor: tour guiado ==================== */
/* La capa oscurece todo menos el elemento señalado (4 paneles + marco),
   así el resaltado no se recorta dentro de tablas con scroll. */
.tour-capa { position: fixed; inset: 0; z-index: 9998; pointer-events: none; }
.tour-capa > div { position: fixed; background: rgba(15, 23, 42, 0.72); }
.tour-capa .tour-marco { background: transparent; border: 2px solid #fff; border-radius: 6px; box-shadow: 0 0 0 3px rgba(44, 110, 145, 0.75); }
.tour-tip {
    display: none; position: fixed; z-index: 9999; background: #fff; border-radius: 8px;
    padding: 14px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); font-size: 0.9rem;
}
.tour-tip h4 { margin: 0 0 6px; font-size: 1rem; color: #2c3e50; }
.tour-tip p { margin: 0 0 4px; color: #444; }
.tour-tip-pie { margin-top: 12px; }
.tour-tip-pie small { display: block; margin-bottom: 8px; color: #7a878e; }
.tour-tip-botones { display: flex; gap: 6px; justify-content: flex-end; }
.tour-tip-botones .btn { padding: 6px 12px; font-size: 0.82rem; }

/* ===== Modo app (celular ≤768 px). El escritorio no se toca. ===== */
.app-tabbar, .app-sheet, .app-back { display: none; }

@media (max-width: 768px) {
    :root { --app-tabbar-h: 58px; }

    body.app-modo { padding-bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom)); min-height: 100dvh; overscroll-behavior-y: contain; }

    /* Barra superior compacta: atrás / ícono + título de la pantalla */
    .main-header { padding: 8px 0; }
    .main-header .container { display: flex; align-items: center; gap: 10px; padding-left: 12px; padding-right: 12px; }
    body.app-modo .main-header .logo-txt { display: none; }
    body.app-modo .main-header .logo-img { width: 28px; height: 28px; }
    body.app-modo .header-titulo { display: block; flex: 1 1 auto; min-width: 0; margin: 0; padding: 0; border: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; }
    body.app-modo .main-content > h1 { display: none; }
    body.app-modo .main-nav, body.app-modo .menu-toggle, body.app-modo .perfil-header { display: none !important; }

    .app-back {
        display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
        width: 34px; height: 34px; border-radius: 9px; border: 0;
        background: rgba(255,255,255,0.14); color: #fff; font-size: 1.15rem; line-height: 1;
        -webkit-tap-highlight-color: transparent;
    }
    .app-back:active { background: rgba(255,255,255,0.26); }

    /* Barra inferior de pestañas */
    .app-tabbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1300; display: flex;
        background: #24343f; border-top: 1px solid rgba(255,255,255,0.08);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .app-tab {
        position: relative; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px; height: var(--app-tabbar-h); padding: 0; background: none; border: 0;
        color: #9db2c0; text-decoration: none; font-family: inherit; font-size: 0.66rem; font-weight: 600;
        -webkit-tap-highlight-color: transparent;
    }
    .app-tab svg { width: 22px; height: 22px; }
    .app-tab.activo { color: #fff; }
    .app-tab.activo::before { content: ""; position: absolute; top: 0; left: 18%; right: 18%; height: 3px; border-radius: 0 0 3px 3px; background: #7fc4e8; }
    .app-tab:active { background: rgba(255,255,255,0.08); }
    .app-tab-badge {
        position: absolute; top: 5px; left: 50%; margin-left: 6px;
        background: #c0392b; color: #fff; font-style: normal; font-size: 0.58rem;
        line-height: 1.4; padding: 0 5px; border-radius: 9px;
    }

    /* Hoja "Más" */
    .app-sheet { position: fixed; inset: 0; z-index: 1400; display: none; background: rgba(0,0,0,0.45); }
    .app-sheet.open { display: block; }
    .app-sheet-panel {
        position: absolute; left: 0; right: 0; bottom: 0; background: #fff;
        border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom);
        max-height: 82vh; overflow-y: auto; animation: appSheet 0.18s ease-out;
    }
    @keyframes appSheet { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
    .app-sheet-cab { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #eef2f5; position: sticky; top: 0; background: #fff; }
    .app-sheet-cerrar { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: #7a8b99; padding: 0 4px; }
    .app-sheet-lista { padding: 6px 0 10px; }
    .app-sheet-lista a, .app-sheet-lista button {
        display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 18px;
        color: #2c3e50; text-decoration: none; font-family: inherit; font-size: 0.95rem;
        background: none; border: 0; text-align: left; -webkit-tap-highlight-color: transparent;
    }
    .app-sheet-lista a:active, .app-sheet-lista button:active { background: #f2f6f9; }
    .app-sheet-lista svg { width: 20px; height: 20px; color: #5b7386; flex: 0 0 auto; }
    .app-sheet-salir { color: #c0392b !important; }
    .app-sheet-salir svg { color: #c0392b; }
    body.app-hoja-abierta { overflow: hidden; }

    /* Controles táctiles: sin zoom al enfocar y áreas cómodas */
    input, select, textarea { font-size: 16px; }
    .btn { min-height: 44px; }
    a, button { -webkit-tap-highlight-color: transparent; }

    /* El total flotante y los avisos no quedan tapados por la barra */
    .total-cot-flotante { bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom) + 8px); }
    #toast-cont { top: 64px; }
}

/* Listas como tarjetas en celular (solo las tablas marcadas con .tabla-app) */
@media (max-width: 768px) {
    .tabla-app { display: block; background: transparent; border-radius: 0; overflow: visible; }
    .tabla-app thead { display: none; }
    .tabla-app tbody { display: block; }
    .tabla-app tr {
        display: block; background: #fff; border: 1px solid #e3e9ee; border-radius: 10px;
        padding: 10px 12px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }
    .tabla-app td {
        display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
        width: auto; padding: 5px 0; border: 0; border-bottom: 1px solid #f2f5f7;
        font-size: 0.88rem; text-align: right;
    }
    .tabla-app td:last-child { border-bottom: 0; }
    .tabla-app td::before {
        content: attr(data-label); flex: 0 0 40%; font-weight: 600; color: #7a8b99; text-align: left;
    }
    .tabla-app td[data-label=""]::before { content: none; }
    .tabla-app td.actions { justify-content: flex-end; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
    .tabla-app td.actions::before { flex: 1 1 100%; margin-bottom: 2px; }
    /* Existencias: la columna de acciones fija y el compactado no aplican en tarjetas */
    .tabla-app td:last-child, .tabla-app th:last-child { position: static; box-shadow: none; }
    .tabla-existencias td, .tabla-existencias th { padding: 5px 0; font-size: 0.88rem; }
    .tabla-existencias td.actions { padding-top: 8px; }
}

/* Transiciones entre pantallas (solo celular). La barra y las pestañas quedan fijas. */
@media (max-width: 768px) {
    @view-transition { navigation: auto; }

    .main-header { view-transition-name: app-header; }
    .app-tabbar { view-transition-name: app-tabbar; }

    /* La barra superior y la barra inferior no se animan: solo cambia el contenido */
    ::view-transition-old(app-header), ::view-transition-new(app-header),
    ::view-transition-old(app-tabbar), ::view-transition-new(app-tabbar) { animation: none; }

    ::view-transition-old(root) { animation: appSalida 0.16s ease-in both; }
    ::view-transition-new(root) { animation: appEntrada 0.22s ease-out both; }

    @keyframes appSalida { to { opacity: 0; transform: translateY(-6px); } }
    @keyframes appEntrada { from { opacity: 0; transform: translateY(10px); } }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
