/* ===== QualisPharma — Bringing quality to Life ===== */
:root {
    --q-primary: #00838F;
    --q-primary-dark: #005662;
    --q-primary-light: #E0F7FA;
    --q-accent: #26C6DA;
    --q-accent-green: #7CB342;
    --q-sidebar: #0D1B2A;
    --q-sidebar-hover: rgba(255,255,255,.08);
    --q-sidebar-active: rgba(38,198,218,.2);
    --q-header-bg: #ffffff;
    --q-body-bg: #f0f2f5;
    --q-text-muted: #6c757d;
    --q-border: #e3e6ea;
    --q-danger: #dc3545;
    --q-radius: .5rem;
}

html, body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .875rem;
    background: var(--q-body-bg);
    margin: 0;
}

h1:focus { outline: none; }

/* --- Buttons: QualisPharma Palette --- */

/* Primary — Teal oscuro (logo text) */
.btn-primary {
    background-color: var(--q-primary);
    border-color: var(--q-primary);
    color: #fff;
}
.btn-primary:hover, .btn-primary:active, .btn-primary:first-child:active {
    background-color: var(--q-primary-dark);
    border-color: var(--q-primary-dark);
    color: #fff;
}
.btn-primary:disabled, .btn-primary.disabled {
    background-color: var(--q-primary);
    border-color: var(--q-primary);
    opacity: .65;
}

/* Success — Verde (logo tagline) */
.btn-success {
    background-color: #7CB342;
    border-color: #7CB342;
    color: #fff;
}
.btn-success:hover, .btn-success:active, .btn-success:first-child:active {
    background-color: #689F38;
    border-color: #689F38;
    color: #fff;
}

/* Info — Cyan brillante (logo icon) */
.btn-info {
    background-color: #26C6DA;
    border-color: #26C6DA;
    color: #fff;
}
.btn-info:hover, .btn-info:active, .btn-info:first-child:active {
    background-color: #00ACC1;
    border-color: #00ACC1;
    color: #fff;
}
.btn-info.text-white { color: #fff !important; }

/* Warning — Ámbar cálido */
.btn-warning {
    background-color: #FFB300;
    border-color: #FFB300;
    color: #212529;
}
.btn-warning:hover, .btn-warning:active, .btn-warning:first-child:active {
    background-color: #FFA000;
    border-color: #FFA000;
    color: #212529;
}

/* Danger — Rojo refinado */
.btn-danger {
    background-color: #E53935;
    border-color: #E53935;
    color: #fff;
}
.btn-danger:hover, .btn-danger:active, .btn-danger:first-child:active {
    background-color: #C62828;
    border-color: #C62828;
    color: #fff;
}

/* Secondary — Blue-grey */
.btn-secondary {
    background-color: #546E7A;
    border-color: #546E7A;
    color: #fff;
}
.btn-secondary:hover, .btn-secondary:active, .btn-secondary:first-child:active {
    background-color: #455A64;
    border-color: #455A64;
    color: #fff;
}

/* --- Outline Buttons --- */
.btn-outline-primary {
    color: var(--q-primary);
    border-color: var(--q-primary);
}
.btn-outline-primary:hover, .btn-outline-primary:active {
    background-color: var(--q-primary);
    border-color: var(--q-primary);
    color: #fff;
}

.btn-outline-success {
    color: #7CB342;
    border-color: #7CB342;
}
.btn-outline-success:hover, .btn-outline-success:active {
    background-color: #7CB342;
    border-color: #7CB342;
    color: #fff;
}

.btn-outline-info {
    color: #00ACC1;
    border-color: #26C6DA;
}
.btn-outline-info:hover, .btn-outline-info:active {
    background-color: #26C6DA;
    border-color: #26C6DA;
    color: #fff;
}

.btn-outline-warning {
    color: #F9A825;
    border-color: #FFB300;
}
.btn-outline-warning:hover, .btn-outline-warning:active {
    background-color: #FFB300;
    border-color: #FFB300;
    color: #212529;
}

.btn-outline-danger {
    color: #E53935;
    border-color: #E53935;
}
.btn-outline-danger:hover, .btn-outline-danger:active {
    background-color: #E53935;
    border-color: #E53935;
    color: #fff;
}

.btn-outline-secondary {
    color: #546E7A;
    border-color: #546E7A;
}
.btn-outline-secondary:hover, .btn-outline-secondary:active {
    background-color: #546E7A;
    border-color: #546E7A;
    color: #fff;
}

/* --- Focus rings — unified teal ring --- */
.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .2rem rgba(0,131,143,.25);
}
.btn-success:focus { box-shadow: 0 0 0 .2rem rgba(124,179,66,.3); }
.btn-info:focus    { box-shadow: 0 0 0 .2rem rgba(38,198,218,.3); }
.btn-warning:focus { box-shadow: 0 0 0 .2rem rgba(255,179,0,.3); }
.btn-danger:focus  { box-shadow: 0 0 0 .2rem rgba(229,57,53,.3); }

/* --- Badges: QualisPharma Palette --- */
.badge.bg-primary  { background-color: var(--q-primary) !important; }
.badge.bg-success  { background-color: #7CB342 !important; }
.badge.bg-info     { background-color: #26C6DA !important; color: #fff !important; }
.badge.bg-warning  { background-color: #FFB300 !important; color: #212529 !important; }
.badge.bg-danger   { background-color: #E53935 !important; }
.badge.bg-secondary { background-color: #546E7A !important; }

/* --- Bootstrap bg-* utility overrides --- */
.bg-primary   { background-color: var(--q-primary); }
.bg-primary-light { background-color: var(--q-primary-light) !important; color: var(--q-primary) !important; }
.bg-success   { background-color: #7CB342; }
.bg-info      { background-color: #26C6DA; }
.bg-warning   { background-color: #FFB300; }
.bg-danger    { background-color: #E53935; }
.bg-secondary { background-color: #546E7A; }

/* --- Modal header — teal gradient QualisPharma --- */
.modal-header {
    background: linear-gradient(135deg, var(--q-primary), #0097A7);
    color: #fff;
    border-bottom: none;
    border-radius: var(--q-radius) var(--q-radius) 0 0;
}
.modal-header .modal-title,
.modal-header h5 {
    font-weight: 700;
    letter-spacing: .3px;
}
.modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: .8;
}
.modal-header .btn-close:hover {
    opacity: 1;
}

/* --- Links --- */
a, .btn-link { color: var(--q-primary); }
a:hover, .btn-link:hover { color: var(--q-primary-dark); }


/* --- Form validation --- */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--q-danger); }
.validation-message { color: var(--q-danger); font-size: .85rem; }

/* --- Sidebar (Light Corporate Theme) --- */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: #FFFFFF;
    color: #1E293B;
    border-right: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    transition: width .25s ease, min-width .25s ease;
    z-index: 10;
    overflow: hidden;
    box-shadow: 2px 0 10px rgba(0, 61, 102, 0.04);
}

/* --- Sidebar collapsed --- */
.sidebar-collapsed .sidebar {
    width: 68px;
    min-width: 68px;
}
.sidebar-collapsed .sidebar-brand div { display: none !important; }
.sidebar-collapsed .sidebar-section { opacity: 0; height: 0; margin: 0; padding: 0; overflow: hidden; }
.sidebar-collapsed .sidebar-nav .nav-link span,
.sidebar-collapsed .sidebar-nav .section-toggle span,
.sidebar-collapsed .sidebar-nav .section-toggle .toggle-icon,
.sidebar-collapsed .sidebar-search {
    display: none !important;
}

.sidebar-collapsed .sidebar-nav .nav-link,
.sidebar-collapsed .sidebar-nav .section-toggle {
    justify-content: center !important;
    padding: .75rem 0 !important;
    width: 100% !important;
    text-align: center !important;
}

.sidebar-collapsed .sidebar-nav .nav-link i,
.sidebar-collapsed .sidebar-nav .section-toggle i:first-child {
    width: auto !important;
    font-size: 1.25rem !important;
    margin: 0 !important;
}

.sidebar-collapsed .sidebar-brand {
    justify-content: center !important;
    padding: 1rem .5rem !important;
}
.sidebar-collapsed .sidebar-brand i { font-size: 1.5rem !important; }
.sidebar-collapsed .sidebar-footer {
    flex-direction: column !important;
    padding: .65rem .5rem !important;
    gap: .4rem !important;
}
.sidebar-collapsed .sidebar-footer .user-info { display: none !important; }
.sidebar-collapsed .sidebar-footer .avatar { width: 32px; height: 32px; font-size: .75rem; }
.sidebar-collapsed .sidebar-footer .btn-logout { width: 100% !important; text-align: center !important; }

/* --- Toggle button --- */
.btn-sidebar-toggle {
    background: transparent;
    border: 1px solid var(--q-border);
    border-radius: var(--q-radius);
    color: var(--q-text-muted);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0;
}
.btn-sidebar-toggle:hover {
    background: var(--q-primary-light);
    color: var(--q-primary);
    border-color: var(--q-primary);
}

.btn-sidebar-toggle-nav {
    background: transparent;
    border: 1px solid #E2E8F0;
    border-radius: var(--q-radius);
    color: #64748B;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .15s ease;
}
.btn-sidebar-toggle-nav:hover {
    background: #E6F4F9;
    color: #0065A8;
    border-color: #C5E3ED;
}

.sidebar-brand {
    padding: 1rem 0.85rem;
    border-bottom: 1px solid #E2E8F0;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-brand i { font-size: 1.6rem; color: #0065A8; }
.sidebar-brand .brand-logo { width: 36px; height: 36px; flex-shrink: 0; }
.sidebar-brand .brand-title { color: #003D66; font-weight: 700; font-size: 1rem; letter-spacing: .5px; }
.sidebar-brand .brand-tagline { display: block; font-size: .65rem; color: #7CB342; margin-top: 2px; font-style: italic; letter-spacing: .3px; }
.sidebar-brand small { display: block; font-size: .7rem; color: #64748B; margin-top: 2px; }

/* --- Sidebar Search --- */
.sidebar-search {
    padding: 0.5rem 0.75rem;
    background: #FFFFFF;
    border-bottom: 1px solid #F1F5F9;
    position: relative;
    transition: all .25s ease;
}
.sidebar-search .search-container {
    display: flex;
    align-items: center;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: var(--q-radius);
    padding: 0.25rem 0.5rem;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.sidebar-search .search-container:focus-within {
    border-color: #0065A8;
    background: #FFFFFF;
    box-shadow: 0 0 0 .2rem rgba(0, 101, 168, 0.12);
}
.sidebar-search .search-icon {
    color: #64748B;
    font-size: 0.85rem;
    margin-right: 0.35rem;
    display: flex;
    align-items: center;
}
.sidebar-search input {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: #1E293B !important;
    font-size: 0.8rem;
    padding: 0;
    width: 100%;
    box-shadow: none !important;
}
.sidebar-search input::placeholder {
    color: #94A3B8;
}
.sidebar-search .btn-clear {
    background: transparent;
    border: none;
    color: #64748B;
    padding: 0 0 0 0.35rem;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.sidebar-search .btn-clear:hover {
    color: #0F172A;
}

.sidebar-collapsed .sidebar-search {
    display: none;
}

.sidebar-section {
    padding: .65rem .85rem .25rem;
    margin-top: .4rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748B;
    font-weight: 700;
}
.sidebar-nav { display: flex; flex-direction: column; padding: .2rem .5rem; gap: 2px; }
.sidebar-nav .nav-link {
    color: #334155;
    border-radius: var(--q-radius);
    padding: .5rem .75rem;
    font-size: .84rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .6rem;
    transition: all .15s ease-in-out;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: #0065A8; transition: color .15s ease; }
.sidebar-nav .nav-link:hover { background: #F1F5F9; color: #003D66; border-left-color: #93C5FD; }
.sidebar-nav .nav-link.active { background: #E6F4F9; color: #003D66; font-weight: 700; border-left: 3.5px solid #0065A8; }
.sidebar-nav .nav-link.active i { color: #003D66; }

.sidebar-footer {
    margin-top: auto;
    padding: .75rem .85rem;
    background: #F8FAFC;
    border-top: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    gap: .65rem;
}
.sidebar-footer .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00838F 0%, #26C6DA 100%);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; color: #fff;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .user-name { font-size: .82rem; font-weight: 700; color: #0F172A; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-role { font-size: .7rem; color: #64748B; }
.sidebar-footer .user-tenant {
    font-size: .7rem;
    color: #0065A8;
    max-width: 140px;
    line-height: 1.25;
    font-weight: 500;
}
.sidebar-footer .user-tenant i { font-size: .65rem; }
.sidebar-footer .btn-logout {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    color: #64748B;
    border-radius: var(--q-radius);
    padding: .35rem .55rem;
    cursor: pointer;
    transition: all .15s ease;
    flex-shrink: 0;
}
.sidebar-footer .btn-logout:hover { background: #FEE2E2; color: #DC2626; border-color: #FCA5A5; }

/* --- Top header --- */
.top-header {
    background: var(--q-header-bg);
    border-bottom: 1px solid var(--q-border);
    padding: .65rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.top-header .breadcrumb-area { font-size: .875rem; color: var(--q-text-muted); }
.top-header .breadcrumb-area strong { color: #212529; }

/* Empresa / Establecimiento info in header */
.header-tenant-info {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--q-primary);
    background: linear-gradient(135deg, var(--q-primary), #0097A7);
    color: #fff;
    border-radius: var(--q-radius);
    padding: .4rem .85rem;
    font-size: .8rem;
    font-weight: 500;
    box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.header-tenant-info .tenant-item {
    display: flex;
    align-items: center;
    gap: .35rem;
}
.header-tenant-info .tenant-item i { font-size: .85rem; opacity: .85; }
.header-tenant-info .tenant-sep { opacity: .45; font-weight: 300; }

/* --- Content area --- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--q-body-bg);
}
/* main-content es una columna flex de alto fijo: su contenido no debe encogerse (se recortaría en vez de hacer scroll) */
.main-content > * { flex-shrink: 0; }

/* --- Login page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(135deg, #00838F 0%, #005662 40%, #0D1B2A 100%);
}
.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    padding: 3rem;
}
.login-left .brand-icon { font-size: 4rem; color: rgba(255,255,255,.9); }
.login-left .login-logo { width: 80px; height: 80px; margin-bottom: .5rem; filter: drop-shadow(0 2px 8px rgba(0,0,0,.2)); }
.login-left h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: 1px; margin: 1rem 0 .25rem; }
.login-left .login-tagline { font-size: 1.1rem; color: #7CB342; font-style: italic; font-weight: 500; margin-bottom: .5rem; }
.login-left p { font-size: 1.05rem; color: rgba(255,255,255,.6); max-width: 340px; text-align: center; line-height: 1.6; }
.login-left .features { margin-top: 2.5rem; display: flex; flex-direction: column; gap: .85rem; }
.login-left .features div { display: flex; align-items: center; gap: .75rem; color: rgba(255,255,255,.7); font-size: .9rem; }
.login-left .features i { color: var(--q-accent); font-size: 1.1rem; }

.login-right {
    width: 480px;
    min-width: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 3rem;
}
.login-card { width: 100%; max-width: 380px; }
.login-card h3 { font-weight: 700; color: #212529; margin-bottom: .25rem; }
.login-card p.subtitle { color: var(--q-text-muted); font-size: .9rem; margin-bottom: 1.75rem; }
.login-card .form-label { font-weight: 600; font-size: .85rem; color: #495057; }
.login-card .form-control { padding: .65rem .85rem; border-radius: var(--q-radius); border: 1px solid var(--q-border); }
.login-card .form-control:focus { border-color: var(--q-accent); box-shadow: 0 0 0 .2rem rgba(38,198,218,.15); }
.login-card .btn-login {
    background: var(--q-primary);
    border: none;
    padding: .7rem;
    border-radius: var(--q-radius);
    font-weight: 600;
    font-size: .95rem;
    transition: background .2s;
}
.login-card .btn-login:hover { background: var(--q-primary-dark); }

/* --- Backdrop (oculto en desktop) --- */
.sidebar-backdrop { display: none; }

/* Alto visible real en celulares (descuenta la barra de direcciones del navegador) */
.app-shell { height: 100dvh !important; }

/* --- Barra superior móvil (oculta en desktop) --- */
.mobile-topbar { display: none; }

@media (max-width: 768px) {
    /* --- Login responsive --- */
    .login-left { display: none; }
    .login-right { width: 100%; min-width: auto; padding: 1.5rem; }

    /* --- Sidebar: overlay móvil --- */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px !important;
        min-width: 260px !important;
        transform: translateX(-100%);
        z-index: 1050;
        transition: transform .3s ease;
    }
    /* Cuando NO está colapsado → mostrar overlay */
    div:not(.sidebar-collapsed) > .sidebar {
        transform: translateX(0);
    }
    /* Resetear estilos de collapsed en móvil (siempre full sidebar) */
    .sidebar-collapsed .sidebar-brand div { display: block; }
    .sidebar-collapsed .sidebar-section { opacity: 1; height: auto; margin-top: .75rem; padding: .5rem .75rem 0; overflow: visible; }
    .sidebar-collapsed .sidebar-nav .nav-link span { display: inline; }
    .sidebar-collapsed .sidebar-nav .nav-link { justify-content: flex-start; padding: .55rem .85rem; }
    .sidebar-collapsed .sidebar-nav .nav-link i { width: 1.2rem; font-size: 1.05rem; }
    .sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 1.25rem 1rem; }
    .sidebar-collapsed .sidebar-brand i { font-size: 1.6rem; }
    .sidebar-collapsed .sidebar-footer { flex-direction: row; padding: .85rem 1rem; gap: .65rem; }
    .sidebar-collapsed .sidebar-footer .user-info { display: block; }
    .sidebar-collapsed .sidebar-footer .avatar { width: 36px; height: 36px; font-size: .85rem; }
    .sidebar-collapsed .sidebar-footer .btn-logout { width: auto; }

    /* --- Pestañas: una sola fila desplazable --- */
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
    .nav-tabs .nav-link { white-space: nowrap; }

    /* --- Barra superior móvil: botón para abrir el menú lateral --- */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: .6rem;
        padding: .4rem .75rem;
        background: #FFFFFF;
        border-bottom: 1px solid #E2E8F0;
        flex-shrink: 0;
    }
    .btn-mobile-menu {
        border: 1px solid #E2E8F0;
        background: #FFFFFF;
        border-radius: .4rem;
        width: 38px;
        height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1.4rem;
        color: #003D66;
    }
    .mobile-topbar-titulo {
        display: flex;
        flex-direction: column;
        line-height: 1.15;
        min-width: 0;
        color: #003D66;
    }
    .mobile-topbar-sub {
        font-size: .75rem;
        color: #64748B;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* --- Backdrop --- */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 1040;
    }
    div:not(.sidebar-collapsed) > .sidebar-backdrop {
        display: block;
    }

    /* --- Header compacto --- */
    .top-header {
        padding: .5rem .75rem;
    }
    .top-header .breadcrumb-area strong {
        font-size: .8rem;
    }

    /* --- Contenido --- */
    .main-content {
        padding: .75rem;
    }

    /* --- Tablas y cards --- */
    .stat-card {
        padding: .75rem;
        border-radius: .35rem;
    }
    .table th, .table td {
        font-size: .8rem;
        padding: .4rem .5rem;
    }
    .table thead th,
    .table tbody td {
        display: none;
    }
    .table thead th.col-main,
    .table tbody td.col-main,
    .table thead th:last-child,
    .table tbody td:last-child {
        display: table-cell;
    }
    /* Tablas de detalle de documentos: todas las columnas, con desplazamiento horizontal */
    .table.tabla-completa thead th,
    .table.tabla-completa tbody td {
        display: table-cell;
    }
    /* Tablas que en celular se muestran como lista compacta: una tarjeta por fila.
       La celda .col-main es el título; el resto fluye debajo. data-label="..." muestra la etiqueta (útil en campos editables). */
    .table.tabla-movil thead { display: none; }
    .table.tabla-movil tfoot tr { display: flex; justify-content: space-between; padding: .5rem .6rem; }
    .table.tabla-movil tfoot td { display: block !important; border: 0; padding: 0 !important; }
    .table.tabla-movil tfoot td:empty { display: none !important; }
    .table.tabla-movil tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: .75rem;
        row-gap: .2rem;
        padding: .5rem .6rem;
        border-bottom: 1px solid #E2E8F0;
    }
    .table.tabla-movil tbody td {
        display: block !important;
        border: 0;
        padding: 0 !important;
        background: transparent;
        box-shadow: none;
        font-size: .8rem;
        color: #475569;
        white-space: normal;
        max-width: 100%;
    }
    .table.tabla-movil tbody td { text-align: left !important; }
    .table.tabla-movil tbody td.col-main {
        order: -1;
        flex: 1 1 100%;
        font-weight: 600;
        font-size: .85rem;
        color: #1E293B;
    }
    .table.tabla-movil tbody td.col-movil-ancho { flex: 1 1 100%; }
    .table.tabla-movil tbody td:empty,
    .table.tabla-movil tbody td.col-sel,
    .table.tabla-movil tbody td.col-oculta-movil,
    .table.tabla-movil tbody td:has(> input[type="radio"]) { display: none !important; }
    .table.tabla-movil tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: .68rem;
        font-weight: 600;
        color: #94A3B8;
        text-transform: uppercase;
        letter-spacing: .02em;
    }
    .table.tabla-movil tbody td[data-label]:has(input, select) { flex: 1 1 45%; }
    .table.tabla-movil td.col-main .text-truncate { max-width: none !important; white-space: normal; }
    /* Barras de los listados: el texto de la fila seleccionada no cabe en celular */
    .grid-toolbar .grid-selection-hint { display: none; }
    .table.tabla-movil .cell-truncate,
    .table.tabla-movil .cell-truncate-sm,
    .table.tabla-movil .cell-truncate-lg { max-width: none; white-space: normal; }
    /* Buscadores: en pantallas chicas la lista de resultados mide lo mismo que el campo (no se sale por la derecha) */
    .searchable-select > .dropdown-menu {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* --- Página header (títulos de sección) --- */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: .75rem;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 h4 {
        font-size: 1.1rem;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 .btn {
        width: 100%;
    }

    /* --- Buscador --- */
    .stat-card .row.g-2 .col-md-6 { flex: 1 1 100%; }
    .stat-card .row.g-2 .col-auto { width: 100%; }
    .stat-card .row.g-2 .col-auto .btn { width: 100%; }

    /* --- Modal fullscreen en móvil --- */
    .modal-dialog {
        margin: .5rem;
        max-width: calc(100% - 1rem);
    }
    .modal-body .row .col-md-4,
    .modal-body .row .col-md-8,
    .modal-body .row .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* --- Paginación compacta --- */
    nav.d-flex.justify-content-between {
        flex-direction: column;
        gap: .5rem;
        text-align: center;
    }

    /* --- Toasts más pequeños --- */
    .toast-container-custom {
        max-width: calc(100% - 1rem);
        left: .5rem;
        right: .5rem;
    }
}

/* --- Dashboard cards --- */
.stat-card {
    background: #fff;
    border-radius: var(--q-radius);
    padding: 1.25rem;
    border: 1px solid var(--q-border);
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); }

/* --- Compact tables with striped rows --- */
.table {
    font-size: .8125rem;
}
.table th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.table th, .table td {
    padding: .4rem .65rem;
}
.table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}
.table-hover tbody tr:nth-child(even):hover {
    background-color: rgba(0,0,0,.06);
}

/* ============ Toast Notifications ============ */
.toast-container-custom {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 400px;
    width: 100%;
    pointer-events: none;
}

.toast-item {
    pointer-events: auto;
    padding: .85rem 1rem;
    border-radius: var(--q-radius, 8px);
    border-left: 4px solid;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    animation: toast-slide-in .3s ease-out;
}

.toast-item .btn-close {
    font-size: .65rem;
    opacity: .5;
    margin-top: 2px;
}
.toast-item .btn-close:hover { opacity: 1; }

.toast-icon { font-size: 1.2rem; margin-top: 1px; }

.toast-success {
    border-left-color: #198754;
}
.toast-success .toast-icon { color: #198754; }

.toast-error {
    border-left-color: #dc3545;
}
.toast-error .toast-icon { color: #dc3545; }

.toast-warning {
    border-left-color: #ffc107;
}
.toast-warning .toast-icon { color: #d39e00; }

.toast-info {
    border-left-color: var(--q-primary, #0d6e5b);
}
.toast-info .toast-icon { color: var(--q-primary, #0d6e5b); }

@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ============ Autocomplete Dropdown ============ */
.autocomplete-dropdown {
    z-index: 1050;
    top: 100%;
    left: 0;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--q-border);
    border-radius: 0 0 var(--q-radius) var(--q-radius);
    background: #fff;
}
.autocomplete-dropdown .list-group-item {
    border: none;
    border-bottom: 1px solid #f0f0f0;
    font-size: .875rem;
}
.autocomplete-dropdown .list-group-item:last-child { border-bottom: none; }
.autocomplete-dropdown .list-group-item-action:hover {
    background: var(--q-primary-light);
    color: var(--q-primary-dark);
}
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: .75rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}

/* --- Error boundary --- */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "Ha ocurrido un error."; }
/* ===== Menús Colapsables en Sidebar (Light Theme) ===== */
.sidebar-nav .section-toggle {
    width: 100%;
    background: transparent;
    border: none;
    color: #334155;
    text-align: left;
    padding: .5rem .75rem;
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    transition: all .15s ease;
    border-radius: var(--q-radius);
}

.sidebar-nav .section-toggle i:first-child {
    font-size: 1.05rem;
    width: 1.2rem;
    text-align: center;
    color: #0065A8;
}

.sidebar-nav .section-toggle .toggle-icon {
    font-size: .75rem;
    color: #64748B;
    transition: transform .25s ease;
    margin-left: auto;
}

.sidebar-nav .section-toggle:hover {
    background: #F1F5F9;
    color: #003D66;
}

.sidebar-nav .section-toggle.expanded {
    color: #003D66;
    background: #E6F4F9;
    font-weight: 700;
}

.sidebar-nav .section-toggle.expanded .toggle-icon {
    transform: rotate(180deg);
    color: #003D66;
}

.collapsible-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
}

.collapsible-menu.show {
    max-height: 2000px;
}

.submenu-label {
    padding: .55rem .85rem .25rem 2rem;
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #64748B;
    font-weight: 700;
    margin-top: .15rem;
}

.sidebar-nav .nav-link.submenu-item {
    padding-left: 2rem;
    font-size: .8rem;
    color: #475569;
}

.sidebar-nav .nav-link.submenu-item i {
    font-size: .92rem;
    color: #0065A8;
}

.sidebar-nav .nav-link.submenu-item:hover {
    background: #F8FAFC;
    color: #003D66;
}

.sidebar-nav .nav-link.submenu-item.active {
    background: #E6F4F9;
    color: #003D66;
    font-weight: 700;
    border-left: 3.5px solid #0065A8;
}

.sidebar-collapsed .collapsible-menu {
    display: none !important;
}

/* ==========================================================================
   QualisPharma — Master Grid & List Styling (Estilo Catálogo de Productos)
   ========================================================================== */

/* --- Compact Table Styling --- */
.table {
    font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
    font-size: .75rem;
    color: #212529;
    line-height: 1.25;
    background-color: #ffffff;
}
.table th {
    font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: .35rem .5rem;
    color: #003D66;
    font-weight: 700;
}
.table th, .table td {
    padding: .3rem .5rem;
    vertical-align: middle;
}
.table-compact th, .table-compact td {
    padding: .25rem .45rem;
}
.table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}
.table-hover tbody tr:hover {
    background-color: rgba(0, 101, 168, 0.05);
}
.table-row-selected {
    background-color: #D1ECF6 !important;
    border-left: 3.5px solid var(--q-primary) !important;
}
.table-row-selected td {
    background-color: transparent !important;
}

/* --- Table Scroll Container with Sticky Header --- */
.table-scroll-container {
    height: calc(100vh - 175px);
    min-height: 250px;
    overflow-y: auto;
    background-color: #ffffff;
    border-bottom: none;
    padding-bottom: 45px;
}
.table-scroll-container .table {
    margin-bottom: 0 !important;
}
.table-scroll-container table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: #E6F4F9 !important;
    color: #003D66 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* --- Fixed Pagination Footer --- */
.grid-pagination-footer {
    position: fixed;
    bottom: 0;
    left: 260px;
    right: 0;
    height: 40px;
    background: #ffffff;
    border-top: 1px solid #C5E3ED;
    padding: .25rem 1rem;
    font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
    font-size: .8rem;
    color: #212529;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    z-index: 100;
    transition: left .25s ease;
}
.sidebar-collapsed .grid-pagination-footer {
    left: 70px;
}
@media (max-width: 768px) {
    .grid-pagination-footer {
        left: 0 !important;
    }
}

.pagination-take-select {
    min-width: 65px !important;
    width: auto !important;
    padding-left: .5rem !important;
    padding-right: 1.4rem !important;
    font-family: Tahoma, 'Segoe UI', Arial, sans-serif !important;
    font-size: .75rem !important;
    font-weight: 700 !important;
    color: #003D66 !important;
    background-color: #ffffff !important;
    border: 1px solid #bce1ec !important;
    border-radius: .25rem !important;
}
@media (max-width: 1650px) {
    .col-oculta-laptop {
        display: none !important;
    }
}

/* --- Cell Text Truncation with Ellipsis --- */
.cell-truncate {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cell-truncate-lg {
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cell-truncate-sm {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Command Bar / CRM Toolbar --- */
.grid-toolbar {
    background: var(--q-body-bg);
    border: none;
    padding: .25rem .5rem;
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
    font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
}
.grid-toolbar .btn, 
.grid-toolbar label.btn {
    background-color: #ffffff !important;
    border: 1px solid #c5e3ed !important;
    font-size: .8rem;
    padding: .2rem .45rem;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(11,74,83,0.08) !important;
    transition: all .15s ease-in-out;
}
.grid-toolbar .btn-primary { color: #0065A8 !important; }
.grid-toolbar .btn-outline-primary { color: #0288d1 !important; }
.grid-toolbar .btn-success,
.grid-toolbar .btn-outline-success { color: #2e7d32 !important; }
.grid-toolbar .btn-warning,
.grid-toolbar .btn-outline-warning { color: #f57c00 !important; }
.grid-toolbar .btn-danger,
.grid-toolbar .btn-outline-danger { color: #d32f2f !important; }
.grid-toolbar .btn-info,
.grid-toolbar .btn-outline-info { color: #0097a7 !important; }

.grid-toolbar .btn:disabled,
.grid-toolbar .btn.disabled,
.grid-toolbar label.disabled {
    background-color: rgba(255,255,255,0.6) !important;
    color: #9cb5bd !important;
    border-color: #dceef4 !important;
    box-shadow: none !important;
    opacity: 0.7;
    cursor: not-allowed;
}

.grid-toolbar .btn:not(:disabled):hover {
    background-color: #f1f5f9 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2) !important;
}
.grid-toolbar .vr {
    height: 16px;
    opacity: .3;
    align-self: center;
}

/* --- Acción en curso: capa que bloquea la página (BloqueoAccion) y botones deshabilitados visibles --- */
.bloqueo-accion {
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: rgba(255, 255, 255, .35);
    cursor: progress;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 2.5rem;
    /* Bloquea los clics desde el primer instante, pero solo se ve si la operación tarda (sin parpadeo en las rápidas) */
    animation: bloqueo-aparecer .2s ease .35s both;
}
@keyframes bloqueo-aparecer {
    from { background: rgba(255, 255, 255, 0); }
    to { background: rgba(255, 255, 255, .35); }
}
.bloqueo-accion-aviso { animation: bloqueo-aviso .2s ease .35s both; }
@keyframes bloqueo-aviso {
    from { opacity: 0; }
    to { opacity: 1; }
}
/* Mientras el diálogo "¿Está seguro?" está abierto todavía no se procesa nada: sin aviso */
body:has(.modal.show) .bloqueo-accion:not(.bloqueo-accion-global) .bloqueo-accion-aviso { display: none; }
/* Capa global (solicitud en curso): por encima de las ventanas y debajo de los avisos (toasts, 9999) */
.bloqueo-accion-global { z-index: 1100; }
.bloqueo-accion-aviso {
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
    padding: .45rem 1rem;
    font-size: .85rem;
    font-weight: 600;
    color: #003D66;
}
.btn:disabled, .btn.disabled, .btn-grid-action:disabled, button:disabled {
    opacity: .45;
    cursor: not-allowed;
}
