:root {
    --primario: #E0B060; 
    --primario-hover: #D0A060; 
    --secundario: #F8F1E8; 
    --texto: #303020;      
    --texto-muted: #907050;
    --peligro: #C94F4F;    
    --borde: #E8D9C7;      
    --info: #D0A060;       
    --cancelado: #F9EEEE;  
    --editando: #FDF4E1;   
    --sidebar-bg: #303020; 
    --sidebar-hover: #4A4033;
    --whatsapp: #25D366;
    --whatsapp-hover: #128C7E;
    
    --radius-sm: 0.375rem;
    --radius-md: 0.625rem;
    --radius-lg: 0.875rem;
    --shadow-base: 0 1px 3px 0 rgba(48,48,32,0.06), 0 1px 2px -1px rgba(48,48,32,0.06);
    --shadow-hover: 0 10px 15px -3px rgba(48,48,32,0.08), 0 4px 6px -4px rgba(48,48,32,0.04);
    --transition-bounce: 220ms cubic-bezier(0.16, 1, 0.3, 1);
    
    --pc-btn-size: 32px;
    --pc-btn-font: 17px;
    --pc-btn-font-minus: 21px;
    --pc-qty-font: 1.05rem;
    --pc-ctrl-gap: 6px;
    --pc-ctrl-pad-y: 5px;
    --pc-ctrl-pad-x: 7px;
    --pc-ctrl-max-h: 2.7rem;
    --pc-card-min-h: 4.1rem;
    --fab-size: 2.25rem;
    --fab-font: 1.35rem;
    --qty-width: 2.20rem;
    --qty-font: 1.05rem;
    --fab-gap: 0.35rem;
    --fab-offset-y: 1.05rem;
    --card-bottom-space: 1.60rem;
    --card-width: 5.6rem;
    --card-title-size: 0.875rem;
    --card-price-size: 1.00rem;
    --card-pad: 0.85rem;
}

html { font-size: 100%; }

body { 
    font-family: 'Nunito', system-ui, sans-serif; 
    background: #FCFAF8; 
    margin: 0; 
    color: var(--texto); 
    height: 100dvh; 
    display: flex; 
    /* Cambiamos hidden por auto para permitir el scroll si es necesario */
    overflow-y: auto; 
}

.tabular-nums, table, .summary-value { font-variant-numeric: tabular-nums; }

/* --- SIDEBAR --- */
.sidebar-main { width: 16rem; background: var(--sidebar-bg); color: white; display: none; flex-direction: column; flex-shrink: 0; box-shadow: 0.25rem 0 0.625rem rgba(0,0,0,0.15); z-index: 2000; transition: all 0.3s ease; }
.sidebar-brand { padding: 1.5rem 1.25rem; border-bottom: 0.0625rem solid rgba(255,255,255,0.05); display: flex; justify-content: center; align-items: center; }
.sidebar-logo-img { max-width: 100%; height: 8rem; object-fit: contain; }
.sidebar-menu { flex: 1; padding: 1.25rem 0; display: flex; flex-direction: column; gap: 0.5rem; overflow-y: auto; }
.nav-tab { background: transparent; color: #a8a096; border: none; padding: 0.875rem 1.5rem; cursor: pointer; font-weight: 800; text-align: left; font-size: 0.9375rem; display: flex; align-items: center; gap: 0.75rem; border-radius: var(--radius-md); margin: 0 0.75rem; transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease; }
.nav-tab i { width: 1.25rem; height: 1.25rem; opacity: 0.7; transition: opacity 0.2s; }
.nav-tab:hover { background: var(--sidebar-hover); transform: translateX(4px); color: white; }
.nav-tab:hover i { opacity: 1; }
.nav-tab.active { background: rgba(224, 176, 96, 0.15); color: var(--primario); }
.nav-tab.active i { opacity: 1; color: var(--primario); }
.sidebar-footer { padding: 1.25rem; border-top: 0.0625rem solid rgba(255,255,255,0.05); }

/* --- CONTENEDORES --- */
.content-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; min-height: 0; }
.view-section { 
    display: none; 
    flex: 1; 
    min-height: 0;
    overflow-y: auto; 
    padding: 0.5rem; 
    -webkit-overflow-scrolling: touch;
}

.view-section.active { 
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    min-height: 0;
}

.view-section.gsap-transitioning { display: flex; flex-direction: column; position: absolute; top: 0; left: 0; width: 100%; height: 100%; padding: 1.5rem; box-sizing: border-box; background: #FCFAF8; z-index: 10; }

/* --- POS & ESTRUCTURAS --- */
.pos-layout { display: flex; gap: 0.25rem; height: 100%; overflow: hidden; flex-direction: row; }
.grid-productos { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.75rem; flex: 1; min-height: 0; overflow-y: auto; align-content: start; padding-bottom: 1.25rem; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.desktop-card { background: white; border: 2px solid var(--borde); padding: 1.15rem; border-radius: var(--radius-lg); cursor: pointer; text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 5rem; transition: transform var(--transition-bounce), box-shadow var(--transition-bounce), border-color 0.2s; }
.desktop-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--primario-hover); }
.sidebar-ticket { width: 24rem; background: white; border-radius: var(--radius-lg); border: 2px solid var(--borde); display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; box-shadow: var(--shadow-base); }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.15rem; background: white; padding: 1rem; border-radius: var(--radius-lg); border: 2px solid var(--borde); flex-wrap: wrap; gap: 0.75rem; box-shadow: var(--shadow-base); position: sticky; top: 0; z-index: 50; }
.view-title { margin: 0; font-size: 1.35rem; font-weight: 900; color: var(--texto); }
.view-subtitle { margin: 0.25rem 0 0; font-size: 0.875rem; font-weight: 700; color: var(--texto-muted); }

/* --- TABLAS (PC) --- */
.table-wrapper { display: flex; flex-direction: column; gap: 0.25rem; overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; padding-right: 0.5rem; padding-bottom: 2.5rem; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.table-container { background: white; border-radius: var(--radius-lg); border: 2px solid var(--borde); overflow: auto; flex: 1; box-shadow: var(--shadow-base); }
table { width: 100%; border-collapse: collapse; min-width: 40rem; }
th { background: var(--secundario); padding: 0.875rem 1rem; text-align: left; font-size: 0.75rem; border-bottom: 2px solid var(--borde); color: var(--texto-muted); text-transform: uppercase; position: sticky; top: 0; z-index:10; white-space: nowrap; font-weight: 800;}
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--borde); font-size: 0.875rem; font-weight: 600;}
tr { transition: background 0.15s; cursor: pointer; }
tr:hover { background: rgba(224, 176, 96, 0.1) !important; }
tr.status-cancelada { background-color: var(--cancelado); color: var(--peligro); }

.input-stock { width: 4.5rem; padding: 0.375rem; border: 2px solid var(--borde); border-radius: var(--radius-sm); font-weight: 800; text-align: center; font-size: 0.875rem; transition: border-color 0.2s, box-shadow 0.2s; outline: none; font-family: 'Nunito', sans-serif;}
.input-stock:focus { border-color: var(--primario); box-shadow: 0 0 0 3px rgba(224, 176, 96, 0.2); }
tr.estado-rojo { background-color: #FDF2F2; }
tr.estado-rojo td { color: #A03D3D; border-bottom-color: #F8D8D8; }
tr.estado-rojo .input-stock { border-color: #DDAAAA; color: #A03D3D; background: white; }
tr.estado-naranja { background-color: #FDF7EB; }
tr.estado-naranja td { color: #A67623; border-bottom-color: #FBEBD2; }
tr.estado-naranja .input-stock { border-color: #E2C79A; color: #A67623; background: white; }
tr.estado-verde { background-color: #F4F9F4; }
tr.estado-verde td { color: #43694F; border-bottom-color: #D3ECD7; }
tr.estado-verde .input-stock { border-color: #92CDA0; color: #43694F; background: white; }

/* --- CONFIGURACIÓN --- */
.config-wrapper { display: flex; flex-direction: column; gap: 0.25rem; height: 100%; overflow: hidden; }
.config-layout { display: grid; grid-template-columns: 15rem 1fr; gap: 0.25rem; flex: 1; min-height: 0; overflow: hidden; }
.config-sidebar { background: white; border: 2px solid var(--borde); border-radius: var(--radius-lg); box-shadow: var(--shadow-base); padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; min-height: 0; }
.config-tab { width: 100%; border: none; background: transparent; color: var(--texto-muted); padding: 0.875rem 1rem; border-radius: var(--radius-md); font-weight: 800; text-align: left; display: flex; align-items: center; gap: 0.75rem; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease; }
.config-tab i, .config-tab svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.config-tab:active { transform: scale(0.96); }
.config-tab:hover { background: var(--secundario); color: var(--texto); }
.config-tab.active { background: rgba(224, 176, 96, 0.15); color: var(--primario-hover); }
.config-content { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; flex: 1; height: 100%; }
.config-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; flex-direction: column; gap: 1rem; padding-right: 0.5rem; padding-bottom: 1rem; }
.config-panel.active { display: block !important; }
.config-panel .table-wrapper { flex: none !important; height: auto !important; overflow: visible !important; margin-bottom: 2.5rem; }
.config-panel .table-container { flex: none !important; height: auto !important; max-height: none !important; overflow-x: auto !important; }

/* --- FORMULARIOS Y BOTONES --- */
.form-group { margin-bottom: 0.875rem; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 800; margin-bottom: 0.375rem; color: var(--texto-muted); }
.form-group input, .form-group select { width: 100%; padding: 0.625rem 0.75rem; border: 2px solid var(--borde); border-radius: var(--radius-md); box-sizing: border-box; font-size: 0.875rem; font-family: 'Nunito', sans-serif; font-weight: 600; background: var(--secundario); color: var(--texto); transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s, color 0.2s; }
.form-group input:focus, .form-group select:focus { border-color: var(--primario); background: white; box-shadow: 0 0 0 3px rgba(224, 176, 96, 0.2); outline: none; }
.qty-control { display: flex; align-items: center; gap: 0.375rem; background: var(--secundario); padding: 0.25rem; border-radius: var(--radius-sm); border: 1px solid var(--borde); }
.btn-qty { background: white; border: 1px solid var(--borde); border-radius: 0.25rem; width: 1.75rem; height: 1.75rem; display: flex; justify-content: center; align-items: center; cursor: pointer; font-weight: 900; font-size: 0.875rem; color: var(--texto); transition: transform 0.1s, background 0.1s; }
.btn-qty:hover { background: var(--secundario); border-color: var(--primario-hover); }
.btn-qty:active { transform: scale(0.9); }
.input-qty { width: 2.75rem; text-align: center; border: 1px solid var(--borde); border-radius: 0.25rem; padding: 0.25rem 0; font-weight: 900; font-size: 0.875rem; color: var(--texto); outline: none; font-family: 'Nunito', sans-serif;}
.input-qty:focus { border-color: var(--primario); }
.btn { padding: 0.625rem 1.25rem; border-radius: var(--radius-md); border: none; font-weight: 900; cursor: pointer; transition: transform var(--transition-bounce), box-shadow var(--transition-bounce), background 0.15s, color 0.15s; font-size: 0.875rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; font-family: 'Nunito', sans-serif; letter-spacing: 0.02em; -webkit-tap-highlight-color: transparent; }
.btn i, .btn svg { width: 1.125rem; height: 1.125rem; flex-shrink: 0; }
.btn-sm { padding: 0.4rem 0.6rem; border-radius: var(--radius-sm); font-size: 0.8125rem; }
.btn-sm i, .btn-sm svg { width: 0.9rem; height: 0.9rem; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn:active { transform: scale(0.96); box-shadow: var(--shadow-base); }
.btn-primario { background: var(--primario); color: var(--texto); border: 1px solid transparent; }
.btn-primario:hover { background: var(--primario-hover); }
.btn-primario:disabled { background: var(--borde); color: #A0988C; cursor: not-allowed; transform: none; box-shadow: none;}
.btn-peligro { background: var(--peligro); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-outline { border: 2px solid var(--borde); background: white; color: var(--texto); }
.btn-outline:hover { background: var(--secundario); border-color: var(--primario); color: var(--texto); }
.btn-whatsapp { background: white; border: 2px solid var(--whatsapp); color: var(--texto); }
.btn-whatsapp:hover { background: #f0fdf4; color: var(--whatsapp-hover); border-color: var(--whatsapp-hover); }
.btn-eliminar-modal { width: 100%; background: #FDF2F2; color: var(--peligro); border: 2px solid #DDAAAA; border-radius: var(--radius-md); padding: 0.625rem 1.25rem; font-size: 0.875rem; font-weight: 900; font-family: 'Nunito', sans-serif; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-eliminar-modal:hover { background: var(--peligro); color: white; border-color: var(--peligro); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn-eliminar-modal:active { transform: scale(0.96); box-shadow: var(--shadow-base); }
.badge { padding: 0.25rem 0.5rem; border-radius: var(--radius-sm); font-size: 0.6875rem; font-weight: 800; text-transform: uppercase; white-space: nowrap; letter-spacing: 0.04em;}
.hidden { display: none !important; }
#indicador-edicion { background: var(--editando); padding: 0.875rem; border-radius: var(--radius-md); margin-bottom: 1rem; font-weight: 800; display: flex; justify-content: space-between; align-items: center; border: 2px solid var(--primario-hover); color: var(--texto-muted); font-size: 0.875rem;}

/* --- MODALES Y VARIOS --- */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(48, 48, 32, 0.65); z-index: 3000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.modal-gsap { opacity: 0; pointer-events: none; } 
.modal-box { background: white; padding: 1.75rem; border-radius: 1.25rem; box-shadow: 0 25px 50px -12px rgba(48,48,32,0.3); max-height: 90dvh; display: flex; flex-direction: column; overflow: hidden; width: 90%; max-width: 25rem; transform-origin: center center; border: 1px solid var(--borde); }
.modal-box > *:not(h3):not(.modal-footer) { overflow-y: auto; flex: 1; min-height: 0; padding-right: 0.5rem; }
.pago-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; padding: 0.75rem; border: 2px solid var(--borde); border-radius: var(--radius-md); background: var(--secundario); }
.pago-label { font-weight: 800; font-size: 0.875rem; display: flex; align-items: center; gap: 0.5rem; }
.pago-input-wrapper { position: relative; width: 8.5rem; }
.pago-input-wrapper input { width: 100%; padding: 0.625rem; border: 2px solid var(--borde); background: white; border-radius: var(--radius-md); font-size: 1.125rem; font-weight: 900; box-sizing: border-box; text-align: right; color: var(--texto); transition: border-color 0.2s, box-shadow 0.2s; font-family: 'Nunito', sans-serif;}
.pago-input-wrapper input:focus { border-color: var(--primario); box-shadow: 0 0 0 3px rgba(224, 176, 96, 0.2); outline: none; }
.cat-list-item { display: flex; justify-content: space-between; align-items: center; padding: 0.625rem; border-bottom: 1px solid var(--borde); transition: background 0.2s; border-radius: var(--radius-sm);}
.cat-list-item:hover { background: var(--secundario); }
.cat-actions button { background: none; border: none; cursor: pointer; color: inherit; padding: 0.25rem; margin-left: 0.5rem; transition: transform var(--transition-bounce); }
.cat-actions button:hover { transform: scale(1.15); }

/* --- LOGIN --- */
#login-overlay { background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--sidebar-hover) 100%); }
.login-box-modern { background: var(--sidebar-bg); padding: 2.5rem 1.75rem; border-radius: 1.5rem; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.6); width: 90%; max-width: 22rem; text-align: center; border: 1px solid rgba(224,176,96,0.15); color: white;}
.login-logo-img { max-width: 100%; height: 12rem; object-fit: contain; margin-bottom: 0.625rem; filter: drop-shadow(0px 4px 6px rgba(0,0,0,0.4));}
.login-box-modern p.subtitle { color: #c4b9aa; font-size: 0.875rem; margin-bottom: 1.5rem; font-weight: 600;}
.login-input-group { margin-bottom: 1rem; text-align: left; }
.login-input-group label { display: block; font-size: 0.75rem; font-weight: 800; color: #E8D9C7; margin-bottom: 0.375rem; text-transform: uppercase; letter-spacing: 0.05em; }
.login-box-modern input { width: 100%; padding: 0.75rem; border: 2px solid var(--sidebar-hover); border-radius: var(--radius-md); box-sizing: border-box; font-size: 0.9375rem; transition: border-color 0.3s, box-shadow 0.3s; background: #3B3429; color: white; font-weight: 600; font-family: 'Nunito', sans-serif;}
.login-box-modern input:focus { border-color: var(--primario); outline: none; box-shadow: 0 0 0 4px rgba(224, 176, 96, 0.2); }
.login-box-modern .btn-primario { padding: 0.875rem; font-size: 1rem; margin-top: 0.75rem; width: 100%; border:none; box-shadow: 0 4px 15px rgba(224,176,96,0.25); color: var(--texto);}

/* --- TOASTS & ZOOM --- */
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.toast { background: white; border-radius: var(--radius-md); padding: 0.75rem 1rem; box-shadow: var(--shadow-hover); font-size: 0.875rem; font-weight: 800; display: flex; align-items: center; gap: 0.75rem; min-width: 14rem; max-width: 20rem; pointer-events: auto; border-left: 4px solid var(--primario); opacity: 0; transform: translateX(3.125rem); color: var(--texto);}
.toast.toast-error { border-left-color: var(--peligro); }
.toast.toast-warning { border-left-color: #D48B30; }
.toast.toast-info { border-left-color: var(--info); }
.toast-icon { font-size: 1.125rem; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.3; }

/* --- VARIOS Y UTILIDADES --- */
.pos-filters-header { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.pos-search-wrapper { position: relative; width: 18rem; flex-shrink: 0; }
.pos-search-input { width: 100%; padding: 0.625rem 0.75rem 0.625rem 2.25rem; border: 2px solid var(--borde); border-radius: 99px; font-family: 'Nunito', sans-serif; font-size: 0.875rem; font-weight: 800; background: white; color: var(--texto); outline: none; transition: border-color 0.2s, box-shadow 0.2s; box-sizing: border-box; }
.pos-search-input:focus { border-color: var(--primario); box-shadow: 0 0 0 3px rgba(224, 176, 96, 0.2); }
@keyframes spin { 100% { transform: rotate(360deg); } }
.lucide-spinner { animation: spin 1s linear infinite; }
.swal2-container { z-index: 10000 !important; }
.swal2-popup { z-index: 10001 !important; }
.config-tab:focus, .btn:focus { outline: none; }
.config-tab:focus-visible, .btn:focus-visible { outline: 2px solid var(--primario); outline-offset: 2px; }
.pc-inner > div:nth-last-child(2), .desktop-card > div:nth-last-child(2) { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; word-break: break-word; }

/* --- ASISTENTE DE PASTELES --- */
.cake-option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem; margin-top: 0.5rem; }
.cake-opt-btn { background: white; border: 2px solid var(--borde); border-radius: var(--radius-md); padding: 0.75rem; cursor: pointer; text-align: center; transition: all 0.2s; display: flex; flex-direction: column; gap: 0.25rem; }
.cake-opt-btn:hover { border-color: var(--primario); background: var(--secundario); }
.cake-opt-btn.selected { border-color: var(--primario); background: #FFFAF4; box-shadow: 0 0 0 3px rgba(224, 176, 96, 0.2); }
.cake-opt-title { font-weight: 800; font-size: 0.85rem; color: var(--texto); }
.cake-opt-price { font-weight: 900; font-size: 0.9rem; color: var(--primario-hover); }

/* --- SCROLL HORIZONTAL CATEGORÍAS POS --- */
#filtros-categorias { display: flex; flex-wrap: nowrap; gap: 0.5rem; overflow-x: auto; overflow-y: hidden; white-space: nowrap; padding: 0 1rem 0 0; margin-bottom: 0; flex-shrink: 0; min-width: 0; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; align-items: center; }
#filtros-categorias::-webkit-scrollbar { display: none; }
#filtros-categorias::after { content: ""; flex: 0 0 0.75rem; }
.chip-cat { flex: 0 0 auto; min-width: max-content; max-width: none; border-radius: 999px; padding: 0.72rem 1rem; font-size: 0.875rem; font-weight: 900; line-height: 1; scroll-snap-align: start; white-space: nowrap; }
.chip-cat.btn-outline { background: white; border: 2px solid var(--borde); color: var(--texto); }
.chip-cat.btn-outline:hover { background: var(--secundario); border-color: var(--primario); }
.chip-cat.btn-primario { background: var(--primario); color: var(--texto); border: 2px solid transparent; }

/* ========================================= */
/* --- DASHBOARD Y GRÁFICAS --- */
/* ========================================= */
.summary-box { background: var(--secundario); padding: 0.75rem 1rem; border-radius: var(--radius-md); display: flex; flex-direction: column; min-width: 6.25rem; flex: 1; border: 1px solid var(--borde); }
.summary-label { font-size: 0.75rem; color: var(--texto-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em;}
.summary-value { font-size: 1.25rem; font-weight: 900; color: var(--texto);}
.val-efectivo { color: #8A653B; }
.val-gasto { color: var(--peligro); }
.val-total { color: var(--texto); }

/* --- TARJETAS KPI COMPACTAS, CENTRADAS Y ESTILIZADAS --- */
.dash-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
    width: 100% !important;
}
.dash-kpi-card {
    background: white !important;
    border: 2px solid var(--borde) !important;
    border-radius: var(--radius-md) !important;
    padding: 0.75rem 0.875rem !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    text-align: left !important;
    gap: 0.5rem !important;
    box-shadow: var(--shadow-base) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    min-height: 6.5rem !important;
    box-sizing: border-box !important;
    position: relative;
    overflow: hidden;
    min-width: 0 !important;
    border-left: 5px solid var(--borde) !important;
}
.dash-kpi-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: var(--shadow-hover) !important;
}

/* Temas de bordes y fondos premium */
.dash-kpi-card.kpi-ingresos { border-left-color: #788562 !important; background: linear-gradient(135deg, #ffffff 0%, #f4f6f3 100%) !important; }
.dash-kpi-card.kpi-gastos { border-left-color: var(--peligro) !important; background: linear-gradient(135deg, #ffffff 0%, #fdf5f5 100%) !important; }
.dash-kpi-card.kpi-utilidad { border-left-color: var(--primario) !important; background: linear-gradient(135deg, #ffffff 0%, #fffbf4 100%) !important; }
.dash-kpi-card.kpi-promedio { border-left-color: #907050 !important; }
.dash-kpi-card.kpi-txs { border-left-color: #a8a096 !important; }
.dash-kpi-card.kpi-efectivo { border-left-color: #8A653B !important; }
.dash-kpi-card.kpi-transferencias { border-left-color: var(--info) !important; }

.dash-kpi-header {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    width: 100% !important;
}
.dash-kpi-icon-pill {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 1.75rem !important;
    height: 1.75rem !important;
    border-radius: 50% !important;
    background: var(--secundario) !important;
    color: var(--texto-muted) !important;
    flex-shrink: 0 !important;
}
.kpi-ingresos .dash-kpi-icon-pill { background: rgba(120, 133, 98, 0.15) !important; color: #788562 !important; }
.kpi-gastos .dash-kpi-icon-pill { background: rgba(201, 79, 79, 0.15) !important; color: var(--peligro) !important; }
.kpi-utilidad .dash-kpi-icon-pill { background: rgba(224, 176, 96, 0.18) !important; color: var(--primario-hover) !important; }

.dash-kpi-title {
    font-size: 0.72rem !important;
    font-weight: 800 !important;
    color: var(--texto-muted) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
}
.dash-kpi-value {
    font-size: 1.35rem !important;
    font-weight: 900 !important;
    color: var(--texto) !important;
    line-height: 1.1 !important;
    margin: 0 !important;
    word-break: break-all;
}
.badge-kpi-sub {
    font-size: 0.65rem !important;
    font-weight: 800 !important;
    padding: 0.15rem 0.45rem !important;
    border-radius: 99px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.02em !important;
    background: var(--secundario) !important;
    color: var(--texto-muted) !important;
    display: inline-block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
.kpi-ingresos .badge-kpi-sub { background: rgba(120, 133, 98, 0.1) !important; color: #788562 !important; }
.kpi-gastos .badge-kpi-sub { background: rgba(201, 79, 79, 0.1) !important; color: var(--peligro) !important; }
.kpi-utilidad .badge-kpi-sub { background: rgba(224, 176, 96, 0.15) !important; color: var(--primario-hover) !important; }

#contenedor-dashboard-avanzado {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 1.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}
#contenedor-dashboard-avanzado .dash-chart-card {
    width: calc(50% - 0.75rem) !important;
    box-sizing: border-box !important;
}
#dash-kpi-grid {
    width: 100% !important;
}
.dash-chart-card { background: white; border: 2px solid var(--borde); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-base); display: flex; flex-direction: column; }
.dash-chart-card-doughnut {
    max-width: 400px !important;
    width: 100% !important;
    margin: 0 auto !important;
}
.dash-chart-title { font-weight: 900; font-size: 1.1rem; color: var(--texto); margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--secundario); }
.dash-chart-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 250px; /* Altura por defecto en PC */
}
.dash-list-container { display: flex; flex-direction: column; gap: 0; }
.dash-list-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px dashed var(--borde); }
.dash-list-item:last-child { border-bottom: none; }
.dash-item-name { font-weight: 800; font-size: 0.9rem; color: var(--texto); }
.dash-item-val { font-weight: 900; color: var(--texto); font-size: 1rem; }
.dash-progress-wrapper { background: var(--secundario); border-radius: 99px; height: 1.25rem; width: 100%; overflow: hidden; border: 1px solid var(--borde); position: relative; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); }
.dash-progress-fill { background: linear-gradient(90deg, var(--primario), #b88a44); height: 100%; width: 0%; transition: width 1s cubic-bezier(0.16, 1, 0.3, 1); }
.dash-progress-text { position: absolute; width: 100%; text-align: center; top: 0; line-height: 1.25rem; font-size: 0.75rem; font-weight: 900; color: white; mix-blend-mode: difference; }


/* ========================================= */
/* --- POS Y MÓVIL GENERAL (<= 768px) ---    */
/* ========================================= */
@media (max-width: 768px) {
    :root {
        --fab-size: 2.25rem;      
        --fab-font: 1.35rem;
        --qty-width: 2.2rem;
        --qty-font: 1.25rem;
        --fab-gap: 0.35rem;
        --fab-offset-y: 1.05rem; 
        --card-bottom-space: 1.6rem; 
    }

    .sidebar-ticket { display: none !important; }
    #pos-grid { padding-bottom: 6rem !important; }
    .grid-productos { grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-width, 5.6rem)), 1fr)); gap: 0.5rem; }
    
    .pcw { position: relative; display: flex; flex-direction: column; border-radius: var(--radius-lg); overflow: visible !important; min-width: 0; }
    .pcw.activo { padding-bottom: var(--card-bottom-space); }
    .pc-inner { background: #fff; border: 2px solid var(--borde); padding: var(--card-pad, 0.5rem); border-radius: var(--radius-lg); cursor: pointer; text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: var(--pc-card-min-h, 5rem); min-width: 0; position: relative; z-index: 1; transition: border-color var(--transition-bounce), transform var(--transition-bounce), box-shadow var(--transition-bounce), background-color 0.2s; }
    .pc-inner:active { transform: scale(0.96); }
    .pcw.activo .pc-inner { border-color: var(--primario) !important; box-shadow: 0 4px 12px rgba(224, 176, 96, 0.15); background: #FFFAF4; }
    .pc-badge { position: absolute; top: -8px; right: -8px; background: var(--texto); color: var(--primario); border-radius: 999px; min-width: 24px; height: 24px; padding: 0 6px; font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(48,48,32,0.25); z-index: 5; pointer-events: none; transform: scale(0); transition: transform var(--transition-bounce); }
    .pcw.activo .pc-badge { transform: scale(1); }
    .pc-stepper-float { position: absolute; left: 0; right: 0; bottom: calc(var(--fab-offset-y) * -1); height: calc(var(--fab-size) + 0.2rem); pointer-events: none; z-index: 4; opacity: 0; transform: translateY(-10px); transition: opacity var(--transition-bounce), transform var(--transition-bounce); }
    .pcw.activo .pc-stepper-float { opacity: 1; pointer-events: auto; transform: translateY(0); }
    .pc-fab-btn { position: absolute; bottom: 0; width: var(--fab-size); height: var(--fab-size); border-radius: 999px; border: none; display: flex; align-items: center; justify-content: center; font-weight: 900; line-height: 1; cursor: pointer; box-shadow: 0 4px 12px rgba(48,48,32,0.15); -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: transform var(--transition-bounce), background 0.15s; }
    .pc-fab-btn:active { transform: scale(0.85); }
    .pc-fab-btn.menos { left: calc(50% - (var(--qty-width) / 2) - var(--fab-gap) - var(--fab-size)); background: white; color: var(--texto); border: 2px solid var(--borde); font-size: calc(var(--fab-font) - 0.05rem); }
    .pc-fab-btn.mas { left: calc(50% + (var(--qty-width) / 2) + var(--fab-gap)); background: var(--primario); color: var(--texto); font-size: var(--fab-font); }
    .pc-fab-qty { position: absolute; left: 50%; bottom: 0.1rem; transform: translateX(-50%); width: var(--qty-width); height: var(--fab-size); border: 2px solid transparent; background: white; border-radius: var(--radius-sm); text-align: center; font-size: var(--qty-font); font-weight: 900; color: var(--texto); font-family: Nunito, sans-serif; outline: none; padding: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.05); transition: border-color 0.2s, box-shadow 0.2s; }
    .pc-fab-qty:focus { border-color: var(--primario); box-shadow: 0 0 0 3px rgba(224, 176, 96, 0.2); }
    .pc-fab-qty::-webkit-inner-spin-button, .pc-fab-qty::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

    #barra-cobrar-movil { position: fixed; bottom: 56px; left: 0; right: 0; z-index: 1800; background: white; border-top: 2px solid var(--borde); padding: 12px 20px; display: flex; align-items: center; gap: 12px; box-shadow: 0 -10px 25px rgba(48,48,32,0.1); transform: translateY(120%); transition: transform 0.3s cubic-bezier(0.16,1,0.3,1); }
    #barra-cobrar-movil.visible { transform: translateY(0); }
    #bcm-label { font-size: 0.8125rem; color: var(--texto-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
    #bcm-total { font-size: 1.5rem; font-weight: 900; color: var(--texto); flex: 1; }
    #bcm-btn { background: var(--primario); color: var(--texto); border: none; border-radius: var(--radius-md); padding: 0.875rem 1.75rem; font-size: 1.0625rem; font-weight: 900; cursor: pointer; transition: transform var(--transition-bounce), background 0.15s, box-shadow 0.15s; box-shadow: 0 4px 12px rgba(224,176,96,0.35); }
    #bcm-btn:active { background: var(--primario-hover); transform: scale(0.95); box-shadow: none;}
}
@media (min-width: 769px) { #barra-cobrar-movil { display: none !important; } }
@media (max-width: 64rem) { .pos-layout { flex-direction: column; } .sidebar-ticket { width: 100%; height: auto; flex: none; } }


/* ========================================= */
/* --- AJUSTES Y TABLAS MÓVILES (<= 48rem) --- */
/* ========================================= */
@media (max-width: 48rem) {
    html, body { height: 100dvh; overflow: hidden; }
    .view-section, .view-section.gsap-transitioning { padding: 0.5rem; }
    .view-title { font-size: 1.1rem !important; }
    .view-subtitle { display: none !important; }

    /* Barra Inferior Celular */
    .sidebar-main { position: fixed; bottom: 0; left: 0; width: 100%; height: 56px; flex-direction: row; box-shadow: 0 -4px 15px rgba(48,48,32,0.15); overflow: hidden; }
    .sidebar-brand, .sidebar-footer { display: none; }
    .sidebar-menu { flex-direction: row; width: 100%; justify-content: space-around; padding: 0; overflow-y: hidden; overflow-x: auto; scrollbar-width: none; gap: 0; }
    .nav-tab { flex: 1; flex-direction: column; padding: 6px 2px; font-size: 10px; justify-content: center; border-radius: 0; margin: 0; border-top: 3px solid transparent; gap: 3px; text-align: center; min-width: 0; }
    .nav-label { display: none; }
    .nav-tab i, .nav-tab svg { width: 1.5rem; height: 1.5rem; }
    .nav-tab.active { border-top-color: var(--primario); background: linear-gradient(180deg, rgba(224, 176, 96, 0.15) 0%, rgba(224, 176, 96, 0) 100%); transform: translateY(-2px) !important; }
    .nav-tab.active .nav-label { display: block; font-size: 0.6rem; margin-top: 0.1rem; color: var(--primario); }

    .content-area { height: calc(100dvh - 56px); max-height: calc(100dvh - 56px); padding-bottom: 0; overflow: hidden; min-height: 0; }
    .view-section.active { flex: 1 1 0; }

    /* POS / Config: scroll interno en hijos (Historial se pasa a scroll de sección en móvil) */
    #view-pos, #view-config { overflow: hidden; }
    #view-pos .pos-layout { flex: 1; min-height: 0; height: auto; }
    #view-pos .pos-layout > div:first-child { min-height: 0; }

    /*
     * Gastos, Surtido e Historial: UN solo scroll en la pestaña (evita flex anidado que en iOS/Android
     * expande el contenedor en lugar de activar overflow).
     */
    #view-gastos.view-section.active,
    #view-surtido.view-section.active,
    #view-historial.view-section.active {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
    }
    #view-gastos .table-wrapper,
    #view-surtido .table-wrapper,
    #view-historial .table-wrapper {
        flex: none;
        height: auto;
        min-height: auto;
        overflow: visible;
    }
    #view-gastos .view-header,
    #view-surtido .view-header,
    #view-historial .view-header {
        flex-shrink: 0;
    }
    #gastos-cards-mobile,
    #surtido-cards-mobile,
    #historial-cards-mobile {
        overflow: hidden;
        flex-shrink: 0;
    }

    /* Dashboard en Móvil: scroll vertical a una sola columna */
    #contenedor-dashboard-avanzado {
        flex-direction: column !important;
        gap: 1.25rem !important;
    }
    #contenedor-dashboard-avanzado .dash-chart-card {
        width: 100% !important;
    }
    
    .view-header { padding: 0.75rem !important; gap: 0.5rem !important; margin-bottom: 0 !important; flex-direction: column; align-items: stretch; position: sticky; top: 0; z-index: 50; }
    .view-header .btn { width: auto; min-width: 0; flex: 0 1 auto; }
    
    .pos-search-wrapper { width: 100% !important; margin-bottom: 0.5rem; }
    .pos-filters-header { flex-direction: column; align-items: stretch; margin-bottom: 0.5rem; }

    /* Pestañas / Segmented Control Móvil */
    .sub-tab-container { margin-top: 0.25rem !important; }
    .sub-tab-container .sub-tab i, .sub-tab-container .sub-tab svg { width: 0.85rem; height: 0.85rem; flex-shrink: 0; }

    /* Filtros compactos en una línea */
    #view-historial .view-header > div:last-child { flex-direction: row !important; align-items: center !important; flex-wrap: nowrap !important; gap: 0.5rem; }
    .input-filtro { padding: 0.35rem 0.5rem !important; font-size: 0.75rem !important; height: auto !important; max-width: 100%; box-sizing: border-box; }

    /* Forzar la visibilidad de tablas elegantes (Opción B) y matar el límite de PC */
    .table-container { display: block !important; overflow-x: auto !important; }
    .mobile-cards { display: none !important; }
    table { table-layout: fixed !important; width: 100% !important; min-width: 0 !important; }
    th, td { white-space: normal !important; overflow-wrap: break-word !important; word-wrap: break-word !important; padding: 0.6rem 0.25rem !important; font-size: 0.75rem !important; text-align: center !important; vertical-align: middle !important; }
    
    /* Configuración de anchos porcentuales para tablas móviles */
    #view-historial th:nth-child(1), #historial-tabla td:nth-child(1) { width: 22% !important; text-align: left !important; }
    #view-historial th:nth-child(2), #historial-tabla td:nth-child(2) { width: 33% !important; text-align: center !important;}
    #view-historial th:nth-child(5), #historial-tabla td:nth-child(5) { width: 25% !important; text-align: right !important; }
    #view-historial th:nth-child(6), #historial-tabla td:nth-child(6) { width: 20% !important; text-align: center !important;}

    #view-historial #contenedor-listas-historial .table-container { display: none !important; }
    #historial-cards-mobile { display: block !important; width: 100%; box-sizing: border-box; margin-top: 0; }

    /* FIX: Eliminar el espacio a la derecha en paneles para que la tabla use el 100% real */
    .config-panel { padding-right: 0 !important; }
    .table-wrapper { padding-right: 0 !important; }

    #view-surtido th:nth-child(1), #surtido-tabla td:nth-child(1) { width: 70% !important; text-align: left !important; }
    #view-surtido th:nth-child(3), #surtido-tabla td:nth-child(3) { width: 30% !important; text-align: right !important; }

    #config-productos th:nth-child(1), #tabla-productos td:nth-child(1),
    #config-usuarios th:nth-child(1), #tabla-usuarios td:nth-child(1) { width: 45% !important; text-align: left !important; }
    
    #config-productos th:nth-child(2), #tabla-productos td:nth-child(2) { width: 30% !important; text-align: center !important;}
    #config-usuarios th:nth-child(2), #tabla-usuarios td:nth-child(2) { width: 35% !important; text-align: left !important;}
    
    #config-productos th:nth-child(3), #tabla-productos td:nth-child(3) { width: 25% !important; text-align: right !important; }
    #config-usuarios th:nth-child(3), #tabla-usuarios td:nth-child(3) { width: 20% !important; text-align: right !important; }

    #tabla-cake-tamanos th:nth-child(1), #tabla-cake-tamanos td:nth-child(1) { width: 50% !important; text-align: left !important; }
    #tabla-cake-tamanos th:nth-child(2), #tabla-cake-tamanos td:nth-child(2) { width: 25% !important; text-align: right !important; }
    #tabla-cake-tamanos th:nth-child(3), #tabla-cake-tamanos td:nth-child(3) { width: 25% !important; text-align: right !important; }
    
    #tabla-cake-panes th:nth-child(1), #tabla-cake-panes td:nth-child(1),
    #tabla-cake-rellenos th:nth-child(1), #tabla-cake-rellenos td:nth-child(1) { width: 75% !important; text-align: left !important; }
    
    #tabla-cake-panes th:nth-child(2), #tabla-cake-panes td:nth-child(2),
    #tabla-cake-rellenos th:nth-child(2), #tabla-cake-rellenos td:nth-child(2) { width: 25% !important; text-align: right !important; }

    .hide-mobile { display: none !important; }

    /* Barra lateral de Configuración */
    #view-config { overflow: hidden; }
    .config-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 0.25rem; height: 100%; min-height: 0; overflow: hidden; }
    .config-sidebar { display: flex; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scroll-snap-type: x proximity; scrollbar-width: none; align-items: center; background: transparent; border: none; box-shadow: none; padding: 0 1rem 0 0; gap: 0.5rem; height: 3.5rem; }
    .config-sidebar::-webkit-scrollbar { display: none; }
    .config-sidebar::after { content: ""; flex: 0 0 0.75rem; }
    .config-tab { flex: 0 0 auto; width: auto; min-width: max-content; scroll-snap-align: start; justify-content: center; padding: 0 1rem; height: 2.75rem; font-size: 0.8125rem; background: white; border-radius: var(--radius-md); box-sizing: border-box; margin: 0; border: 2px solid var(--borde); transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; transform: none !important; }
    .config-tab.active { border-color: var(--primario); background: rgba(224, 176, 96, 0.12); color: var(--primario-hover); }
    .config-content { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }
    .config-panel { min-height: 0; }
    /* GASTOS MOBILE COMPACTO (3 COLUMNAS x 2 FILAS) */
    #view-gastos .table-container { display: none !important; } /* Ocultamos la tabla fea de PC en el celular */
    #gastos-cards-mobile { display: block !important; width: 100%; box-sizing: border-box; border: 2px solid var(--borde); border-radius: var(--radius-lg); background: white; overflow: hidden; box-shadow: var(--shadow-base); }
    .gasto-mobile-header { display: grid; grid-template-columns: 1fr 1.5fr 1fr; background: var(--secundario); padding: 0.6rem 0.25rem; text-align: center; font-size: 0.7rem; font-weight: 900; color: var(--texto-muted); text-transform: uppercase; border-bottom: 2px solid var(--borde); }
    .gasto-mobile-body { display: flex; flex-direction: column; }
    .gasto-mobile-row { display: grid; grid-template-columns: 1fr 1.5fr 1fr; grid-template-rows: auto auto; padding: 0.6rem 0.25rem; border-bottom: 1px solid var(--borde); text-align: center; align-items: center; gap: 0.25rem; user-select: none; transition: background 0.2s; -webkit-tap-highlight-color: transparent;}
    .gasto-mobile-row:active { background: rgba(224, 176, 96, 0.15); }
    .gasto-mobile-row:last-child { border-bottom: none; }
    
    .g-col-main { font-size: 0.85rem; color: var(--texto); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height:1.2;}
    .g-col-sub { font-size: 0.65rem; padding-top: 0.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height:1.2;}
    
    .gasto-mobile-row .text-muted { color: #A0988C; font-weight: 700; }
    .gasto-mobile-row .concepto { font-size: 0.6rem; color: #B3AAA0; }
    .gasto-mobile-row .monto { font-size: 0.95rem; }
    
    .badge-user { background: rgba(224, 176, 96, 0.2); color: #8A653B; padding: 0.15rem 0.45rem; border-radius: 99px; font-weight: 900; letter-spacing: 0.03em;}
    
    .gasto-cancelado,
    .gasto-mobile-row.gasto-cancelado { background: var(--cancelado) !important; opacity: 0.7; }
    .gasto-cancelado .g-col-main,
    .gasto-cancelado .g-col-sub,
    .gasto-cancelado .g-col-monto { text-decoration: line-through; color: var(--peligro) !important; }
    .gasto-cancelado .badge-user { background: rgba(201, 79, 79, 0.15); color: var(--peligro); text-decoration: line-through; }

    /* INSUMOS MOBILE COMPACTO (2 COLUMNAS x 2 FILAS) */
    #view-surtido .table-container { display: none !important; } /* Ocultamos la tabla de PC en el celular */
    #surtido-cards-mobile { display: block !important; width: 100%; box-sizing: border-box; border: 2px solid var(--borde); border-radius: var(--radius-lg); background: white; overflow: visible; box-shadow: var(--shadow-base); margin-top: 0.5rem; }
    
    .insumo-mobile-header { display: grid; grid-template-columns: 1fr 1fr; background: var(--secundario); padding: 0.6rem 0.75rem; font-size: 0.7rem; font-weight: 900; color: var(--texto-muted); text-transform: uppercase; border-bottom: 2px solid var(--borde); }
    .insumo-mobile-body { display: flex; flex-direction: column; }
    .insumo-mobile-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        padding: 0.75rem;
        border-bottom: 1px solid var(--borde);
        align-items: center;
        gap: 0.35rem 0.5rem;
        user-select: none;
        transition: background 0.2s;
        -webkit-tap-highlight-color: transparent;
    }
    .insumo-mobile-row:active { background: rgba(224, 176, 96, 0.15); }
    .insumo-mobile-row:last-child { border-bottom: none; }

    .insumo-mobile-nombre {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
        text-align: left;
        font-weight: 900;
        font-size: 0.95rem;
    }
    .insumo-stock-badge {
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
        text-align: center;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .insumo-stock-badge:active { transform: scale(0.95); }
    .insumo-mobile-proveedor {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
        text-align: left;
    }
    .insumo-mobile-minmax {
        grid-column: 2;
        grid-row: 2;
        justify-self: center;
        text-align: center;
    }
    
    .i-col-main { font-size: 0.85rem; color: var(--texto); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; max-width: 100%; }
    .i-col-sub { font-size: 0.7rem; padding-top: 0.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
    
    .insumo-mobile-row .text-muted { color: #A0988C; font-weight: 800; font-size: 0.65rem; }
    
    /* Stock crítico (rojo pastel) */
    .insumo-rojo { background: #FBE4E4 !important; }
    .insumo-rojo .insumo-mobile-nombre { color: #A03D3D; }
    .insumo-rojo .insumo-stock-badge { background: #E8B4B4; color: #A03D3D; }
}

@media (max-width: 360px) {
    .chip-cat { padding: 0.65rem 0.85rem; font-size: 0.78rem; }
    .config-tab { font-size: 0.75rem; padding: 0 0.75rem; gap: 0.375rem; }

    #toast-container { top: 0.75rem; right: 0.75rem; left: 0.75rem; align-items: center; }
    .toast { min-width: unset; width: 100%; max-width: 100%; font-size: 0.8125rem; }
}

.badge-cantidad { 
    background: var(--primario); 
    color: var(--texto); 
    padding: 0.2rem 0.6rem; 
    border-radius: 99px; 
    font-weight: 900; 
    font-size: 0.8rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* --- CABECERA DE SURTIDO EN CUADRÍCULA COMPACTA Y FIJA (MÓVIL / ESCRITORIO) --- */
.surtido-header-grid {
    display: grid !important;
    grid-template-columns: 1fr auto auto auto !important;
    align-items: center !important;
    gap: 0.75rem !important;
    background: white !important;
    border: 2px solid var(--borde) !important;
    border-radius: var(--radius-lg) !important;
    padding: 1rem !important;
    box-shadow: var(--shadow-base) !important;
    margin-bottom: 0.75rem !important;
}

.surtido-header-grid .surtido-header-title {
    grid-column: 1;
}

.surtido-header-grid .header-btn-whatsapp {
    grid-column: 2;
}

.surtido-header-grid .header-btn-sams {
    grid-column: 3;
}

.surtido-header-grid .header-btn-add {
    grid-column: 4;
}

/* Optimización móvil */
@media (max-width: 48rem) {
    #view-surtido.view-section.active {
        overflow-y: auto !important; /* Habilitamos el scroll nativo dentro de la sección */
    }

    .surtido-header-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto !important;
        gap: 0.5rem !important;
        padding: 0.625rem !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important; /* Redondeado solo inferior en móvil */
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        box-shadow: 0 4px 12px rgba(48,48,32,0.08) !important;
        margin-bottom: 0.5rem !important;
    }

    /* Distribución en cuadrícula de 2x2 */
    .surtido-header-grid .surtido-header-title {
        grid-column: 1 / 2 !important;
        grid-row: 1 / 2 !important;
        align-self: center !important;
    }

    .surtido-header-grid .header-btn-sams {
        grid-column: 2 / 3 !important;
        grid-row: 1 / 2 !important;
        width: 100% !important;
    }

    .surtido-header-grid .header-btn-whatsapp {
        grid-column: 1 / 2 !important;
        grid-row: 2 / 3 !important;
        width: 100% !important;
    }

    .surtido-header-grid .header-btn-add {
        grid-column: 2 / 3 !important;
        grid-row: 2 / 3 !important;
        width: 100% !important;
    }

    /* Reducción de altura y simplificación visual */
    .surtido-header-grid .view-subtitle {
        display: none !important; /* Ocultamos el subtítulo en móvil para ganar altura útil */
    }

    .surtido-header-grid .view-title {
        font-size: 0.95rem !important;
        font-weight: 900 !important;
        margin: 0 !important;
        text-align: left !important;
        line-height: 1.2 !important;
    }

    /* Botones de cabecera más densos y compactos en móvil */
    .surtido-header-grid .btn {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.25rem !important;
        height: 2.1rem !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.25rem !important;
        margin: 0 !important;
        width: 100% !important;
        box-shadow: none !important;
    }
    
    .surtido-header-grid .btn i, 
    .surtido-header-grid .btn svg {
        width: 0.85rem !important;
        height: 0.85rem !important;
    }
}

/* --- REDISEÑO COMPACTO Y SLIDER DE CABECERA DE HISTORIAL --- */
.historial-header-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    padding: 0.875rem !important;
    background: white !important;
    border: 2px solid var(--borde) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-base) !important;
    margin-bottom: 1rem !important;
}

.historial-header-top {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
}

.historial-title-block {
    display: flex !important;
    flex-direction: column !important;
    text-align: left !important;
}

.historial-filter-block {
    display: flex !important;
    align-items: center !important;
    gap: 0.375rem !important;
    flex-wrap: wrap !important;
}

.historial-filter-block .filter-label {
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--texto);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.historial-header-bottom {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
    border-top: 1px solid var(--secundario) !important;
    padding-top: 0.5rem !important;
}

/* --- SEGMENTED CONTROL ESTILO TELEGRAM --- */
.sub-tab-container {
    position: relative !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    background: var(--secundario) !important;
    border-radius: 99px !important;
    padding: 0.25rem !important;
    border: 1px solid var(--borde) !important;
    width: 100% !important;
    max-width: 380px !important;
    margin: 0 auto !important;
    z-index: 1 !important;
    box-sizing: border-box !important;
}
.sub-tab-slider-bg {
    position: absolute !important;
    top: 0.25rem !important;
    bottom: 0.25rem !important;
    left: 0.25rem !important;
    width: calc((100% - 0.5rem) / 3) !important;
    background: white !important;
    border-radius: 99px !important;
    box-shadow: 0 2px 8px rgba(48,48,32,0.1) !important;
    z-index: 0 !important;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1) !important;
    transform: translateX(0) !important;
}
.sub-tab-container[data-active="ventas"] .sub-tab-slider-bg { transform: translateX(0) !important; }
.sub-tab-container[data-active="cotizaciones"] .sub-tab-slider-bg { transform: translateX(100%) !important; }
.sub-tab-container[data-active="dashboard"] .sub-tab-slider-bg { transform: translateX(200%) !important; }

.sub-tab-container[data-active="productos"] .sub-tab-slider-bg { transform: translateX(0) !important; }
.sub-tab-container[data-active="usuarios"] .sub-tab-slider-bg { transform: translateX(100%) !important; }
.sub-tab-container[data-active="pasteleria"] .sub-tab-slider-bg { transform: translateX(200%) !important; }

.sub-tab-container .sub-tab {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.375rem !important;
    padding: 0.5rem 0.25rem !important;
    font-size: 0.85rem !important;
    font-weight: 800 !important;
    color: var(--texto-muted) !important;
    background: transparent !important;
    border: none !important;
    border-radius: 99px !important;
    cursor: pointer !important;
    z-index: 2 !important;
    transition: color 0.3s ease !important;
    -webkit-tap-highlight-color: transparent !important;
    outline: none !important;
}

.sub-tab-container .sub-tab.active {
    color: var(--texto) !important; 
}
.sub-tab-container .sub-tab.active i,
.sub-tab-container .sub-tab.active svg {
    color: var(--primario-hover) !important;
    transform: scale(1.1);
    transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), color 0.2s;
}

/* Ajustes responsivos en Móviles */
@media (max-width: 48rem) {
    /* --- CORRECCIÓN: LIBERAR SCROLL Y APILAR DASHBOARD --- */
    #view-historial.view-section.active {
        display: block !important; 
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: 100% !important;
    }
    #contenedor-dashboard-avanzado {
        flex-direction: column !important; /* Fuerza 1 sola columna en móvil */
        height: auto !important;
        overflow: visible !important;
    }
    #contenedor-dashboard-avanzado .dash-chart-card {
        width: 100% !important; /* Fuerza a que no intente usar el 50% de la PC */
        max-width: 100% !important;
        position: relative !important;
        min-height: auto !important; /* Remove fixed min-height for lists/charts */
        margin: 0 !important;
        padding: 1rem !important;
    }
    .dash-chart-card-doughnut {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
    }
    .dash-chart-canvas-wrapper {
        height: 210px !important; /* Altura perfecta para Chart.js en móvil */
    }
    .dash-kpi-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }
    .dash-kpi-grid .dash-kpi-card {
        min-height: 6rem !important;
        padding: 0.6rem 0.75rem !important;
        border-left-width: 4px !important;
    }
    .dash-kpi-value {
        font-size: 1.15rem !important; /* Evita desbordamiento de números largos */
    }

    .historial-header-grid {
        padding: 0.625rem !important;
        gap: 0.5rem !important;
    }

    .historial-header-top {
        flex-direction: row !important; /* Asegura una sola fila */
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }

    .historial-title-block .view-title {
        font-size: 0.95rem !important;
        font-weight: 900 !important;
        margin: 0 !important;
        line-height: 1.2 !important;
    }

    .historial-title-block .view-subtitle {
        display: none !important; /* Ocultamos subtítulo en móvil para ahorrar espacio */
    }

    .historial-filter-block {
        gap: 0.25rem !important;
    }

    .historial-filter-block .filter-label {
        display: none !important; /* Ocultamos etiqueta "Filtrar:" en móvil */
    }

    .historial-filter-block select.input-filtro,
    .historial-filter-block input.input-filtro {
        font-size: 0.75rem !important;
        padding: 0.35rem 0.5rem !important;
        height: auto !important;
        width: auto !important;
        max-width: 120px !important; /* Evita desbordamientos */
    }

    .sub-tab-container .sub-tab {
        padding: 0.4rem 0.75rem !important; /* Más compactos en pantallas móviles */
        font-size: 0.72rem !important;
    }
    
    .sub-tab-container .sub-tab i,
    .sub-tab-container .sub-tab svg {
        width: 0.8rem !important;
        height: 0.8rem !important;
    }
}