/* Material Design 3 - NexoTaller Theme */
@import 'theme.css';

/* Standard Mobile Viewport Fix (DVH) */
.mobile-viewport-fix {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Global Touch Target Standardization (Apple/Google Recommendation) */
.touch-safe-target {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Reset & Base --- */

/* --- Reset & Base --- */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font: var(--md-sys-typescale-body-large);
    -webkit-tap-highlight-color: transparent;
    /* Clean touch feedback on mobile */
    text-rendering: optimizeLegibility;

    /* --- Premium Theme Variables (Glassmorphism) --- */
    --glass-bg: var(--premium-glass-bg);
    --glass-border: var(--premium-glass-border);
    --glass-shadow: var(--premium-glass-shadow);
    --glass-blur: var(--premium-blur);

    --gradient-primary: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    --gradient-accent: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);

    /* Vibrant Mesh Gradient Background (Fallback logic) */
    --bg-mesh: var(--theme-body-image);

    background-color: var(--theme-body-bg);
    background-image: var(--theme-body-image);

    color: var(--md-sys-color-on-background);
    height: 100vh;
    overflow: hidden;
}

/* --- Premium Utilities --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
}

.premium-shadow {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.premium-gradient-text {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

/* =========================================================
   Tailwind Gradient Utilities — ONLY classes missing from output.css
   Uses --tw-gradient-stops for compatibility with compiled Tailwind
   ========================================================= */

/* from-* stops NOT in output.css */
.from-violet-500   { --tw-gradient-from: #a020f0 var(--tw-gradient-from-position); --tw-gradient-to: rgba(160, 32, 240,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-violet-600   { --tw-gradient-from: #c040ff var(--tw-gradient-from-position); --tw-gradient-to: rgba(192, 64, 255,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-indigo-600   { --tw-gradient-from: #4f46e5 var(--tw-gradient-from-position); --tw-gradient-to: rgba(79,70,229,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-indigo-900   { --tw-gradient-from: #312e81 var(--tw-gradient-from-position); --tw-gradient-to: rgba(49,46,129,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-sky-500      { --tw-gradient-from: #0ea5e9 var(--tw-gradient-from-position); --tw-gradient-to: rgba(14,165,233,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-cyan-400     { --tw-gradient-from: #22d3ee var(--tw-gradient-from-position); --tw-gradient-to: rgba(34,211,238,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-teal-500     { --tw-gradient-from: #14b8a6 var(--tw-gradient-from-position); --tw-gradient-to: rgba(20,184,166,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-rose-500     { --tw-gradient-from: #f43f5e var(--tw-gradient-from-position); --tw-gradient-to: rgba(244,63,94,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }

/* from-* with opacity NOT in output.css */
.from-violet-600\/20 { --tw-gradient-from: rgba(192, 64, 255,0.2) var(--tw-gradient-from-position); --tw-gradient-to: rgba(192, 64, 255,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-violet-600\/10 { --tw-gradient-from: rgba(192, 64, 255,0.1) var(--tw-gradient-from-position); --tw-gradient-to: rgba(192, 64, 255,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-purple-600\/20 { --tw-gradient-from: rgba(147,51,234,0.2) var(--tw-gradient-from-position); --tw-gradient-to: rgba(147,51,234,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-indigo-600\/20 { --tw-gradient-from: rgba(79,70,229,0.2) var(--tw-gradient-from-position); --tw-gradient-to: rgba(79,70,229,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.from-indigo-900\/40 { --tw-gradient-from: rgba(49,46,129,0.4) var(--tw-gradient-from-position); --tw-gradient-to: rgba(49,46,129,0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }

/* to-* stops NOT in output.css */
.to-violet-600     { --tw-gradient-to: #c040ff var(--tw-gradient-to-position); }
.to-purple-600     { --tw-gradient-to: #9333ea var(--tw-gradient-to-position); }
.to-sky-600        { --tw-gradient-to: #0284c7 var(--tw-gradient-to-position); }
.to-amber-600      { --tw-gradient-to: #d97706 var(--tw-gradient-to-position); }
.to-blue-700       { --tw-gradient-to: #1d4ed8 var(--tw-gradient-to-position); }

/* to-* with opacity NOT in output.css */
.to-indigo-600\/10 { --tw-gradient-to: rgba(79,70,229,0.1) var(--tw-gradient-to-position); }
.to-violet-600\/10 { --tw-gradient-to: rgba(192, 64, 255,0.1) var(--tw-gradient-to-position); }

/* Shadow color utilities NOT in output.css */
.shadow-violet-500\/20  { --tw-shadow-color: rgba(160, 32, 240,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-indigo-500\/20  { --tw-shadow-color: rgba(99,102,241,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-purple-500\/20  { --tw-shadow-color: rgba(160, 32, 240,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-purple-500\/40  { --tw-shadow-color: rgba(160, 32, 240,0.4); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-sky-500\/20     { --tw-shadow-color: rgba(14,165,233,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-sky-500\/40     { --tw-shadow-color: rgba(14,165,233,0.4); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-cyan-500\/20    { --tw-shadow-color: rgba(6,182,212,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-cyan-500\/25    { --tw-shadow-color: rgba(6,182,212,0.25); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-cyan-500\/30    { --tw-shadow-color: rgba(6,182,212,0.3); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-cyan-500\/40    { --tw-shadow-color: rgba(6,182,212,0.4); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-amber-500\/20   { --tw-shadow-color: rgba(245,158,11,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-emerald-500\/20 { --tw-shadow-color: rgba(16,185,129,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-green-500\/20   { --tw-shadow-color: rgba(34,197,94,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-teal-500\/20    { --tw-shadow-color: rgba(20,184,166,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }
.shadow-rose-500\/20    { --tw-shadow-color: rgba(244,63,94,0.2); box-shadow: 0 10px 15px -3px var(--tw-shadow-color); }

/* Primary gradient button — replaces from-[var(--md-sys-color-primary)] */
.nx-gradient-primary {
    background-image: linear-gradient(to right, #c040ff, #4f46e5);
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(192, 64, 255, 0.2);
}
.nx-gradient-primary:hover {
    box-shadow: 0 10px 15px -3px rgba(192, 64, 255, 0.4);
}

/* Icon badge gradients — direct background, no Tailwind variable chain */
.nx-badge-indigo  { background-image: linear-gradient(to bottom right, #6366f1, #4f46e5); color: #fff; box-shadow: 0 10px 15px -3px rgba(99,102,241,0.2); }
.nx-badge-sky     { background-image: linear-gradient(to bottom right, #0ea5e9, #0284c7); color: #fff; box-shadow: 0 10px 15px -3px rgba(14,165,233,0.2); }
.nx-badge-amber   { background-image: linear-gradient(to bottom right, #f59e0b, #d97706); color: #fff; box-shadow: 0 10px 15px -3px rgba(245,158,11,0.2); }
.nx-badge-emerald { background-image: linear-gradient(to bottom right, #10b981, #059669); color: #fff; box-shadow: 0 10px 15px -3px rgba(16,185,129,0.2); }
.nx-badge-green   { background-image: linear-gradient(to bottom right, #22c55e, #16a34a); color: #fff; box-shadow: 0 10px 15px -3px rgba(34,197,94,0.2); }
.nx-badge-cyan    { background-image: linear-gradient(to bottom right, #06b6d4, #0891b2); color: #fff; box-shadow: 0 10px 15px -3px rgba(6,182,212,0.2); }
.nx-badge-purple  { background-image: linear-gradient(to bottom right, #a020f0, #9333ea); color: #fff; box-shadow: 0 10px 15px -3px rgba(160, 32, 240,0.2); }
.nx-badge-violet  { background-image: linear-gradient(to bottom right, #a020f0, #4f46e5); color: #fff; box-shadow: 0 10px 15px -3px rgba(160, 32, 240,0.2); }
.nx-badge-teal    { background-image: linear-gradient(to bottom right, #14b8a6, #0d9488); color: #fff; box-shadow: 0 10px 15px -3px rgba(20,184,166,0.2); }
.nx-badge-rose    { background-image: linear-gradient(to bottom right, #f43f5e, #e11d48); color: #fff; box-shadow: 0 10px 15px -3px rgba(244,63,94,0.2); }

/* New Animation Utilities */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-enter {
    animation: fadeInScale 0.4s ease-out forwards;
}

/* --- Premium Design System 2.0 (Nexo Violet) --- */
.premium-glass {
    background: var(--premium-glass-bg);
    backdrop-filter: var(--premium-blur);
    -webkit-backdrop-filter: var(--premium-blur);
    border: var(--premium-glass-border);
    box-shadow: var(--premium-glass-shadow);
    border-radius: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-glass:hover {
    border-color: rgba(160, 32, 240, 0.4);
    box-shadow: 0 20px 25px -5px rgba(160, 32, 240, 0.1), 0 8px 10px -6px rgba(160, 32, 240, 0.1);
    transform: translateY(-2px);
}

.metric-card {
    padding: 1.5rem !important; /* Forces p-6 consistency */
    display: flex;
    flex-direction: column;
    min-height: 140px;
    background: var(--premium-glass-bg);
}

.text-premium-label {
    font-size: 0.625rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    background: var(--premium-text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bg-premium-accent {
    background: var(--premium-accent-gradient);
}

/* --- Header UX Optimization Patterns --- */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
}

.breadcrumb-item {
    transition: color 0.2s ease;
}

.breadcrumb-item:hover {
    color: var(--accent-violet);
}

.breadcrumb-separator {
    opacity: 0.3;
}

/* --- Robust Header Breakpoints --- */
.mobile-header { display: flex !important; }
.desktop-header { display: none !important; }

@media (min-width: 768px) {
    .mobile-header { display: none !important; }
    .desktop-header { display: flex !important; }
}

/* --- Sucursal Selector Styles --- */
.sucursal-select-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: var(--search-input-bg);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 12px;
    height: 36px;
    transition: all 0.2s ease;
}

.sucursal-select-container:hover {
    border-color: var(--accent-violet);
}

.sucursal-select-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--sucursal-bg);
    border: 1px solid var(--sucursal-border);
    padding: 6px 12px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.sucursal-select {
    background: transparent !important;
    border: none !important;
    color: var(--sucursal-text) !important;
    font-size: 0.75rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    appearance: none;
    padding: 0;
}

.search-bar-container {
    position: relative;
    width: 100%;
    max-width: 450px;
    margin: 0 2rem;
}

.nx-glass-field {
    padding: 0.625rem 0.875rem;
    background: rgba(var(--md-sys-color-surface-variant-rgb), 0.1);
    border: 1px solid rgba(var(--md-sys-color-outline-rgb), 0.2);
    border-radius: 0.75rem;
    color: var(--md-sys-color-on-surface);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

.nx-glass-field.pl-icon {
    padding-left: 3rem !important;
}

.search-input {
    width: 100%;
    height: 44px;
    padding: 0 1rem 0 2.75rem;
    background: var(--search-input-bg) !important;
    border: 1px solid var(--search-input-border) !important;
    border-radius: 14px;
    color: var(--md-sys-color-on-surface);
    font-size: 0.875rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
    background: var(--md-sys-color-surface);
    border-color: var(--accent-violet);
    box-shadow: 0 0 15px rgba(160, 32, 240, 0.15);
    outline: none;
}

.search-shortcut {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 2px 6px;
    background: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    color: var(--md-sys-color-on-surface-variant);
    pointer-events: none;
}

.action-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border: 2px solid var(--md-sys-color-surface);
    border-radius: 50%;
}

/* --- Hub Utility Buttons --- */
.hub-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hub-button-bg);
    border: var(--hub-button-border);
    border-radius: 12px;
    color: var(--hub-icon-color);
    transition: all 0.2s ease;
}

.hub-btn:hover {
    background: var(--md-sys-color-surface-variant);
    transform: translateY(-2px);
}

.hub-btn i {
    font-size: 1.1rem;
}


/* --- App Shell (Grid Layout) --- */
#app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 64px 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    height: 100vh;
}

.main-content {
    /* margin-left removed - flex layout handles spacing */
    height: 100vh;
    overflow-y: auto;
    background-color: var(--md-sys-color-background);
}


/* --- Navigation Drawer (Sidebar) --- */
/* Phase 50: Sidebar styles now handled by sidebar.js component */
#sidebar {
    grid-area: sidebar;
    /* Reset old styles - new component uses Tailwind */
    background: transparent;
    padding: 0;
    border: none;
    overflow: visible;
    height: 100%;
}

/* New sidebar component styles */
crm-sidebar {
    display: block;
    height: 100%;
    width: fit-content;
}

crm-sidebar aside {
    /* Ensure proper positioning */
    position: relative;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 16px 24px;
    /* MD3 Spec */
    color: var(--md-sys-color-primary);
    font: var(--md-sys-typescale-title-large);
    margin-bottom: 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    height: 56px;
    /* MD3 Spec */
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: none;
    margin-bottom: 4px;
    transition: background-color 0.2s, color 0.2s;
    font: var(--md-sys-typescale-label-large);
}

.nav-link:hover {
    background-color: rgba(29, 27, 32, 0.08);
    /* State Layer */
    color: var(--md-sys-color-on-surface);
}

.nav-link.active {
    background-color: rgba(160, 32, 240, 0.15);
    color: var(--accent-violet);
    font-weight: 700;
}

.nav-link .material-icons {
    font-size: 28px;
}

/* --- Top App Bar (Header) - Theme-Aware --- */
#header {
    grid-area: header;
    background-color: var(--nx-header-bg, var(--md-sys-color-surface));
    border-bottom: 1px solid var(--nx-header-border, var(--md-sys-color-outline-variant));
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    color: var(--md-sys-color-on-surface);
    height: var(--nx-header-height, 64px);
}

crm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: var(--nx-header-height, 64px);
    flex-shrink: 0;
    background: transparent;
}

/* Hamburger button: visible on mobile, hidden on desktop (≥1024px) */
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 1024px) {
    .hamburger-btn {
        display: none !important;
    }
}

/* Hidden on mobile, visible on desktop (≥1024px) */
.hidden-mobile {
    display: none !important;
}

@media (min-width: 1024px) {
    .hidden-mobile {
        display: block !important;
    }
}

.header-title {
    font-family: var(--nx-font-heading, 'Sora', sans-serif);
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface);
}

/* --- Main Content Area - NexoTaller Dark Theme --- */
#main-content {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
    background-color: var(--md-sys-color-background);
}

/* --- Abyssal Background (Centralized) --- */
/* Premium background for main content area — used across all modules */
/* 3-Layer Dark Mode System:
   Layer 0 (base): #0f172a — sidebar, header, content bg (this class)
   Layer 1 (cards): rgba(30, 41, 59, 0.7) — elevated panels, kanban cards
   Layer 2 (modals): linear-gradient(145deg, #1e293b, #0f172a) — overlays */
.abyssal-bg {
    background: var(--md-sys-color-background) !important;
}

[data-theme="dark"] .abyssal-bg {
    background: #0f172a !important;
}

/* --- Cards --- */
.card {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 24px;
    box-shadow: var(--md-sys-elevation-1);
    transition: box-shadow 0.2s;
    border: 1px solid var(--md-sys-color-outline-variant);
    /* Optional for better contrast */
}

.card:hover {
    box-shadow: var(--md-sys-elevation-2);
}

/* --- Buttons --- */
button,
.btn-primary, .nx-btn-primary,
.btn-secondary, .nx-btn-ghost,
.btn-danger, .nx-btn-danger-outline,
.btn-text,
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px; /* Touch-Safe Target para Móviles */
    padding: 0 24px;
    border-radius: var(--md-sys-shape-corner-full);
    font: var(--md-sys-typescale-label-large);
    cursor: pointer;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    user-select: none;
}

/* Filled Button (Primary) */
.btn-primary, .nx-btn-primary {
    background: linear-gradient(135deg, #3B82F6, #A020F0);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(160, 32, 240, 0.3);
}

.btn-primary:hover, .nx-btn-primary:hover {
    box-shadow: var(--md-sys-color-ai-glow);
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-primary:active, .nx-btn-primary:active {
    filter: brightness(0.9);
    transform: translateY(1px);
}

/* Outlined Button (Secondary) */
.btn-secondary, .nx-btn-ghost,
button.secondary {
    background-color: transparent;
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-on-surface); /* Neutral */
}

.btn-secondary:hover, .nx-btn-ghost:hover,
button.secondary:hover {
    background-color: var(--md-sys-color-surface-variant);
    border-color: var(--md-sys-color-on-surface-variant);
}

/* Danger Button */
.btn-danger, .nx-btn-danger-outline {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    border: none;
}

.btn-danger:hover, .nx-btn-danger-outline:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 12px rgba(255, 61, 113, 0.3);
}

/* Text Button */
.btn-text {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    padding: 0 16px;
}

.btn-text:hover {
    background-color: var(--md-sys-color-surface-variant);
}

/* Icon Button */
.btn-icon {
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background-color: transparent;
    color: var(--md-sys-color-on-surface-variant);
}

.btn-icon:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
}

/* --- Inputs (Text Fields) --- */
/* Hide Spin Buttons */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* --- Inputs (Text Fields - Floating Label) --- */
.input-group {
    position: relative;
    margin-bottom: 24px;
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    height: 56px;
    padding: 24px 16px 8px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    /* MD3 Extra Small */
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font: var(--md-sys-typescale-body-large);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Remove default arrow for select */
}

/* Floating Label */
.input-group label {
    position: absolute;
    left: 16px;
    top: 16px;
    color: var(--md-sys-color-on-surface-variant);
    pointer-events: none;
    transition: 0.2s ease all;
    background-color: transparent;
    font: var(--md-sys-typescale-body-large);
}

/* Active State (Focus or Value Present) */
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    border-color: var(--md-sys-color-focus);
    border-width: 2px;
    padding: 23px 15px 7px 15px; /* Adjust for 2px border */
    box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.1);
}

.input-group input:focus~label,
.input-group input:not(:placeholder-shown)~label,
.input-group select:focus~label,
.input-group select:valid~label,
.input-group textarea:focus~label,
.input-group textarea:not(:placeholder-shown)~label {
    top: 8px;
    font-size: 12px;
    line-height: 16px;
    color: var(--md-sys-color-focus);
}

/* Error State */
.input-group input.error,
.input-group select.error {
    border-color: var(--md-sys-color-error);
}

.input-group input.error~label,
.input-group select.error~label {
    color: var(--md-sys-color-error);
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    font: var(--md-sys-typescale-body-medium);
}

th {
    text-align: left;
    padding: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant);
    font: var(--md-sys-typescale-title-small);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface);
}

tr:hover td {
    background-color: rgba(0, 0, 0, 0.04);
}

/* --- Badges --- */
.badge {
    padding: 6px 12px;
    border-radius: 8px;
    font: var(--md-sys-typescale-label-small);
    text-transform: uppercase;
}

.badge-success {
    background-color: #e8f5e9;
    color: #1b5e20;
}

.badge-warning {
    background-color: #fff8e1;
    color: #f57f17;
}

.badge-error {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

/* --- Utilities --- */
/* NOTE: Removed .flex, .flex-col, .items-center, .justify-between, .justify-end,
   .gap-2, .gap-4, .mb-4, .mt-4, .w-full, .text-right from here.
   These are provided by Tailwind (output.css).
   CRITICAL: Having .flex here overrode Tailwind's .hidden due to cascade order,
   causing 'hidden flex' modals to show as flex (bg-black/90 covering entire page). */


/* --- Modals --- */
.modal, .nx-modal-overlay {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Scrim oscuro */
    backdrop-filter: blur(4px); /* Glassmorphism Overlay */
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.nx-modal-overlay.active, .modal.flex {
    opacity: 1;
    pointer-events: auto;
}

.modal-content, .modal-surface, .nx-modal-container {
    background: var(--theme-modal-bg);
    color: var(--md-sys-color-on-surface);
    border-radius: var(--md-sys-shape-corner-large); /* 16px */
    box-shadow: var(--md-sys-elevation-3);
    border: 1px solid var(--theme-modal-border);
    width: 100%;
    max-width: var(--nx-modal-max-w, 600px);
    position: relative;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Scroll belongs to body */
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nx-modal-container.active {
    transform: scale(1);
    opacity: 1;
}

.modal-header, .nx-modal-header {
    background: var(--theme-modal-header);
    padding: 24px 24px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--theme-modal-border);
}

.modal-header h2, .modal-header h3, .nx-modal-header h2, .nx-modal-header h3 {
    margin: 0;
    font: var(--md-sys-typescale-title-large);
    color: var(--md-sys-color-on-surface);
}

.modal-body, .nx-modal-body {
    padding: 24px;
    overflow-y: auto; /* Scroll is here */
    flex-grow: 1;
}

.modal-footer, .nx-modal-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--theme-modal-footer);
    border-top: 1px solid var(--theme-modal-border);
}

/* Touch-Safe Mobile Behavior (Bottom Sheet) */
@media (max-width: 768px) {
    .modal, .nx-modal-overlay {
        align-items: flex-end; /* Drop to bottom */
        padding: 0; /* Remove side padding */
    }
    .modal-content, .modal-surface, .nx-modal-container {
        border-radius: 24px 24px 0 0; /* Only top corners */
        max-width: 100%;
        max-height: 85vh;
        animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
        border-bottom: none;
    }
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- Toast Notification --- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 14px 16px;
    border-radius: 4px;
    min-width: 288px;
    box-shadow: var(--md-sys-elevation-3);
    font: var(--md-sys-typescale-body-medium);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideIn 0.3s ease-out forwards;
}

.toast.success {
    border-left: 4px solid #4caf50;
}

.toast.error {
    border-left: 4px solid var(--md-sys-color-error);
}

.toast.info {
    border-left: 4px solid var(--md-sys-color-primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --- Tooltip --- */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #323232;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    margin-bottom: 4px;
}

/* --- Sidebar Collapsible Logic (Service Dashboard Style) --- */
aside:not(:hover) .label {
    display: none;
}

aside:hover .label {
    display: block;
    animation: fadeIn 0.2s;
}

/* Ensure icons stay visible */
.nav-rail-item .material-icons {
    min-width: 24px;
}

/* --- Functional Modal Inputs (Midnight Circuit) --- */
.nx-glass-field {
    background: var(--theme-input-bg);
    border: 1px solid var(--theme-modal-border);
    color: var(--md-sys-color-on-surface);
    border-radius: 0.75rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    width: 100%;
    transition: all 0.3s ease;
}

.nx-glass-field:focus {
    background: var(--theme-input-bg);
    border-color: var(--md-sys-color-focus);
    box-shadow: var(--theme-field-focus-shadow);
    outline: none;
}

.nx-modal-label {
    display: block;
    font-size: 0.625rem; /* 10px */
    font-weight: 700;
    color: var(--theme-label-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.nx-modal-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Dashboard Final Polish --- */
.sucursal-select {
    background-color: var(--sucursal-bg) !important;
    color: var(--sucursal-text) !important;
    border: 1px solid var(--sucursal-border) !important;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    appearance: none;
}

.sucursal-select:hover {
    border-color: var(--accent-violet) !important;
}

.plus-btn {
    background: var(--accent-violet) !important;
    color: #FFFFFF !important;
    box-shadow: 0 4px 15px rgba(160, 32, 240, 0.3);
    border: none;
    transition: all 0.3s ease;
}

/* Glass effect refinement for dark mode */
[data-theme='dark'] .plus-btn {
    background: rgba(160, 32, 240, 0.85) !important;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.plus-btn:hover {
    box-shadow: 0 6px 20px rgba(160, 32, 240, 0.5);
    transform: translateY(-1px);
    filter: brightness(1.1);
}

/* =========================================================
   MOBILE-FIRST & RESPONSIVE UTILITIES (Fase 1)
   ========================================================= */

@media (max-width: 768px) {
    /* Esconder Sidebar y Elementos Desktop */
    .hide-on-mobile,
    aside.sidebar {
        display: none !important;
    }

    /* Forzar diseño en columna (apilado) */
    .stack-on-mobile {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }

    /* Reducir padding global para ganar espacio en celular */
    body {
        font-size: 14px; /* Mejorar densidad */
    }

    /* Modales a Pantalla Completa (Bottom Sheet / Fullscreen) */
    .modal-content, .modal-panel {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        margin: 0 !important;
    }

    /* Formularios densos a 1 columna */
    .grid {
        grid-template-columns: 1fr !important;
    }

    /* Inputs Táctiles: Mínimo 44px (Apple standard) */
    input, select, button, .nx-glass-field {
        min-height: 44px !important;
    }

    /* Tarjetas Apiladas (Responsive Cards) para Tablas Densas */
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block;
    }

    .table-responsive thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-responsive tr {
        border: 1px solid var(--md-sys-color-outline-variant);
        border-radius: var(--md-sys-shape-corner-medium);
        margin-bottom: 1rem;
        background: var(--md-sys-color-surface);
        padding: 0.5rem;
    }

    .table-responsive td {
        border: none;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        position: relative;
        padding-left: 50% !important;
        text-align: right !important;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .table-responsive td:last-child {
        border-bottom: 0;
        justify-content: center;
        padding-left: 0 !important;
    }

    .table-responsive td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--md-sys-color-on-surface-variant);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    /* Bottom Nav Bar Styles */
    body {
        padding-bottom: 70px; /* Space for the bottom nav */
    }

    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: var(--premium-glass-bg);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--premium-glass-border);
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--md-sys-color-outline);
        text-decoration: none;
        width: 100%;
        height: 100%;
        transition: all 0.2s ease;
    }

    .mobile-bottom-nav .nav-item i {
        font-size: 1.25rem;
        transition: transform 0.2s ease;
    }

    .mobile-bottom-nav .nav-item span {
        font-size: 0.65rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .mobile-bottom-nav .nav-item.active {
        color: var(--accent-violet);
    }

    .mobile-bottom-nav .nav-item.active i {
        transform: translateY(-2px);
    }

    .mobile-bottom-nav .nav-item:active {
        background: rgba(255, 255, 255, 0.05);
    }
}
/* Ficha Tecnica Global Styles injected by Agent */
/* ── DataSheet Modal (Glassmorphism) ─────────────────────────────── */
.datasheet-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100010;
    padding: 20px;
}
.datasheet-modal-overlay.open { display: flex; }

.datasheet-modal-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0,0,0,.3), 0 0 80px rgba(139,92,246,.08);
    width: 100%;
    max-width: 620px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: dsModalIn .25s ease-out;
}
@keyframes dsModalIn {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.datasheet-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(139,92,246,.06), rgba(6,182,212,.04));
}
.datasheet-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.datasheet-icon { font-size: 20px; }
.datasheet-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}
.datasheet-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .2s, color .2s;
    line-height: 1;
}
.datasheet-close:hover { background: var(--accent-glow); color: var(--text); }

.datasheet-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Loading state */
.datasheet-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 13px;
}
.datasheet-spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error state */
.datasheet-error {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}
.datasheet-error-icon { font-size: 18px; }

/* Content rendered markdown */
.datasheet-content {
    font-size: 13px;
    line-height: 1.65;
    color: var(--text);
}
.datasheet-content h1,
.datasheet-content h2,
.datasheet-content h3 {
    margin: 16px 0 8px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}
.datasheet-content h1 { font-size: 17px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.datasheet-content h2 { font-size: 15px; }
.datasheet-content h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.datasheet-content p { margin: 6px 0; }
.datasheet-content ul, .datasheet-content ol {
    padding-left: 18px;
    margin: 6px 0;
}
.datasheet-content li { margin-bottom: 3px; }
.datasheet-content strong { color: var(--text); font-weight: 600; }
.datasheet-content code {
    background: rgba(139,92,246,.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}
.datasheet-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 12px;
}
.datasheet-content th, .datasheet-content td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
}
.datasheet-content th {
    background: rgba(139,92,246,.08);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* DataSheet meta pills (top of content) */
.datasheet-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.datasheet-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(139,92,246,.1);
    color: #7c3aed;
    border: 1px solid rgba(139,92,246,.2);
}

/* ── DataSheet Light-Mode Hardening ───────────────────────────────── */
[data-theme="light"] .datasheet-modal-panel {
    box-shadow: 0 25px 60px rgba(0,0,0,.12), 0 0 0 1px var(--border);
}
[data-theme="light"] .datasheet-modal-header {
    background: linear-gradient(135deg, rgba(139,92,246,.08), rgba(6,182,212,.05));
}
[data-theme="light"] .datasheet-content th {
    background: rgba(139,92,246,.06);
    color: #4c1d95;
}
[data-theme="light"] .datasheet-content code {
    background: rgba(139,92,246,.08);
    color: #6d28d9;
}
[data-theme="light"] .datasheet-meta-pill {
    background: rgba(139,92,246,.08);
    color: #6d28d9;
    border-color: rgba(139,92,246,.18);
}

/* ── Search / MCP Light-Mode Hardening ───────────────────────────── */
[data-theme="light"] .nps-search-progress {
    background: rgba(139,92,246,.03);
    border-radius: 8px;
}
[data-theme="light"] .nexoparts-hint {
    background: #ffffff;
    border-color: rgba(139,92,246,.15);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
[data-theme="light"] .nexoparts-hint kbd {
    background: rgba(139,92,246,.08);
    color: #6d28d9;
    border-color: rgba(139,92,246,.15);
}
[data-theme="light"] .np-badge--mcp {
    background: rgba(139,92,246,.1);
    color: #6d28d9;
    border-color: rgba(139,92,246,.18);
}
[data-theme="light"] .np-badge--discovered {
    background: rgba(245,158,11,.1);
    color: #b45309;
    border-color: rgba(245,158,11,.2);
}
[data-theme="light"] .mcp-enrichment-card {
    background: linear-gradient(135deg, rgba(139,92,246,.04) 0%, rgba(99,102,241,.03) 100%);
    border-color: rgba(139,92,246,.15);
}
[data-theme="light"] .mcp-fitment-chip {
    background: rgba(139,92,246,.08);
    color: #6d28d9;
    border-color: rgba(139,92,246,.12);
}
[data-theme="light"] .mcp-value--mono {
    color: #6d28d9;
}
