:root {
    --side-bg: #0f172a;
    --side-text: #94a3b8;
    --side-active: #1e293b;
    --accent: #6366f1;
    --page-bg: #f1f5f9;
}
body {
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --bs-body-color: #1e293b;
    background: var(--page-bg); font-size: .95rem; letter-spacing: -.003em;
    -webkit-font-smoothing: antialiased; color-scheme: light;
}
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -.015em; color: #0f172a; }
.text-muted { color: #64748b !important; }

/* ===== Estructura con menú lateral ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar-col { flex: 0 0 auto; }
.sidebar { --bs-offcanvas-bg: var(--side-bg); --bs-offcanvas-width: 260px; color: var(--side-text); width: 260px; }
@media (min-width: 992px) {
    .sidebar-col { width: 250px; background: var(--side-bg); }
    .sidebar { position: sticky; top: 0; height: 100vh; width: 250px; display: flex !important; flex-direction: column; overflow-y: auto; }
}
@media (max-width: 991.98px) { .sidebar-col { display: contents; } }

.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-link { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 600; min-width: 0; }
.brand-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; flex: 0 0 34px; }
.sidebar-nav { padding: .75rem; flex: 1; }
.side-title { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #64748b; padding: .9rem .6rem .3rem; }
.side-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: .55rem; color: var(--side-text); text-decoration: none; margin-bottom: 2px; }
.side-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.side-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.side-link.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { padding: .75rem 1rem; font-size: .72rem; color: #475569; }

.content-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: #fff; border-bottom: 1px solid #e2e8f0; }
@media (min-width: 992px) { .topbar { padding: .7rem 1.75rem; } }
.page-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: .85rem; }
.main-area { padding: 1rem; flex: 1; }
@media (min-width: 992px) { .main-area { padding: 1.5rem 1.75rem; } }

/* ===== Tarjetas y tablas ===== */
.card { border: 0; border-radius: .8rem; box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef2f7; font-weight: 600; border-radius: .8rem .8rem 0 0 !important; }
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; font-weight: 600; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }

.kpi { display: flex; align-items: center; gap: .9rem; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: 0 0 46px; }
.kpi-label { color: #64748b; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.45rem; font-weight: 700; line-height: 1.15; }
.kpi-sub { font-size: .78rem; }
.bg-soft-indigo { background: #e0e7ff; color: #4338ca; }
.bg-soft-green { background: #dcfce7; color: #15803d; }
.bg-soft-amber { background: #fef3c7; color: #b45309; }
.bg-soft-rose { background: #ffe4e6; color: #be123c; }
.bg-soft-sky { background: #e0f2fe; color: #0369a1; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 230px; }
.quick-actions .btn { display: inline-flex; align-items: center; gap: .4rem; }

/* ===== Login ===== */
.auth-bg { background: radial-gradient(circle at 20% 20%, #312e81 0%, #0f172a 60%); }

/* ===== Punto de venta ===== */
.cart-box { max-height: 36vh; overflow-y: auto; }
#camReader { min-height: 240px; }
#results .list-group-item, #custResults .list-group-item { cursor: pointer; }
.qty-btn { width: 32px; padding: 0; }
.cust-wrap { position: relative; }
#custResults { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.ticket { max-width: 340px; font-family: "Courier New", monospace; }

/* ===== Etiquetas ===== */
.labels { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; }
.label { width: 50mm; height: 30mm; border: 1px dashed #bbb; padding: 2mm; text-align: center; background: #fff; overflow: hidden; page-break-inside: avoid; }
.label .l-name { font-size: 9pt; font-weight: 600; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .l-meta { font-size: 8pt; color: #444; }
.label svg { width: 100%; height: 12mm; }
.label .l-price { font-size: 10pt; font-weight: 700; }

@media (max-width: 575.98px) {
    .table { font-size: .88rem; }
    .kpi-value { font-size: 1.2rem; }
    .kpi-icon { width: 40px; height: 40px; flex-basis: 40px; font-size: 1.1rem; }
}

@media print {
    .no-print, .sidebar-col, .topbar, .modal, .alert { display: none !important; }
    body { background: #fff !important; }
    .main-area { padding: 0 !important; }
    .card { box-shadow: none !important; }
    .labels { padding: 0; gap: 0; }
    .label { border: none; outline: 1px dotted #ccc; }
    .ticket { box-shadow: none !important; }
}


/* ===== Formularios ===== */
.form-label { font-weight: 500; font-size: .85rem; color: #334155; margin-bottom: .35rem; }
.form-control, .form-select, .ts-control {
    border: 1px solid #cbd5e1; border-radius: .6rem; min-height: 2.6rem; padding: .5rem .8rem; background-color: #fff; color: #0f172a;
}
.form-control-lg { min-height: 3.1rem; font-size: 1.05rem; }
.form-control::placeholder { color: #94a3b8; }
.form-control:focus, .form-select:focus, .ts-wrapper.focus .ts-control {
    border-color: var(--accent); box-shadow: 0 0 0 .22rem rgba(99,102,241,.18); outline: 0;
}
.form-control[readonly] { background: #f1f5f9; }
.input-group > .form-control:not(:last-child), .input-group > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-radius: .6rem; }
.input-group > .form-control:not(:first-child), .input-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.form-text { color: #64748b; font-size: .78rem; }

.btn { border-radius: .6rem; font-weight: 500; padding: .5rem 1rem; }
.btn-sm { padding: .3rem .65rem; border-radius: .5rem; }
.btn-lg { padding: .7rem 1.2rem; border-radius: .7rem; }
.btn-dark { background: #111827; border-color: #111827; }
.btn-dark:hover { background: #1f2937; border-color: #1f2937; }
.btn:focus-visible { box-shadow: 0 0 0 .22rem rgba(99,102,241,.25); }

/* Validación propia */
.form-control.is-invalid, .form-select.is-invalid { border-color: #ef4444; background-image: none; padding-right: .8rem; }
.form-control.is-invalid:focus { box-shadow: 0 0 0 .22rem rgba(239,68,68,.18); }
.ui-feedback { color: #dc2626; font-size: .8rem; margin-top: .3rem; display: flex; align-items: center; gap: .3rem; }
.ui-feedback::before { content: "\F333"; font-family: bootstrap-icons; font-size: .85rem; }

/* ===== Listas desplegables (Tom Select) ===== */
.ts-wrapper.form-select, .ts-wrapper.single .ts-control { background-image: none; }
.ts-wrapper { width: 100%; }
.ts-wrapper.form-select { padding: 0; border: 0; background: transparent; box-shadow: none; }
.ts-control { display: flex; align-items: center; cursor: pointer; box-shadow: none; }
.ts-wrapper.single .ts-control::after {
    content: ""; border: solid #64748b; border-width: 0 2px 2px 0; padding: 3px; transform: rotate(45deg); margin: -3px 2px 0 .5rem;
    position: static; border-color: #64748b; flex: 0 0 auto;
}
.ts-wrapper.single.dropdown-active .ts-control::after { transform: rotate(-135deg); margin-top: 3px; }
.ts-control .item { flex: 1; }
.ts-dropdown {
    z-index: 2000; border: 1px solid #e2e8f0; border-radius: .75rem; margin-top: .35rem;
    box-shadow: 0 12px 32px rgba(15,23,42,.16); overflow: hidden; background: #fff; font-size: .95rem;
}
.ts-dropdown .ts-dropdown-content { max-height: 280px; padding: .3rem; }
.ts-dropdown .option, .ts-dropdown .no-results { padding: .6rem .8rem; border-radius: .5rem; color: #1e293b; }
.ts-dropdown .option.active { background: #eef2ff; color: #3730a3; }
.ts-dropdown .option.selected { font-weight: 600; }
.ts-dropdown .no-results { color: #64748b; text-align: center; }
.ts-dropdown .dropdown-input { border: 1px solid #cbd5e1; border-radius: .5rem; margin: .3rem; width: calc(100% - .6rem); padding: .45rem .7rem; }
.ts-wrapper.disabled .ts-control { background: #f1f5f9; opacity: 1; }

/* ===== Avisos (toast) ===== */
.ui-toasts { position: fixed; top: 0; right: 0; z-index: 3000; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; width: min(100vw, 400px); pointer-events: none; }
.ui-toast { pointer-events: auto; border: 0; border-radius: .8rem; background: #fff; box-shadow: 0 10px 30px rgba(15,23,42,.18); border-left: 5px solid #6366f1; width: 100%; overflow: hidden; }
.ui-toast-body { display: flex; align-items: flex-start; gap: .7rem; padding: .85rem .9rem; }
.ui-toast-icon { font-size: 1.25rem; line-height: 1.2; }
.ui-toast-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.ui-toast-text strong { font-size: .92rem; color: #0f172a; }
.ui-toast-text span { font-size: .88rem; color: #475569; word-wrap: break-word; }
.ui-toast-success { border-left-color: #22c55e; } .ui-toast-success .ui-toast-icon { color: #22c55e; }
.ui-toast-danger  { border-left-color: #ef4444; } .ui-toast-danger  .ui-toast-icon { color: #ef4444; }
.ui-toast-warning { border-left-color: #f59e0b; } .ui-toast-warning .ui-toast-icon { color: #f59e0b; }
.ui-toast-info    { border-left-color: #0ea5e9; } .ui-toast-info    .ui-toast-icon { color: #0ea5e9; }
@media (max-width: 575.98px) { .ui-toasts { width: 100vw; padding: .75rem; } }

/* ===== Confirmación ===== */
.ui-confirm .modal-content { border: 0; border-radius: 1.1rem; box-shadow: 0 20px 50px rgba(15,23,42,.25); }
.ui-confirm .modal-dialog { max-width: 400px; }
.ui-confirm-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 1rem; font-size: 1.9rem; }
.ui-confirm-icon.is-danger { background: #fee2e2; color: #dc2626; }
.ui-confirm-icon.is-info { background: #e0e7ff; color: #4338ca; }
.ui-confirm-title { font-weight: 700; }
.ui-confirm .btn { min-width: 120px; }
.modal-backdrop.show { opacity: .45; }
.modal-content { border: 0; border-radius: 1rem; }
.modal-header, .modal-footer { border-color: #eef2f7; }

/* ===== Alertas en la página ===== */
.alert { border: 0; border-left: 4px solid; border-radius: .7rem; padding: .8rem 1rem; font-size: .92rem; }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: #ef4444; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #22c55e; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #f59e0b; }
.alert-info { background: #f0f9ff; color: #075985; border-color: #0ea5e9; }

.badge { font-weight: 500; letter-spacing: .01em; }
.table > tbody > tr > td { color: #334155; }
.dropdown-menu { border: 1px solid #e2e8f0; border-radius: .75rem; padding: .35rem; box-shadow: 0 12px 30px rgba(15,23,42,.14); }
.dropdown-item { border-radius: .5rem; padding: .5rem .75rem; }

@media (max-width: 575.98px) {
    /* 16px evita el zoom automático de iPhone al tocar un campo */
    .form-control, .form-select, .ts-control, .ts-control input { font-size: 16px; }
    .ts-dropdown .option { padding: .8rem .9rem; }
    .btn { padding-top: .6rem; padding-bottom: .6rem; }
    .btn-sm { padding-top: .35rem; padding-bottom: .35rem; }
}

/* ===== Importación ===== */
.drop-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center;
    border: 2px dashed #cbd5e1; border-radius: 1rem; padding: 2.2rem 1rem; cursor: pointer; background: #f8fafc; color: #475569; transition: .15s; }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); background: #eef2ff; color: #3730a3; }
.ui-confirm-icon.is-success { background: #dcfce7; color: #16a34a; }
.ui-confirm-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 1.9rem; }

/* ===== Caja (v1.6) ===== */
.cash-hero { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 1.8rem; }
.cash-sum td { padding: .45rem .25rem; }
.count-result { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: .9rem 1rem; }
.count-result strong { font-variant-numeric: tabular-nums; }
