/* ============================================================
   INFINITY VIEW — Brand CSS v1.0
   Infinity View BBJ S.L. — inviewsl.com
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;800&family=Inter:wght@300;400;600&display=swap');

/* ============================================================
   CSS VARIABLES — BRAND BOOK
   ============================================================ */
:root {
    /* === Infinity View Brand === */
    --iv-navy:         #0F2C59;
    --iv-orange:       #EA580C;
    --iv-stone:        #F8F4EB;
    --iv-dark:         #1F2937;
    --iv-white:        #FFFFFF;
    --iv-navy-light:   #1a3d6e;
    --iv-orange-hover: #c2440a;

    --iv-font-title:   'Outfit', sans-serif;
    --iv-font-body:    'Inter', sans-serif;

    --iv-sidebar-width: 240px;
    --iv-topbar-height: 60px;
    --iv-radius:        4px;
    --iv-shadow:        0 2px 8px rgba(15, 44, 89, 0.08);
    --iv-shadow-lg:     0 8px 24px rgba(15, 44, 89, 0.15);
    --iv-transition:    all 0.2s ease;

    /* === MQF Variable Overrides → Infinity View Light Brand ===
       Redefine ALL --mqf-* vars so pages with inline var() fallbacks
       and mqf-theme.css selectors render in brand colors.         */

    /* Fondos */
    --mqf-bg-sidebar:    #0F2C59;
    --mqf-bg-topbar:     #FFFFFF;
    --mqf-bg-canvas:     #F8F4EB;
    --mqf-bg-card:       #FFFFFF;
    --mqf-bg-input:      #FFFFFF;
    --mqf-bg-hover:      #f1ece0;
    --mqf-bg-active:     rgba(234,88,12,0.08);
    --mqf-bg-dark:       #FFFFFF;
    --mqf-bg-elevated:   #FFFFFF;

    /* Acento */
    --mqf-color-acento:       #EA580C;
    --mqf-color-acento-text:  #FFFFFF;
    --mqf-color-acento-hover: #c2440a;
    --mqf-color-acento-sub:   #0F2C59;

    /* Estados */
    --mqf-color-success: #16a34a;
    --mqf-color-error:   #dc2626;
    --mqf-color-warning: #d97706;
    --mqf-color-info:    #0F2C59;
    --mqf-color-neutral: #6b7280;

    /* Texto */
    --mqf-text-primary:   #1F2937;
    --mqf-text-secondary: #57534e;
    --mqf-text-muted:     #9ca3af;
    --mqf-text-disabled:  #d1d5db;
    --mqf-text:           #1F2937;

    /* Bordes */
    --mqf-border-subtle:   #e5e7eb;
    --mqf-border-default:  #cbd5e1;
    --mqf-border-strong:   #94a3b8;
    --mqf-border:          #cbd5e1;

    /* Sidebar */
    --mqf-sidebar-text:        rgba(255,255,255,0.75);
    --mqf-sidebar-text-active: #FFFFFF;
    --mqf-sidebar-section:     rgba(255,255,255,0.35);
    --mqf-sidebar-border-active: #EA580C;

    /* Tablas */
    --mqf-table-head:      #0F2C59;
    --mqf-table-row-hover: rgba(234,88,12,0.04);
    --mqf-table-border:    #e5e7eb;

    /* Radii (mantener) */
    --mqf-radius-sm:  4px;
    --mqf-radius-md:  6px;
    --mqf-radius-lg:  8px;
    --mqf-radius-pill: 999px;

    /* Legacy aliases */
    --mqf-primary:     #EA580C;
    --mqf-accent:      #EA580C;
    --mqf-card-bg:     #FFFFFF;
    --mqf-input-bg:    #FFFFFF;

    /* Common inline fallbacks override */
    --primary:         #EA580C;
    --primary-light:   rgba(234, 88, 12, 0.15);
    --bg-main:         #F8F4EB;
    --bg-card:         #FFFFFF;
    --bg-dark:         #FFFFFF;
    --bg-muted:        #f9fafb;
    --border:          #cbd5e1;
    --border-light:    #e5e7eb;
    --text-color:      #1F2937;
    --text-primary:    #1F2937;
    --text-secondary:  #57534e;
    --text-muted:      #6b7280;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body.iv-body {
    margin: 0;
    padding: 0;
    font-family: var(--iv-font-body);
    font-size: 14px;
    background: var(--iv-stone);
    color: var(--iv-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--iv-font-title);
    font-weight: 800;
    color: var(--iv-navy);
    margin: 0 0 12px;
    line-height: 1.2;
}

a {
    color: var(--iv-orange);
    text-decoration: none;
    transition: var(--iv-transition);
}
a:hover { color: var(--iv-orange-hover); }

p { margin: 0 0 12px; }
ul, ol { padding-left: 20px; }

/* ============================================================
   LAYOUT — SHELL (sidebar + topbar + content)
   ============================================================ */
.iv-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.iv-sidebar,
#sidebar {
    width: var(--iv-sidebar-width);
    height: 100vh;
    background: var(--iv-navy);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.iv-sidebar-logo,
.iv-sidebar .logo-area {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.iv-logo-svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.iv-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.iv-logo-infinity {
    font-family: var(--iv-font-title);
    font-weight: 800;
    font-size: 15px;
    color: var(--iv-white);
    letter-spacing: 1px;
}

.iv-logo-view {
    font-family: var(--iv-font-title);
    font-weight: 300;
    font-size: 15px;
    color: var(--iv-orange);
    letter-spacing: 3px;
}

.iv-sidebar-nav {
    padding: 16px 0;
    flex: 1;
}

.iv-sidebar-section-label {
    font-family: var(--iv-font-body);
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 12px 20px 4px;
}

.iv-sidebar-link,
.iv-sidebar a.nav-link,
.iv-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.75);
    font-family: var(--iv-font-body);
    font-size: 13.5px;
    font-weight: 400;
    text-decoration: none;
    transition: var(--iv-transition);
    border-left: 3px solid transparent;
}

.iv-sidebar-link:hover,
.iv-sidebar a.nav-link:hover,
.iv-sidebar .nav-link:hover {
    background: var(--iv-navy-light);
    color: var(--iv-white);
    border-left-color: transparent;
}

.iv-sidebar-link.active,
.iv-sidebar a.nav-link.active,
.iv-sidebar .nav-link.active,
.iv-sidebar-link.iv-active {
    background: var(--iv-navy-light);
    color: var(--iv-white);
    border-left: 3px solid var(--iv-orange);
    font-weight: 600;
}

.iv-sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 20px;
}

/* --- Topbar --- */
.iv-topbar,
#topbar,
.top-bar {
    position: fixed;
    top: 0;
    left: var(--iv-sidebar-width);
    right: 0;
    height: var(--iv-topbar-height);
    background: var(--iv-white);
    border-bottom: 2px solid var(--iv-orange);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 90;
    gap: 16px;
}

.iv-topbar-title {
    font-family: var(--iv-font-title);
    font-weight: 800;
    font-size: 18px;
    color: var(--iv-navy);
    flex: 1;
}

.iv-topbar-user {
    font-family: var(--iv-font-body);
    font-size: 13px;
    color: var(--iv-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Main content --- */
.iv-main,
#main-content,
.main-content {
    margin-left: var(--iv-sidebar-width);
    margin-top: var(--iv-topbar-height);
    min-height: calc(100vh - var(--iv-topbar-height));
    background: var(--iv-stone);
    padding: 24px;
    flex: 1;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-iv-primary,
.iv-btn,
.iv-btn-primary {
    background: var(--iv-orange);
    color: var(--iv-white);
    border: none;
    padding: 10px 24px;
    border-radius: var(--iv-radius);
    font-family: var(--iv-font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--iv-transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    line-height: 1.4;
}

.btn-iv-primary:hover,
.iv-btn:hover,
.iv-btn-primary:hover {
    background: var(--iv-orange-hover);
    color: var(--iv-white);
}

.btn-iv-secondary,
.iv-btn-secondary {
    background: transparent;
    border: 2px solid var(--iv-navy);
    color: var(--iv-navy);
    padding: 9px 24px;
    border-radius: var(--iv-radius);
    font-family: var(--iv-font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--iv-transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    line-height: 1.4;
}

.btn-iv-secondary:hover,
.iv-btn-secondary:hover {
    background: var(--iv-navy);
    color: var(--iv-white);
}

.btn-iv-ghost {
    background: transparent;
    border: 1px solid rgba(15, 44, 89, 0.2);
    color: var(--iv-dark);
    padding: 8px 16px;
    border-radius: var(--iv-radius);
    font-family: var(--iv-font-body);
    font-size: 13px;
    cursor: pointer;
    transition: var(--iv-transition);
}

.btn-iv-ghost:hover {
    border-color: var(--iv-navy);
    color: var(--iv-navy);
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.iv-card {
    background: var(--iv-white);
    border-left: 4px solid var(--iv-orange);
    border-radius: var(--iv-radius);
    padding: 20px 24px;
    box-shadow: var(--iv-shadow);
    margin-bottom: 16px;
}

.iv-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(15, 44, 89, 0.08);
}

.iv-card-plain {
    background: var(--iv-white);
    border-radius: var(--iv-radius);
    padding: 20px 24px;
    box-shadow: var(--iv-shadow);
    margin-bottom: 16px;
}

.iv-stat-card {
    background: var(--iv-white);
    border-radius: var(--iv-radius);
    padding: 20px;
    box-shadow: var(--iv-shadow);
    border-top: 3px solid var(--iv-orange);
}

.iv-stat-value {
    font-family: var(--iv-font-title);
    font-size: 32px;
    font-weight: 800;
    color: var(--iv-navy);
    line-height: 1;
}

.iv-stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ============================================================
   SECTION TITLES
   ============================================================ */
.iv-section-title,
.section-title {
    font-family: var(--iv-font-title);
    font-weight: 800;
    font-size: 20px;
    color: var(--iv-navy);
    border-bottom: 2px solid var(--iv-orange);
    padding-bottom: 8px;
    margin-bottom: 20px;
}

.iv-page-title {
    font-family: var(--iv-font-title);
    font-weight: 800;
    font-size: 26px;
    color: var(--iv-navy);
    margin-bottom: 4px;
}

.iv-page-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 24px;
}

/* ============================================================
   TABLES
   ============================================================ */
table.iv-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--iv-font-body);
    font-size: 13.5px;
}

table.iv-table thead tr {
    background: var(--iv-navy);
    color: var(--iv-white);
}

table.iv-table thead th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

table.iv-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(15, 44, 89, 0.06);
    vertical-align: middle;
}

table.iv-table tbody tr:nth-child(even) {
    background: var(--iv-stone);
}

table.iv-table tbody tr:hover {
    background: rgba(234, 88, 12, 0.04);
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.iv-form-group {
    margin-bottom: 16px;
}

.iv-form-group label,
.iv-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--iv-navy);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

input.iv-input,
select.iv-select,
textarea.iv-textarea,
.iv-form-group input,
.iv-form-group select,
.iv-form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: var(--iv-radius);
    font-family: var(--iv-font-body);
    font-size: 14px;
    color: var(--iv-dark);
    background: var(--iv-white);
    transition: var(--iv-transition);
}

input.iv-input:focus,
select.iv-select:focus,
textarea.iv-textarea:focus,
.iv-form-group input:focus,
.iv-form-group select:focus,
.iv-form-group textarea:focus {
    border-color: var(--iv-orange);
    outline: none;
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

/* ============================================================
   BADGES & TAGS
   ============================================================ */
.iv-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--iv-font-body);
    white-space: nowrap;
}

.iv-badge-orange { background: var(--iv-orange); color: var(--iv-white); }
.iv-badge-navy   { background: var(--iv-navy); color: var(--iv-white); }
.iv-badge-green  { background: #16a34a; color: var(--iv-white); }
.iv-badge-gray   { background: #e5e7eb; color: #374151; }
.iv-badge-red    { background: #dc2626; color: var(--iv-white); }
.iv-badge-amber  { background: #d97706; color: var(--iv-white); }

/* ============================================================
   ALERTS
   ============================================================ */
.iv-alert {
    padding: 12px 16px;
    border-radius: var(--iv-radius);
    font-size: 13.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.iv-alert-success {
    border-left: 4px solid #16a34a;
    background: #f0fdf4;
    color: #166534;
}

.iv-alert-error {
    border-left: 4px solid var(--iv-orange);
    background: #fff7ed;
    color: #9a3412;
}

.iv-alert-info {
    border-left: 4px solid var(--iv-navy);
    background: #eff6ff;
    color: var(--iv-navy);
}

.iv-alert-warning {
    border-left: 4px solid #d97706;
    background: #fffbeb;
    color: #92400e;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
body.iv-login-page {
    font-family: var(--iv-font-body);
    background: var(--iv-navy);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

.iv-login-card {
    background: var(--iv-white);
    border-radius: 8px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.iv-login-logo {
    text-align: center;
    margin-bottom: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.iv-login-logo svg {
    margin-bottom: 8px;
}

.iv-login-logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 4px;
}

.iv-login-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.iv-login-infinity {
    font-family: var(--iv-font-title);
    font-weight: 800;
    font-size: 22px;
    color: var(--iv-navy);
    letter-spacing: 1px;
}

.iv-login-view {
    font-family: var(--iv-font-title);
    font-weight: 300;
    font-size: 22px;
    color: var(--iv-orange);
    letter-spacing: 4px;
}

.iv-login-subtitle {
    font-family: var(--iv-font-body);
    font-size: 12px;
    color: #9ca3af;
    font-weight: 400;
    margin-top: 8px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.iv-login-card .iv-form-group label {
    font-size: 11px;
    color: #6b7280;
    letter-spacing: 1px;
}

.iv-login-card input {
    background: #f9fafb;
    border-color: #e5e7eb;
    font-size: 14px;
    padding: 12px 14px;
}

.iv-login-card input:focus {
    border-color: var(--iv-orange);
    background: var(--iv-white);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
}

.iv-login-btn {
    width: 100%;
    padding: 13px;
    background: var(--iv-orange);
    color: var(--iv-white);
    border: none;
    border-radius: var(--iv-radius);
    font-family: var(--iv-font-title);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: var(--iv-transition);
    margin-top: 8px;
}

.iv-login-btn:hover { background: var(--iv-orange-hover); }

.iv-login-footer {
    text-align: center;
    margin-top: 32px;
    font-size: 11px;
    color: #9ca3af;
    font-family: var(--iv-font-body);
    letter-spacing: 0.5px;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.iv-text-navy   { color: var(--iv-navy); }
.iv-text-orange { color: var(--iv-orange); }
.iv-text-muted  { color: #6b7280; font-size: 12px; }
.iv-text-center { text-align: center; }
.iv-text-right  { text-align: right; }
.iv-fw-bold     { font-weight: 800; font-family: var(--iv-font-title); }
.iv-mt-0  { margin-top: 0; }
.iv-mt-8  { margin-top: 8px; }
.iv-mt-16 { margin-top: 16px; }
.iv-mt-24 { margin-top: 24px; }
.iv-mb-0  { margin-bottom: 0; }
.iv-mb-8  { margin-bottom: 8px; }
.iv-mb-16 { margin-bottom: 16px; }
.iv-mb-24 { margin-bottom: 24px; }
.iv-flex  { display: flex; align-items: center; gap: 8px; }
.iv-flex-between { display: flex; align-items: center; justify-content: space-between; }
.iv-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.iv-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.iv-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .iv-sidebar,
    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .iv-sidebar.open,
    #sidebar.open {
        transform: translateX(0);
    }

    .iv-topbar,
    #topbar,
    .top-bar {
        left: 0;
    }

    .iv-main,
    #main-content,
    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .iv-grid-2,
    .iv-grid-3,
    .iv-grid-4 {
        grid-template-columns: 1fr;
    }

    .iv-topbar-hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--iv-navy);
        font-size: 20px;
    }
}

@media (min-width: 769px) {
    .iv-topbar-hamburger { display: none; }
}

/* ============================================================
   MQF COMPATIBILITY — Override mqf-* classes with IV brand
   Ensures pages using mqf-sidebar-*, mqf-topbar-*, mqf-content
   render with Infinity View brand colors instead of dark theme.
   ============================================================ */

/* Layout */
.mqf-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.mqf-sidebar {
    height: 100vh;
    width: var(--iv-sidebar-width);
    
    background: var(--iv-navy) !important;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.mqf-sidebar-brand {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.mqf-sidebar-section { padding: 0; }

.mqf-sidebar-group {
    padding: 16px 20px 4px;
}

.mqf-sidebar-group .mqf-sidebar-label {
    font-family: var(--iv-font-body);
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.35) !important;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.mqf-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,0.75) !important;
    font-family: var(--iv-font-body);
    font-size: 13.5px;
    text-decoration: none;
    transition: var(--iv-transition);
    border-left: 3px solid transparent;
}

.mqf-sidebar-link:hover {
    background: var(--iv-navy-light) !important;
    color: #fff !important;
}

.mqf-sidebar-link.mqf-active,
.mqf-sidebar-link.active {
    background: var(--iv-navy-light) !important;
    color: #fff !important;
    border-left: 3px solid var(--iv-orange);
    font-weight: 600;
}

.mqf-sidebar-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.mqf-sidebar-label {
    font-size: 13.5px;
}

.mqf-sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.08) !important;
    margin: 8px 20px;
}

/* Topbar */
.mqf-topbar {
    position: fixed;
    top: 0;
    left: var(--iv-sidebar-width);
    right: 0;
    height: var(--iv-topbar-height);
    background: var(--iv-white) !important;
    border-bottom: 2px solid var(--iv-orange) !important;
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 90;
    gap: 12px;
}

.mqf-topbar-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--iv-navy);
    padding: 4px 8px;
}

.mqf-topbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.mqf-topbar-title-text {
    font-family: var(--iv-font-title);
    font-weight: 800;
    font-size: 18px;
    color: var(--iv-navy) !important;
}

.mqf-topbar-collapse-btn {
    background: none;
    border: none;
    color: var(--iv-navy);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
}

/* Main content */
.mqf-main {
    margin-left: var(--iv-sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.mqf-content {
    margin-top: var(--iv-topbar-height);
    padding: 24px;
    background: var(--iv-stone) !important;
    min-height: calc(100vh - var(--iv-topbar-height));
    color: var(--iv-dark) !important;
}

/* Cards & Panels in content area */
.mqf-content .card,
.mqf-content .panel,
.mqf-content [class*="card"] {
    background: var(--iv-white) !important;
    border: none !important;
    border-left: 4px solid var(--iv-orange) !important;
    border-radius: var(--iv-radius);
    box-shadow: var(--iv-shadow);
    color: var(--iv-dark) !important;
}

/* Stat cards */
.mqf-content .stat-card,
.mqf-content .dashboard-stat {
    background: var(--iv-white) !important;
    border-top: 3px solid var(--iv-orange) !important;
    border-left: none !important;
}

/* Tables */
.mqf-content table thead,
.mqf-content table thead tr {
    background: var(--iv-navy) !important;
    color: var(--iv-white) !important;
}

.mqf-content table thead th {
    color: var(--iv-white) !important;
    font-family: var(--iv-font-body);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 14px;
}

.mqf-content table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(15,44,89,0.06) !important;
    color: var(--iv-dark) !important;
    background: transparent !important;
}

.mqf-content table tbody tr:nth-child(even) {
    background: var(--iv-stone) !important;
}

.mqf-content table tbody tr:hover {
    background: rgba(234,88,12,0.04) !important;
}

/* Headings in content */
.mqf-content h1, .mqf-content h2, .mqf-content h3,
.mqf-content h4, .mqf-content h5, .mqf-content h6 {
    font-family: var(--iv-font-title);
    color: var(--iv-navy) !important;
}

/* Buttons */
.mqf-content .btn-primary,
.mqf-content .btn-success,
.mqf-content button[type="submit"] {
    background: var(--iv-orange) !important;
    border-color: var(--iv-orange) !important;
    color: var(--iv-white) !important;
}

.mqf-content .btn-primary:hover,
.mqf-content .btn-success:hover {
    background: var(--iv-orange-hover) !important;
}

.mqf-content .btn-secondary,
.mqf-content .btn-outline {
    background: transparent !important;
    border: 2px solid var(--iv-navy) !important;
    color: var(--iv-navy) !important;
}

/* Badges */
.mqf-content .badge,
.mqf-content [class*="badge"] {
    font-family: var(--iv-font-body);
    font-weight: 600;
    font-size: 11px;
    border-radius: 12px;
}

/* Links */
.mqf-content a {
    color: var(--iv-orange);
}
.mqf-content a:hover {
    color: var(--iv-orange-hover);
}

/* Forms */
.mqf-content input,
.mqf-content select,
.mqf-content textarea {
    background: var(--iv-white) !important;
    border: 1px solid #cbd5e1 !important;
    color: var(--iv-dark) !important;
    font-family: var(--iv-font-body);
}

.mqf-content input:focus,
.mqf-content select:focus,
.mqf-content textarea:focus {
    border-color: var(--iv-orange) !important;
    box-shadow: 0 0 0 3px rgba(234,88,12,0.12) !important;
}

/* Responsive — sidebar collapse */
.mqf-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 44, 89, 0.4);
    backdrop-filter: blur(2px);
    z-index: 95;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.mqf-overlay.mqf-visible {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    .mqf-sidebar {
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }
    .mqf-sidebar.mqf-open,
    .mqf-sidebar.open { 
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(15, 44, 89, 0.3);
    }
    .mqf-topbar { left: 0 !important; }
    .mqf-main { margin-left: 0 !important; }
    .mqf-content { padding: 16px; padding-bottom: 84px; }
    .mqf-topbar-toggle { padding: 10px 14px; font-size: 22px; cursor: pointer; color: var(--iv-navy); }
}

/* Responsive Table Wrapper */
.mqf-table-wrap, .mqf-table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
    border-radius: var(--iv-radius);
}
.mqf-table-wrap table, .mqf-table-responsive table {
    min-width: 600px;
    margin-bottom: 0;
    border: none;
}

/* ============================================================
   NUCLEAR OVERRIDES — Kill all dark inline styles
   These target the most common inline dark color patterns found
   in page files (117+ instances). Using body.iv-body for high
   specificity plus !important to beat inline style="..." attrs.
   ============================================================ */
body.iv-body {
    background: #F8F4EB !important;
    color: #1F2937 !important;
}

body.iv-body .mqf-content,
body.iv-body .mqf-main,
body.iv-body main {
    background: #F8F4EB !important;
    color: #1F2937 !important;
}

/* Reset dark backgrounds on layout containers (not modals/cards) */
body.iv-body .mqf-content > section,
body.iv-body .mqf-content > article {
    background-color: transparent;
    color: #1F2937;
}

/* Cards — explicit white */
body.iv-body .mqf-content .card,
body.iv-body .mqf-content .panel,
body.iv-body .mqf-content .stat-card,
body.iv-body .mqf-content .dashboard-stat,
body.iv-body .mqf-content .dashboard-card,
body.iv-body .mqf-content .mqf-card,
body.iv-body .mqf-content [style*="background:var(--mqf-bg-card"],
body.iv-body .mqf-content [style*="background: var(--mqf-bg-card"],
body.iv-body .mqf-content [style*="background:#0f0"],
body.iv-body .mqf-content [style*="background: #0f0"],
body.iv-body .mqf-content [style*="background:#0d0"],
body.iv-body .mqf-content [style*="background:#1a1"],
body.iv-body .mqf-content [style*="background: #1a1"],
body.iv-body .mqf-content [style*="background:#111"] {
    background-color: #FFFFFF !important;
    border-color: #e5e7eb !important;
    color: #1F2937 !important;
}

/* Override gradient backgrounds */
body.iv-body .mqf-content [style*="linear-gradient"] {
    background: #FFFFFF !important;
}

/* All text should be dark */
body.iv-body .mqf-content span,
body.iv-body .mqf-content p,
body.iv-body .mqf-content label,
body.iv-body .mqf-content td,
body.iv-body .mqf-content th,
body.iv-body .mqf-content li,
body.iv-body .mqf-content dt,
body.iv-body .mqf-content dd {
    color: inherit;
}

/* Selects & inputs — never dark */
body.iv-body select,
body.iv-body select option,
body.iv-body .form-select,
body.iv-body .form-select option,
body.iv-body input[type="text"],
body.iv-body input[type="email"],
body.iv-body input[type="password"],
body.iv-body input[type="number"],
body.iv-body input[type="search"],
body.iv-body input[type="date"],
body.iv-body textarea {
    background-color: #FFFFFF !important;
    color: #1F2937 !important;
    border: 1px solid #cbd5e1 !important;
}

body.iv-body select:focus,
body.iv-body input:focus,
body.iv-body textarea:focus {
    border-color: #EA580C !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(234,88,12,0.12) !important;
}

/* Table headers navy, not dark */
body.iv-body table thead,
body.iv-body table thead tr,
body.iv-body table thead th {
    background: #0F2C59 !important;
    color: #FFFFFF !important;
}

body.iv-body table tbody td {
    background: transparent !important;
    color: #1F2937 !important;
    border-color: #e5e7eb !important;
}

body.iv-body table tbody tr:nth-child(even) td {
    background: #F8F4EB !important;
}

body.iv-body table tbody tr:hover td {
    background: rgba(234,88,12,0.04) !important;
}

/* Badges — keep readable */
body.iv-body .badge,
body.iv-body [class*="badge"] {
    border-radius: 12px;
    font-weight: 600;
}

/* Modal/overlay backgrounds */
body.iv-body .modal-content,
body.iv-body .modal-body,
body.iv-body .modal-header,
body.iv-body .modal-footer,
body.iv-body .modal-add-linea-content,
body.iv-body .modal-catalogo-content {
    background: #FFFFFF !important;
    color: #1F2937 !important;
    border-color: #e5e7eb !important;
}

body.iv-body .modal-backdrop,
body.iv-body .modal-add-linea {
    background: rgba(15,44,89,0.5) !important;
}

body.iv-body .modal-option-btn {
    background: #FFFFFF !important;
    border: 2px solid #cbd5e1 !important;
    color: #1F2937 !important;
}

body.iv-body .modal-option-btn:hover {
    border-color: #EA580C !important;
    box-shadow: 0 4px 12px rgba(15,44,89,0.1) !important;
}

body.iv-body .modal-option-btn svg {
    color: #EA580C !important;
}

body.iv-body .btn-cancel-modal {
    background: #0F2C59 !important;
    color: #FFFFFF !important;
}

body.iv-body .btn-cancel-modal:hover {
    background: #1a3d6e !important;
}

/* Toast/notification overrides */
body.iv-body .toast,
body.iv-body .notification {
    background: #FFFFFF !important;
    color: #1F2937 !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 4px 12px rgba(15,44,89,0.15) !important;
}

/* Sidebar — stays navy (don't override to light) */
body.iv-body .mqf-sidebar {
    height: 100vh;
    background: #0F2C59 !important;
}
body.iv-body .mqf-sidebar div,
body.iv-body .mqf-sidebar span,
body.iv-body .mqf-sidebar a {
    background-color: transparent !important;
    color: rgba(255,255,255,0.75);
}
body.iv-body .mqf-sidebar .mqf-sidebar-group .mqf-sidebar-label {
    color: rgba(255,255,255,0.35) !important;
}
body.iv-body .mqf-sidebar a.mqf-active,
body.iv-body .mqf-sidebar a.active {
    background: #1a3d6e !important;
    color: #FFFFFF !important;
}

/* Topbar white with orange border */
body.iv-body .mqf-topbar {
    background: #FFFFFF !important;
    border-bottom: 2px solid #EA580C !important;
}
body.iv-body .mqf-topbar * {
    color: #0F2C59 !important;
}

/* Headings */
body.iv-body h1, body.iv-body h2, body.iv-body h3,
body.iv-body h4, body.iv-body h5, body.iv-body h6 {
    color: #0F2C59 !important;
    font-family: 'Outfit', sans-serif;
}

/* Primary buttons → orange */
body.iv-body .btn-primary,
body.iv-body .btn-success,
body.iv-body [class*="btn-primary"],
body.iv-body button.btn-primary {
    background: #EA580C !important;
    border-color: #EA580C !important;
    color: #FFFFFF !important;
}
body.iv-body .btn-primary:hover {
    background: #c2440a !important;
}

/* Links */
body.iv-body .mqf-content a:not(.btn):not(.mqf-sidebar-link) {
    color: #EA580C;
}

/* Scrollbar for light theme */
body.iv-body ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
body.iv-body ::-webkit-scrollbar-track {
    background: #F8F4EB;
}
body.iv-body ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
body.iv-body ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================================
   MQF DASHBOARD & CARD COMPONENTS
   ============================================================ */

/* Stats grid */
.mqf-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.mqf-stat {
    background: #FFFFFF;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    border-top: 3px solid #EA580C;
}

.mqf-stat-accent {
    border-top-color: #0F2C59;
}

.mqf-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin-bottom: 4px;
}

.mqf-stat-value {
    font-family: var(--iv-font-title, 'Outfit', sans-serif);
    font-size: 28px;
    font-weight: 800;
    color: #0F2C59;
    line-height: 1.2;
}

.mqf-stat-sub {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

.mqf-text-success { color: #16a34a !important; }
.mqf-text-warning { color: #d97706 !important; }
.mqf-text-danger  { color: #dc2626 !important; }

/* Cards */
.mqf-card {
    background: #FFFFFF;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    border-left: 4px solid #EA580C;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(15, 44, 89, 0.06);
}

.mqf-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mqf-card-title {
    font-family: var(--iv-font-title, 'Outfit', sans-serif);
    font-weight: 800;
    font-size: 18px;
    color: #0F2C59;
    margin: 0;
}

.mqf-card-body {
    padding: 16px 20px;
}

/* Sidebar scroll fix */
.mqf-sidebar {
    height: 100vh;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Fix: links used as buttons must have white text, not orange */
a.btn-ver, a.btn-primary, a.btn-save, a.iv-btn, a.iv-btn-primary,
a.btn-sm[class*="btn-ver"] {
    color: #FFFFFF !important;
}
a.btn-ver:hover, a.btn-primary:hover {
    color: #FFFFFF !important;
}

/* ================================================================
   iv-modal-overlay — Modal global para pantallas admin
   El JS usa element.style.display = 'flex' para abrir
   ================================================================ */
.iv-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* Cuando el JS pone display:flex inline, garantizar posicionamiento */
.iv-modal-overlay[style*="display: flex"],
.iv-modal-overlay[style*="display:flex"] {
    display: flex !important;
    position: fixed !important;
}

.iv-modal {
    border-radius: 8px;
    max-height: 90vh;
    overflow-y: auto;
    animation: iv-modal-slide-in 0.2s ease-out;
    /* El background, max-width y box-shadow los pone cada pantalla inline */
}

@keyframes iv-modal-slide-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
