* { box-sizing: border-box; margin: 0; padding: 0; }

@font-face {
    font-family: 'Passione One';
    src: url('/static/fonts/passionone-400.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Jost';
    src: url('/static/fonts/jost-400.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Jost';
    src: url('/static/fonts/jost-600.woff2') format('woff2');
    font-weight: 600;
    font-display: swap;
}
@font-face {
    font-family: 'Jost';
    src: url('/static/fonts/jost-700.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    --yellow: #FCC302;
    --white: #FFFFFF;
    --black: #0C0908;
    --red: #CF141D;
    --gray: #424243;

    --primary: var(--yellow);
    --primary-dark: var(--black);
    --primary-light: #FDF3E3;
    --accent: var(--yellow);
    --bg: var(--white);
    --panel: var(--white);
    --text: var(--black);
    --muted: var(--gray);
    --border: #E5E0DA;
    --green: #2e7d32;
    --dark: var(--black);
    --orange: #b45309;
}

body {
    font-family: 'Jost', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

h1, h2, h3 {
    font-family: 'Passione One', 'Arial Black', sans-serif;
    font-weight: 400;
    letter-spacing: .02em;
}

/* Barra de navegación lateral */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 240px;
    height: 100vh;
    background: linear-gradient(180deg, #2b241c, var(--primary-dark));
    color: #fff;
    border-top: 4px solid var(--primary);
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 14px;
    z-index: 60;
    box-shadow: 2px 0 8px rgba(0,0,0,.2);
    transition: transform .3s ease;
}
.sidebar-toggle {
    margin-left: auto;
    background: rgba(255,255,255,.12); color: #fff; border: none;
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .2s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.28); }

.sidebar-abrir {
    display: none;
    position: fixed; top: 12px; left: 12px; z-index: 55;
    background: var(--primary); color: var(--primary-dark); border: none;
    padding: 8px 12px; border-radius: 8px; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
@media (min-width: 901px) {
    .sidebar-toggle { display: inline-flex; }
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); box-shadow: none; }
    body.sidebar-collapsed main { margin-left: 0; }
    body.sidebar-collapsed .sidebar-abrir { display: inline-flex; }
}
@media (max-width: 900px) {
    .sidebar-toggle, .sidebar-abrir { display: none; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand .logo-img { width: 46px; height: 46px; object-fit: contain; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; }
.brand h1 { font-size: 20px; line-height: 1.1; }
.subtitle { font-size: 12px; opacity: .85; display: block; }

.menu {
    display: flex; flex-direction: column; gap: 6px;
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
}
.menu-group { display: flex; flex-direction: column; gap: 2px; }
.menu-grupo {
    margin: 12px 0 2px; padding: 0 14px;
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: rgba(255, 255, 255, .55); font-weight: 700;
}
.menu-group + .menu-grupo, .menu > .menu-grupo { margin-top: 12px; }
.menu-btn {
    background: transparent; color: #fff; border: none;
    padding: 11px 14px; border-radius: 10px; cursor: pointer; font-size: 14px;
    text-align: left; transition: background .2s;
    display: flex; align-items: center; gap: 10px;
}
.menu-btn svg { flex-shrink: 0; }
.menu-btn:hover { background: rgba(255,255,255,.15); }
.menu-btn.active { background: var(--accent); color: var(--primary-dark); font-weight: 700; }

main { max-width: 1200px; margin: 0 auto; padding: 20px; margin-left: 240px; }

.hamburger {
    display: none;
    position: fixed; top: 12px; left: 12px; z-index: 80;
    background: var(--primary); color: var(--primary-dark); border: none;
    padding: 8px 12px; border-radius: 8px; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.sidebar-overlay { display: none; }

.salir-top {
    display: inline-flex;
    position: fixed; top: 12px; right: 12px; z-index: 80;
    background: var(--red); color: #fff; border: none;
    padding: 8px 14px; border-radius: 8px; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    font-size: 14px; font-weight: 600; align-items: center; gap: 6px;
}
@media (min-width: 901px) { .salir-top { display: none !important; } }

.view { display: none; }
.view.active { display: block; }

/* Tarjetas */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
    background: var(--panel); border-radius: 12px; padding: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08); border-top: 4px solid var(--primary);
}
.card h3 { font-size: 13px; color: var(--muted); font-weight: 600; }
.card p { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--primary-dark); }

/* ===== Dashboard ===== */
.dash-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.dash-head h1 { font-size: 26px; color: var(--primary-dark); }
.dash-welcome { color: var(--muted); font-size: 14px; margin-top: 2px; text-transform: capitalize; }
.dash-date { font-size: 13px; color: var(--muted); background: #fff; padding: 8px 14px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }

.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px; margin-bottom: 20px;
}
.kpi {
    display: flex; align-items: center; gap: 14px;
    background: var(--panel); border-radius: 14px; padding: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    border-left: 4px solid var(--primary);
}
.kpi-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.kpi-info { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--primary-dark); line-height: 1.2; }

.kpi-yellow .kpi-icon { background: var(--primary); color: var(--primary-dark); }
.kpi-dark .kpi-icon { background: var(--primary-dark); color: var(--primary); }
.kpi-red .kpi-icon { background: #fdecea; color: var(--red); }
.kpi-green .kpi-icon { background: #e8f5e9; color: var(--green); }

.dash-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .dash-charts { grid-template-columns: 1fr; } .dash-charts > *, .dash-cols > *, .grid-2 > * { min-width: 0; } }
.chart-box { min-height: 180px; overflow-x: auto; }
.chart-box svg { width: 100%; height: auto; display: block; }
.chart-axis { font-size: 11px; fill: #8a8a8a; }
.chart-val { font-size: 10px; fill: #555; }
.chart-leyenda { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.chart-leyenda .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-leyenda .lg::before { content: ''; width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-yellow::before { background: var(--yellow); }
.lg-red::before { background: var(--red); }

.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.hbar-label { width: 34%; font-size: 13px; color: var(--primary-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { flex: 1; height: 18px; background: #f1f1ee; border-radius: 6px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; min-width: 4px; }
.hbar-value { width: 72px; text-align: right; font-size: 13px; font-weight: 700; color: var(--primary-dark); }

.dash-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 900px) { .dash-cols { grid-template-columns: 1fr; } }

.alerts-list { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; }
.alerta {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
}
.alerta-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alerta-info strong { font-size: 14px; }
.alerta-info span { font-size: 12px; color: var(--muted); }
.alerta-bajo { background: #fff8e1; border-color: #f2df8f; }
.alerta-bajo strong { color: #8a6d00; }
.alerta-vencer { background: #fdecea; border-color: #f0b8b8; }
.alerta-vencer strong { color: var(--red); }

.badge-alerta {
    background: #dc2626; color: #fff; font-size: 11px; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto; animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

.notif-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
    background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff;
    padding: 16px 24px; display: flex; align-items: center; gap: 14px;
    box-shadow: 0 4px 20px rgba(220,38,38,.4); animation: slideDown .3s ease;
}
.notif-banner-icon { font-size: 28px; flex-shrink: 0; font-weight: 700; }
.notif-banner-text { flex: 1; }
.notif-banner-text strong { display: block; font-size: 18px !important; margin-bottom: 2px; font-weight: 700; }
.notif-banner-text span { font-size: 16px !important; opacity: .95; }
.notif-banner-close {
    background: none; border: none; color: #fff; font-size: 22px;
    cursor: pointer; padding: 0 8px; opacity: .8;
}
.notif-banner-close:hover { opacity: 1; }
@media (max-width: 900px) {
    .notif-banner { top: 60px; padding: 12px 16px; }
    .notif-banner-text strong { font-size: 15px !important; }
    .notif-banner-text span { font-size: 13px !important; }
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* Tarjetas genéricas (compatibilidad) */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
    background: var(--panel); border-radius: 12px; padding: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08); margin-bottom: 16px;
}
.panel h2 { font-size: 16px; margin-bottom: 12px; }

/* Tablas */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    text-align: left; padding: 8px 10px; background: #faf7f4; color: var(--muted);
    font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #fdf9f5; }

/* Scroll horizontal de tablas (móvil) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; scrollbar-width: thin; }
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: #d8c6a0; border-radius: 3px; }
@media (max-width: 900px) { .data-table { white-space: nowrap; } }

/* Botones */
.btn {
    padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
    background: #fff; cursor: pointer; font-size: 14px; transition: filter .15s;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-dark); }
.btn-primary:hover { background: #e6b100; }
.btn-danger { background: #fff; color: var(--red); border-color: #e0b4b4; }
.btn-icon { padding: 5px 8px; margin-right: 4px; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }

/* Formularios */
form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 15px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--red); outline-offset: 1px; border-color: var(--red); }
button:focus-visible, a:focus-visible, .tab-log:focus-visible, .hist-tab:focus-visible,
.wiz-paso:focus-visible, .ste:focus-visible, .close:focus-visible,
.pagination button:focus-visible, .menu-btn:focus-visible, .prod-card:focus-within,
.salir-top:focus-visible, .hamburger:focus-visible {
    outline: 3px solid var(--red); outline-offset: 2px;
}

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar.small { margin-bottom: 10px; }
.toolbar h2 { margin-right: auto; }
.toolbar input, .toolbar select { min-width: 170px; }

/* Badges */
.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-entrada { background: #e8f5e9; color: var(--green); }
.badge-salida { background: #fdecea; color: var(--red); }
.badge-bajo { background: #fdecea; color: #CF141D; }
.badge-vencer { background: #fdecea; color: var(--red); }
.badge-info { background: #e8f0fe; color: #1a73e8; }
.badge-pendiente { background: #fff7e6; color: #b45309; }
.badge-despachado { background: #e8f0fe; color: #1a73e8; }
.badge-cumplido { background: #e8f5e9; color: #15803d; }

.items-detalle {
    max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 13px; color: var(--muted);
}
.items-detalle:hover { white-space: normal; }

/* Modal */
.modal {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 100; align-items: flex-start; justify-content: center; padding: 40px 16px;
    overflow-y: auto;
}
.modal.open { display: flex; }
.modal-content {
    background: #fff; border-radius: 14px; padding: 24px; max-width: 560px; width: 100%;
    position: relative; animation: slide .2s ease;
}
.modal-wide { max-width: 750px; }
@keyframes slide { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
.close { position: absolute; right: 16px; top: 10px; font-size: 28px; cursor: pointer; color: var(--muted); border: 0; background: transparent; padding: 4px 8px; line-height: 1; }
.modal-content h2 { margin-bottom: 16px; }
.modal-wide { max-width: 860px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.respaldo-txt { color: var(--muted); font-size: 13px; margin-right: auto; }
.text-red { color: var(--red); }
.text-orange { color: var(--orange, #d97706); }
.scan-input {
    display: flex; align-items: center; gap: 10px;
    border: 2px dashed #FCC302; background: #FFF9E8;
    border-radius: 10px; padding: 10px 14px; margin-bottom: 8px;
}
.scan-input .scan-icon { color: #CF141D; display: flex; }
.scan-input input {
    flex: 1; border: none; background: transparent; font-size: 15px; font-family: inherit;
    color: #0C0908; outline: none;
}
.scan-input input::placeholder { color: #8a8a8a; }
.scan-input:focus-within { border-color: var(--red); border-style: solid; }
.scan-hint { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

/* Toast */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
    background: #323232; color: #fff; padding: 12px 22px; border-radius: 8px;
    font-size: 14px; opacity: 0; transition: all .3s; z-index: 200; box-shadow: 0 3px 10px rgba(0,0,0,.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 20px; font-style: italic; }

/* Mensaje de código automático en el formulario */
.code-auto {
    background: #FDF3E3; color: var(--primary-dark);
    border: 1px dashed var(--accent); border-radius: 8px;
    padding: 8px 12px; font-size: 13px; text-align: center;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--black);
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: 20px;
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
    border: 1px solid rgba(252, 195, 2, .2);
}

.login-box .logo {
    display: block;
    text-align: center;
    margin-bottom: 14px;
}

.login-box h1 {
    text-align: center;
    font-size: 24px;
    margin: 8px 0 4px;
    color: var(--black);
}

.login-box p.sub {
    text-align: center;
    color: var(--gray);
    font-size: 13px;
    margin-bottom: 20px;
}

.login-box label {
    margin-bottom: 10px;
    color: var(--gray);
    display: block;
}

.login-box .btn {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    font-size: 16px;
    border-radius: 12px;
}

.login-box .btn-primary {
    background: var(--yellow);
    border-color: var(--yellow);
    color: var(--black);
}

.login-box .btn-primary:hover {
    background: #D9B400;
}

#login-error {
    display: none;
    background: rgba(252, 195, 2, .12);
    color: var(--black);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
    border: 1px solid rgba(252, 195, 2, .35);
}

/* Pie del menú lateral */
.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,.2);
    padding-top: 12px;
    display: flex; flex-direction: column; gap: 6px;
}
.sidebar-footer .menu-btn { font-size: 13px; }

.sidebar-sesion {
    border-top: 1px solid rgba(255,255,255,.15);
    padding: 12px 14px;
    cursor: pointer;
    transition: background .15s;
}
.sidebar-sesion:hover {
    background: rgba(255,255,255,.07);
}
.sidebar-sesion .sesion-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.sidebar-sesion .sesion-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.sidebar-sesion .sesion-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,.5);
    flex-shrink: 0;
}
.sidebar-sesion .sesion-nombre {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}
.sidebar-sesion .sesion-rol {
    font-size: 11px;
    color: rgba(255,255,255,.72);
    margin-top: 2px;
    padding-left: 42px;
}
.sidebar-sesion .sesion-suc {
    font-size: 11px;
    color: var(--accent, #fcc302);
    margin-top: 1px;
    padding-left: 42px;
    font-weight: 600;
}
.perfil-avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 28px;
    margin: 0 auto 16px;
}
@media (max-width: 900px) {
    .hamburger { display: block; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform .3s ease;
        width: 260px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: block;
        position: fixed; inset: 0; background: rgba(0,0,0,.5);
        z-index: 55; opacity: 0; visibility: hidden; transition: opacity .3s;
    }
    .sidebar-overlay.open { opacity: 1; visibility: visible; }
    main { margin-left: 0; padding: 14px; padding-top: 64px; }
    .data-table { font-size: 12px; }
}
@media (max-width: 700px) {
    main { padding: 12px; padding-top: 60px; }
}

/* Fila total en tablas de reportes */
.total-row td {
    border-top: 2px solid var(--black);
    background: rgba(252, 195, 2, .15);
}

/* Botones de acción con icono */
.toolbar .btn svg { vertical-align: -2px; margin-right: 4px; }
.toolbar .btn { white-space: nowrap; }
.toolbar-spacer { flex: 1; }

/* Cards de categoría */
.categoria-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}
.categoria-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(252, 195, 2, .08);
    border-bottom: 1px solid var(--border);
}
.categoria-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--black);
}
.subcat-titulo {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--primary-dark);
    background: rgba(252, 195, 2, .04);
    border-top: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}
.subcat-titulo:first-child {
    border-top: none;
}
.categoria-table-wrap {
    max-height: 320px;
    overflow-y: auto;
}
.categoria-table-wrap::-webkit-scrollbar { width: 6px; }
.categoria-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Encabezados de sección */
.view > h2 {
    font-size: 22px;
    color: var(--primary-dark);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

/* Paneles con borde lateral */
.panel-accent { border-left: 4px solid var(--primary); }
.panel-success { border-left: 4px solid var(--green); }

/* Encabezado dentro de panel */
.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.panel-head h3, .panel-head h2 { margin: 0; font-size: 16px; }
.panel-head h2 { margin-bottom: 0; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }

/* Separación entre secciones */
.view > .panel { margin-bottom: 16px; }
.view > .grid-2 { margin-top: 16px; }

/* Paginación */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; font-size: 13px; }
.pagination button { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.pagination button:hover:not(:disabled) { background: var(--primary); color: var(--primary-dark); border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .pag-info { color: var(--muted); }

/* Impresión de reportes: solo se imprime la vista activa, sin deformarse */
@media print {
    body { background: #fff; margin: 0; padding: 0; }
    .sidebar, .topbar, .hamburger, .sidebar-overlay, .pagination { display: none !important; }
    main { margin-left: 0; padding: 0; width: 100%; }
    .view { display: none !important; }
    .view.active { display: block !important; width: 100%; }
    .toolbar .btn, .toolbar input, .toolbar select, .kpi-grid, .btn { visibility: hidden; }
    .toolbar { visibility: hidden; }
    .toolbar h2 { visibility: visible; }
    .panel { box-shadow: none; border: none; padding: 6px; margin-bottom: 14px; page-break-inside: auto; }
    h2, h3, .panel h2 { page-break-after: avoid; }
    tr { page-break-inside: avoid; }
    .data-table, table { width: 100% !important; border-collapse: collapse; }
    .data-table { border: 1px solid #ccc; font-size: 10px; }
    .data-table th, .data-table td { padding: 4px 6px; word-break: break-word; }
    thead { display: table-header-group; }
    .dash-charts { grid-template-columns: 1fr !important; gap: 8px; }
    .chart-box { overflow: visible !important; min-height: 0 !important; }
    .chart-box svg { width: 100% !important; max-width: 100% !important; height: auto !important; }
    .hbar-row { page-break-inside: avoid; }
    @page { size: A4; margin: 0.9cm 0.8cm; }
}

body.rol-encargado .kpi-finance,
body.rol-encargado .panel-finance {
    display: none !important;
}

.hist-sucursal-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.hist-tab {
    padding: 6px 14px;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    background: var(--panel-bg, #fff);
    cursor: pointer;
    font-weight: 600;
    color: var(--muted, #666);
    transition: all .2s;
}
.hist-tab.active {
    background: var(--primary);
    color: var(--primary-dark);
    border-color: var(--primary);
}
.tabs-log {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.tab-log {
    padding: 6px 14px;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    background: var(--panel-bg, #fff);
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 14px;
    color: var(--muted, #666);
    transition: all .2s;
}
.tab-log:hover { border-color: var(--red); color: var(--red); }
.tab-log.active {
    background: var(--primary);
    color: var(--primary-dark);
    border-color: var(--primary);
}
.bandeja-cab select.bandeja-estado {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid var(--border, #d8d4cc);
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}
.hist-col-pedidos { min-width: 0; display: flex; flex-direction: column; }
.scope-info {
    color: var(--muted, #666);
    font-size: 13px;
    margin: 0 0 10px;
    font-weight: 600;
}

/* Sincronía de inventario (Reportes admin) */
#panel-sincronia summary {
    cursor: pointer;
    font-weight: 700;
    padding: 4px 0;
    color: var(--accent-dark, #333);
}
#panel-sincronia[open] summary { margin-bottom: 8px; }
.sinc-fichas { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.sinc-ficha {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 130px; padding: 12px 16px; border-radius: 10px;
    background: rgba(252, 195, 2, .12); border: 1px solid rgba(252, 195, 2, .5);
}
.sinc-num { font-size: 26px; font-weight: 800; }
.sinc-lab { font-size: 12px; color: var(--muted, #666); text-align: center; }
.sinc-ok { background: rgba(46, 160, 67, .12); border-color: rgba(46, 160, 67, .5); }
.sinc-mal { background: rgba(207, 20, 29, .12); border-color: rgba(207, 20, 29, .5); }
.sinc-val { margin: 8px 0; }
.sinc-mal-row td { background: rgba(207, 20, 29, .08); }
#sincronia-resultado { margin-top: 12px; }
#sincronia-resultado h3 { margin: 0 0 4px; }

/* Pedidos: formulario masivo por sucursal proveedora */
.pedido-grupo {
    border: 1px solid var(--border, #e4e1d9);
    border-radius: 10px;
    margin: 12px 0;
    padding: 10px 14px 12px;
    background: var(--panel-bg, #fff);
}
.pedido-grupo h3 {
    margin: 0 0 8px;
    font-size: 15px;
    color: var(--dark, #0C0908);
    display: flex;
    align-items: center;
    gap: 8px;
}
.pedido-grupo h3::before {
    content: '';
    width: 10px; height: 10px; border-radius: 3px;
    background: var(--primary, #CF141D);
    display: inline-block;
}
.pedido-grupo h4 {
    margin: 10px 0 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted, #8a8a8a);
}
.td-unidad { text-align: center; color: var(--muted, #666); font-size: 12px; }
.td-cant { text-align: center; white-space: nowrap; }
.td-prov { text-align: right; font-size: 12px; color: var(--muted, #666); }
.pedido-q {
    border: 1px solid var(--border, #d8d4cc);
    border-radius: 6px;
    padding: 4px 6px;
    font-family: inherit;
    font-size: 14px;
    text-align: center;
}
.pedido-q:focus { border-color: var(--primary, #CF141D); outline: none; }
.data-table.compact td { padding: 4px 6px; }
.data-table.compact th { padding: 3px 6px; }

/* Bandeja de llegada */
.bandeja-sucursal {
    border: 1px solid var(--border, #e4e1d9);
    border-radius: 10px;
    margin-bottom: 14px;
    overflow: hidden;
}
.bandeja-sucursal > h3 {
    margin: 0;
    padding: 10px 14px;
    font-size: 15px;
    background: rgba(252, 195, 2, .12);
    border-bottom: 1px solid var(--border, #e4e1d9);
    display: flex;
    align-items: center;
    gap: 10px;
}
.bandeja-pedido {
    padding: 10px 14px;
    border-bottom: 1px dashed var(--border, #e4e1d9);
}
.bandeja-pedido:last-child { border-bottom: none; }
.bandeja-cab {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 13px;
    margin-bottom: 6px;
}
.bandeja-cab .btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid var(--border, #d8d4cc);
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}
.bandeja-cab .btn-sm:hover { background: var(--primary); color: var(--primary-dark); border-color: var(--primary); }
.flex-grow { flex: 1; }

/* Asistente de pedidos en 3 pasos */
.wizard { margin-top: 6px; }
.wiz-pasos {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.wiz-paso {
    flex: 1;
    min-width: 140px;
    border: 1px solid var(--border, #d8d4cc);
    border-radius: 10px;
    background: var(--panel-bg, #fff);
    padding: 10px 12px;
    text-align: left;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    color: var(--muted, #666);
    box-shadow: none;
}
.wiz-paso:hover { border-color: var(--primary, #CF141D); }
.wiz-paso .num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--border, #d8d4cc);
    color: var(--dark, #0C0908);
    font-weight: 700;
    font-size: 12px;
    margin-right: 8px;
}
.wiz-paso.active {
    border-color: var(--primary, #CF141D);
    background: rgba(252, 195, 2, .1);
    color: var(--dark, #0C0908);
    font-weight: 600;
}
.wiz-paso.active .num { background: var(--primary); color: var(--primary-dark); }
.wiz-panel { display: none; }
.wiz-panel[data-paso="1"] { display: block; }
.wiz-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
    flex-wrap: wrap;
}
.wiz-actions.solo {
    justify-content: space-between;
}
.hint { font-size: 13px; color: var(--muted, #666); margin: 4px 0 10px; }

/* Tarjetas de producto con +/− */
.cat-bloque { margin-bottom: 14px; }
.cat-bloque h4 {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted, #8a8a8a);
}
.cat-bloque h4.prov-titulo {
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--red);
}
.prod-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--border, #e4e1d9);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: var(--panel-bg, #fff);
}
.prod-card.seleccionado {
    border-color: var(--primary, #CF141D);
    background: rgba(252, 195, 2, .08);
}
.prod-card-info { min-width: 0; }
.prod-card-nombre { font-size: 14px; font-weight: 600; color: var(--dark, #0C0908); }
.prod-card-meta { font-size: 12px; color: var(--muted, #666); }
.stepper { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ste {
    width: 30px; height: 30px;
    border: 1px solid var(--border, #d8d4cc);
    border-radius: 8px;
    background: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--dark, #0C0908);
    font-family: inherit;
}
.ste:hover { border-color: var(--red); color: var(--red); }
.prod-q {
    width: 60px;
    border: 1px solid var(--border, #d8d4cc);
    border-radius: 8px;
    padding: 5px 4px;
    font-family: inherit;
    font-size: 14px;
    text-align: center;
}
.prod-q:focus { border-color: var(--primary, #CF141D); outline: none; }
.total-row {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark, #0C0908);
}

