:root {
    --inv-primary:   #1a6fc4;
    --inv-secondary: #0d4f96;
    --inv-accent:    #f0a500;
    --inv-success:   #198754;
    --inv-danger:    #dc3545;
    --inv-warning:   #ffc107;
    --inv-sidebar-w: 260px;
    --inv-sidebar-bg:#0d2137;
    --inv-sidebar-txt:#c8d8e8;
    --inv-sidebar-hover:#1a3a5c;
    --inv-sidebar-active:#1a6fc4;
    --inv-topbar-h:  56px;
}

/* ── Reset / Base ─────────────────────────────────────── */
* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #f4f6f9;
    margin: 0;
    overflow-x: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--inv-sidebar-w);
    height: 100vh;
    background: var(--inv-sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .25s ease;
    overflow-y: auto;
    overflow-x: hidden;
}
#sidebar .sidebar-brand {
    padding: 18px 20px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
#sidebar .sidebar-brand span {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: .02em;
}
#sidebar .sidebar-brand small {
    display: block;
    color: var(--inv-sidebar-txt);
    font-size: .7rem;
    font-weight: 400;
}
#sidebar .sidebar-section {
    padding: 14px 16px 4px;
    font-size: .65rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(200,216,232,.4);
    font-weight: 600;
}
#sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--inv-sidebar-txt);
    text-decoration: none;
    font-size: .875rem;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}
#sidebar .nav-link:hover {
    background: var(--inv-sidebar-hover);
    color: #fff;
}
#sidebar .nav-link.active {
    background: rgba(26,111,196,.25);
    border-left-color: var(--inv-primary);
    color: #fff;
}
#sidebar .nav-link i { width: 18px; text-align: center; opacity: .8; }

/* ── Topbar ───────────────────────────────────────────── */
#topbar {
    position: fixed;
    top: 0;
    left: var(--inv-sidebar-w);
    right: 0;
    height: var(--inv-topbar-h);
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    z-index: 999;
}
#topbar .page-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a2332;
    flex: 1;
}
#topbar .user-badge {
    font-size: .8rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 6px;
}
#sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: #495057;
    display: none;
}

/* ── Main content ─────────────────────────────────────── */
#main-content {
    margin-left: var(--inv-sidebar-w);
    padding-top: var(--inv-topbar-h);
    min-height: 100vh;
}
.content-area {
    padding: 24px;
}

/* ── Stat cards ───────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    border-left: 4px solid var(--inv-primary);
}
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    background: rgba(26,111,196,.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    color: var(--inv-primary);
    flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; color: #1a2332; }
.stat-card .stat-label { font-size: .78rem; color: #6c757d; margin-top: 3px; }
.stat-card.warning { border-left-color: var(--inv-warning); }
.stat-card.warning .stat-icon { background: rgba(255,193,7,.1); color: var(--inv-warning); }
.stat-card.success { border-left-color: var(--inv-success); }
.stat-card.success .stat-icon { background: rgba(25,135,84,.1); color: var(--inv-success); }
.stat-card.danger  { border-left-color: var(--inv-danger); }
.stat-card.danger  .stat-icon { background: rgba(220,53,69,.1); color: var(--inv-danger); }

/* ── Cards ────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: .9rem;
    color: #1a2332;
    background: transparent;
    border-radius: 10px 10px 0 0 !important;
}
.card-body { padding: 20px; }

/* ── Tables ───────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c757d;
    border-bottom: 2px solid #dee2e6;
}
.table tbody tr:hover { background: #f0f4f8; }

/* ── Estado badges ────────────────────────────────────── */
.badge-estado {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .03em;
}
.estado-BORRADOR    { background: #e9ecef; color: #495057; }
.estado-PENDIENTE   { background: #fff3cd; color: #856404; }
.estado-APROBADO    { background: #d1e7dd; color: #0a3622; }
.estado-RECHAZADO   { background: #f8d7da; color: #58151c; }
.estado-VALIDADO    { background: #cfe2ff; color: #052c65; }
.estado-EN_PROCESO  { background: #e2d9f3; color: #432874; }
.estado-ENTREGADO   { background: #d1e7dd; color: #0a3622; }
.estado-CONFIRMADO  { background: #d1e7dd; color: #0a3622; }
.estado-PENDIENTE   { background: #fff3cd; color: #856404; }
.estado-RECIBIDO    { background: #cff4fc; color: #055160; }
.estado-INGRESADO   { background: #d1e7dd; color: #0a3622; }
.estado-ALMACENADO  { background: #d3f9d8; color: #0b4d1b; }
.estado-CERRADO     { background: #e9ecef; color: #495057; }

/* ── Buttons ──────────────────────────────────────────── */
.btn-primary  { background: var(--inv-primary); border-color: var(--inv-primary); }
.btn-primary:hover { background: var(--inv-secondary); border-color: var(--inv-secondary); }

/* ── Forms ────────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: .875rem; }
.form-control, .form-select {
    font-size: .875rem;
    border-color: #ced4da;
}
.form-control:focus, .form-select:focus {
    border-color: var(--inv-primary);
    box-shadow: 0 0 0 .2rem rgba(26,111,196,.2);
}

/* ── Detalle dinámico de líneas ───────────────────────── */
.detalle-table th { font-size: .75rem; }
.btn-remove-line {
    background: none; border: none;
    color: var(--inv-danger);
    cursor: pointer;
    padding: 2px 6px;
}

/* ── Page header ──────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a2332;
    margin: 0;
}

/* ── Auth ─────────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--inv-sidebar-bg) 0%, #1a3a5c 100%);
}
.auth-card {
    background: #fff;
    border-radius: 14px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}
.auth-logo h1 { font-size: 1.4rem; font-weight: 700; color: var(--inv-primary); margin: 0; }
.auth-logo p  { color: #6c757d; font-size: .85rem; margin: 4px 0 0; }

/* ── Alertas flash ────────────────────────────────────── */
.alert { border-radius: 8px; font-size: .875rem; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #topbar { left: 0; }
    #main-content { margin-left: 0; }
    #sidebar-toggle { display: block; }
}

/* ── Product search component ─────────────────────────── */
.prod-dropdown { border-radius: 6px; min-width: 300px; }
.pd-item { transition: background .1s; border-bottom: 1px solid #f0f0f0 !important; cursor: pointer; }
.pd-item:last-child { border-bottom: none !important; }
.pd-item.active, .pd-item:hover { background: #eef2ff !important; }
.pd-item mark { background: #fef08a; padding: 0 1px; border-radius: 2px; }
.prod-nombre.is-selected { border-color: #198754 !important; box-shadow: 0 0 0 .15rem rgba(25,135,84,.15); }
.prod-nombre[readonly].is-selected { background-color: #f0fdf4; }
.mp-row:hover td { background: #eef2ff; cursor: pointer; }
.mp-row.active td { background: #dbeafe; }
.mp-cat-btn { font-size: .75rem; padding: .2rem .6rem; }
#mp-lista tr td { vertical-align: middle; }
.detalle-table th { font-size: .8rem; color: #6c757d; font-weight: 600; }
