:root {
    --neo-bg: #f5f7f4;
    --neo-surface: #ffffff;
    --neo-surface-2: #eef3ec;
    --neo-border: #d8e0d5;
    --neo-text: #1f2a22;
    --neo-text-muted: #5a6b5c;
    --neo-primary: #2f7a4f;
    --neo-primary-hover: #26623f;
    --neo-primary-contrast: #ffffff;
    --neo-danger: #b3432f;
    --neo-warning: #b3812f;
    --neo-sidebar-bg: #1f2f24;
    --neo-sidebar-text: #dfe8de;
    --neo-sidebar-text-muted: #9db29e;
    --neo-sidebar-active: #2f7a4f;
    --neo-radius: 10px;
}

[data-theme="oscuro"] {
    --neo-bg: #141815;
    --neo-surface: #1c211d;
    --neo-surface-2: #232920;
    --neo-border: #313a2f;
    --neo-text: #e6ebe4;
    --neo-text-muted: #a2ada0;
    --neo-primary: #4fa972;
    --neo-primary-hover: #5fbb82;
    --neo-primary-contrast: #0d130e;
    --neo-danger: #d9705a;
    --neo-warning: #d9a75a;
    --neo-sidebar-bg: #101510;
    --neo-sidebar-text: #dbe3d8;
    --neo-sidebar-text-muted: #7f8f80;
    --neo-sidebar-active: #2f7a4f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--neo-bg);
    color: var(--neo-text);
}

.neo-app {
    display: flex;
    min-height: 100vh;
}

.neo-sidebar {
    width: 250px;
    background: var(--neo-sidebar-bg);
    color: var(--neo-sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.neo-sidebar-brand {
    padding: 20px 18px;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.neo-sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.neo-sidebar-nav a {
    display: block;
    padding: 10px 18px;
    color: var(--neo-sidebar-text-muted);
    text-decoration: none;
    font-size: 14px;
}

.neo-sidebar-nav a:hover,
.neo-sidebar-nav a.activo,
.neo-sidebar-group.activo > button {
    color: #fff;
    background: var(--neo-sidebar-active);
}

.neo-sidebar-group > button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    background: none;
    border: none;
    color: var(--neo-sidebar-text-muted);
    font-size: 14px;
    cursor: pointer;
    text-align: left;
}

.neo-sidebar-group > button:hover {
    color: #fff;
    background: var(--neo-sidebar-active);
}

.neo-sidebar-group .neo-chevron {
    transition: transform 0.15s ease;
}

.neo-sidebar-group.abierto .neo-chevron {
    transform: rotate(90deg);
}

.neo-sidebar-submenu {
    display: none;
    flex-direction: column;
}

.neo-sidebar-group.abierto .neo-sidebar-submenu {
    display: flex;
}

.neo-sidebar-submenu a {
    padding: 8px 18px 8px 34px;
    font-size: 13px;
}

.neo-ancla { scroll-margin-top: 16px; }

.neo-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.neo-sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.neo-theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--neo-sidebar-text);
    border-radius: var(--neo-radius);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
}

.neo-logout-form button {
    background: none;
    border: none;
    color: var(--neo-sidebar-text-muted);
    cursor: pointer;
    font-size: 13px;
}

.neo-content {
    flex: 1;
    padding: 24px 32px;
}

.neo-card {
    background: var(--neo-surface);
    border: 1px solid var(--neo-border);
    border-radius: var(--neo-radius);
    padding: 20px;
}

.neo-table {
    width: 100%;
    border-collapse: collapse;
}

.neo-table th, .neo-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--neo-border);
    font-size: 14px;
}

.neo-btn {
    display: inline-block;
    background: var(--neo-primary);
    color: var(--neo-primary-contrast);
    border: none;
    border-radius: var(--neo-radius);
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}

.neo-btn:hover { background: var(--neo-primary-hover); }

.neo-btn-danger { background: var(--neo-danger); }
.neo-btn-success { background: #22c55e; color: #05210f; }

.neo-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--neo-radius);
    border: 1px solid var(--neo-border);
    background: var(--neo-surface-2);
    color: var(--neo-text);
}

select.neo-input:disabled {
    opacity: 0.85;
    cursor: not-allowed;
}

.mp-ayuda,
.mp-bloqueo {
    display: block;
    color: var(--neo-text-muted, #666);
    font-size: 12px;
    margin: 4px 0 0;
    max-width: 36rem;
    line-height: 1.35;
}

.mp-bloqueo[hidden],
.mp-ayuda[hidden] {
    display: none;
}

.neo-table-scroll {
    overflow-x: auto;
}

.mp-card {
    background: var(--neo-surface-2);
    margin: 0 0 16px;
    padding: 16px 18px 18px;
}

.mp-card .neo-input {
    background: var(--neo-surface);
    min-height: 40px;
}

.mp-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.mp-seccion {
    margin: 2px 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--neo-text-muted);
}

.mp-grid {
    display: grid;
    gap: 12px 16px;
    margin-bottom: 14px;
}

.mp-grid-datos {
    grid-template-columns: minmax(12rem, 1.1fr) minmax(11rem, 0.9fr) minmax(9rem, 0.7fr) minmax(260px, 1.6fr);
}

.mp-grid-cant {
    grid-template-columns: minmax(12rem, 1.3fr) minmax(9rem, 1fr) minmax(11rem, 1.2fr) minmax(7rem, 0.6fr);
}

.mp-grid-mp {
    grid-template-columns: minmax(30rem, 1.8fr) minmax(12rem, 0.7fr);
}

.mp-grid-peligro {
    grid-template-columns: minmax(16rem, 1fr) minmax(16rem, 1fr) minmax(18rem, 1.3fr);
}

.mp-campo label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}

.mp-card .mp-select,
.mp-card .mp-decision {
    width: 100%;
}

@media (max-width: 1100px) {
    .mp-grid-datos,
    .mp-grid-cant,
    .mp-grid-mp,
    .mp-grid-peligro {
        grid-template-columns: 1fr 1fr;
    }
    .mp-campo-desc,
    .mp-grid-mp .mp-campo:first-child {
        grid-column: 1 / -1;
    }
}

.neo-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: var(--neo-surface-2);
    color: var(--neo-text-muted);
}

/* DataTables - ajuste visual para que respete nuestros temas */
.dataTables_wrapper {
    color: var(--neo-text);
    font-size: 14px;
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: var(--neo-surface-2);
    color: var(--neo-text);
    border: 1px solid var(--neo-border);
    border-radius: var(--neo-radius);
    padding: 4px 8px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--neo-text) !important;
    border-radius: 6px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--neo-primary) !important;
    color: var(--neo-primary-contrast) !important;
    border: none !important;
}
table.dataTable tbody tr {
    background: var(--neo-surface);
    color: var(--neo-text);
}
table.dataTable thead th {
    border-bottom: 2px solid var(--neo-border) !important;
}

/* ===================== Sistema de alertas (toasts) ===================== */
.neo-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}
.neo-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--neo-radius);
    background: var(--neo-surface);
    border: 1px solid var(--neo-border);
    border-left: 4px solid var(--neo-primary);
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    color: var(--neo-text);
    animation: neo-toast-in 0.2s ease-out;
    font-size: 14px;
}
.neo-toast-icon { font-weight: bold; font-size: 16px; line-height: 1; margin-top: 1px; }
.neo-toast-body { flex: 1; }
.neo-toast-title { font-weight: 600; margin-bottom: 2px; display: block; }
.neo-toast-close { cursor: pointer; color: var(--neo-text-muted); background: none; border: none; font-size: 16px; line-height: 1; }
.neo-toast-close:hover { color: var(--neo-text); }
.neo-toast-exito { border-left-color: var(--neo-primary); }
.neo-toast-exito .neo-toast-icon { color: var(--neo-primary); }
.neo-toast-error { border-left-color: var(--neo-danger); }
.neo-toast-error .neo-toast-icon { color: var(--neo-danger); }
.neo-toast-advertencia { border-left-color: var(--neo-warning); }
.neo-toast-advertencia .neo-toast-icon { color: var(--neo-warning); }
.neo-toast-info { border-left-color: #3b7ab3; }
.neo-toast-info .neo-toast-icon { color: #3b7ab3; }
@keyframes neo-toast-in {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.neo-toast.neo-toast-saliendo { animation: neo-toast-out 0.18s ease-in forwards; }
@keyframes neo-toast-out {
    to { transform: translateX(30px); opacity: 0; }
}

.neo-select-buscable-wrapper { margin-bottom: 0; }

/* Filas "deshabilitados" en listas de catalogo: se distinguen con estilo, no con
   un renglon divisor (ese metodo rompia el conteo de columnas de DataTables). */
.neo-row-disabled { opacity: 0.55; background: var(--neo-surface-2); }
.neo-row-disabled td:first-child { position: relative; }
.neo-select-buscador { margin-bottom: 4px; font-size: 13px; }

/* Dialogo de confirmacion (reemplaza confirm() nativo para acciones destructivas) */
.neo-confirm-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.neo-confirm-box {
    background: var(--neo-surface); border: 1px solid var(--neo-border); border-radius: var(--neo-radius);
    padding: 20px; max-width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.neo-confirm-box p { margin: 0 0 16px; color: var(--neo-text); }
.neo-confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
