/* ══════════════════════════════════════════════════════════════
   Multisistemas 360 — Professional Design System v3.0
   Diseño espectacular · Animaciones fluidas · UX premium
   ══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #eef2ff;
    --color-primary-50: #eef2ff;
    --color-primary-100: #e0e7ff;
    --color-primary-500: #6366f1;
    --color-primary-600: #4f46e5;
    --color-primary-700: #4338ca;

    --color-secondary: #475569;
    --color-secondary-hover: #334155;

    --color-success: #059669;
    --color-success-light: #ecfdf5;
    --color-success-50: #ecfdf5;
    --color-success-500: #10b981;
    --color-success-600: #059669;

    --color-warning: #d97706;
    --color-warning-light: #fffbeb;
    --color-warning-50: #fffbeb;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;

    --color-danger: #dc2626;
    --color-danger-light: #fef2f2;
    --color-danger-50: #fef2f2;
    --color-danger-500: #ef4444;
    --color-danger-600: #dc2626;

    --color-info: #0284c7;
    --color-info-light: #f0f9ff;

    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #0f172a;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;

    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active-bg: rgba(99, 102, 241, 0.12);
    --sidebar-active-text: #a5b4fc;
    --sidebar-active-border: #6366f1;
    --sidebar-width: 320px;
    --sidebar-collapsed-width: 72px;

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --shadow-inner: inset 0 2px 4px rgba(0,0,0,0.04);
    --shadow-glow: 0 0 0 3px rgba(99,102,241,0.15);

    --font-sans: 'DM Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-spring: 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275);

    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.04), transparent 50%),
                radial-gradient(ellipse 60% 40% at 100% 20%, rgba(139, 92, 246, 0.03), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary-hover); text-decoration: none; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: var(--radius-xs); }
::selection { background: var(--color-primary-100); color: var(--color-primary-700); }

.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; stroke-linecap: round; stroke-linejoin: round; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: var(--z-fixed);
    transition: transform var(--transition-slow);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-logo {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-md);
    letter-spacing: -0.5px;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f1f5f9;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    font-size: 0.87rem;
    font-weight: 450;
    transition: all var(--transition-fast);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 1px;
    border: 1px solid transparent;
    position: relative;
}

.sidebar-link:hover {
    color: #e2e8f0;
    background: var(--sidebar-hover);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
    border-color: rgba(99,102,241,0.15);
    font-weight: 550;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--sidebar-active-border);
    border-radius: 0 2px 2px 0;
}

.sidebar-link .icon {
    width: 20px;
    height: 20px;
    opacity: 0.85;
    flex-shrink: 0;
}

.sidebar-link.active .icon { opacity: 1; }

.sidebar-link .sidebar-icon-img {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    object-fit: contain;
    filter: invert(1) saturate(0) brightness(1.3);
    mix-blend-mode: screen;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 0.5rem;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.sidebar-user:hover { background: rgba(255,255,255,0.04); }

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-name { font-size: 0.85rem; color: #e2e8f0; font-weight: 500; }
.sidebar-user-role { font-size: 0.72rem; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: 0.04em; }

.sidebar-logout {
    color: #f87171 !important;
    opacity: 0.8;
}

.sidebar-logout:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.1) !important;
    color: #fca5a5 !important;
}

/* ══════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 2rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.topbar-toggle:hover { background: var(--color-bg); }
.topbar-toggle svg { width: 22px; height: 22px; }

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.01em;
}

.topbar-module-icon { width: 28px; height: 28px; object-fit: contain; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-search {
    position: relative;
    width: 220px;
}

.topbar-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.topbar-search-input {
    width: 100%;
    padding: 0.5rem 0.85rem 0.5rem 2.5rem;
    font-size: 0.85rem;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.topbar-search-input::placeholder { color: var(--color-text-muted); }
.topbar-search-input:hover { border-color: var(--color-border); }
.topbar-search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.topbar-tenant {
    background: var(--color-primary-50);
    color: var(--color-primary);
    padding: 0.3rem 0.85rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.01em;
}

.content-area {
    padding: 1.5rem 2rem 3rem;
    flex: 1;
    animation: fadeInUp 0.3s ease;
}

/* Formularios y cards usan todo el ancho disponible para evitar espacio vacío a la derecha */
.content-area .card {
    max-width: 100% !important;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ══════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════ */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: box-shadow var(--transition), transform var(--transition);
}

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

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.card-subtitle {
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    margin-top: 0.15rem;
}

.card-header-stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
}

.card-body { padding: 1.25rem 1.5rem; }

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ══════════════════════════════════════════
   DASHBOARD WELCOME
   ══════════════════════════════════════════ */
.dashboard-welcome {
    margin-bottom: 1.75rem;
}

.dashboard-welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text);
    margin: 0 0 0.25rem 0;
}

.dashboard-welcome-subtitle {
    font-size: 0.92rem;
    color: var(--color-text-secondary);
    margin: 0;
}

.dashboard-quick-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xs);
}

.dashboard-quick-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-quick-link {
    display: inline-flex;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg);
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.dashboard-quick-link:hover {
    color: var(--color-primary);
    background: var(--color-primary-50);
    text-decoration: none;
}

/* ══════════════════════════════════════════
   STAT CARDS
   ══════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.2s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: 0.25s; }
.stats-grid .stat-card:nth-child(6) { animation-delay: 0.3s; }

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.35rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--color-border);
    transition: all var(--transition-spring);
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.4s ease backwards;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 3px;
    background: var(--stat-accent, var(--color-primary));
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
    border-color: var(--color-primary-100);
}

.stat-card:hover::after { opacity: 1; }

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.stat-icon svg { width: 22px; height: 22px; }

.stat-info { flex: 1; min-width: 0; }

.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    margin-top: 0.15rem;
}

.stat-change {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-full);
    margin-top: 0.35rem;
    display: inline-block;
}

.stat-change.up { background: var(--color-success-50); color: var(--color-success-600); }
.stat-change.down { background: var(--color-danger-50); color: var(--color-danger-600); }

/* ══════════════════════════════════════════
   MODULES GRID (Dashboard)
   ══════════════════════════════════════════ */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.modules-grid .module-card:nth-child(1) { animation-delay: 0.05s; }
.modules-grid .module-card:nth-child(2) { animation-delay: 0.08s; }
.modules-grid .module-card:nth-child(3) { animation-delay: 0.11s; }
.modules-grid .module-card:nth-child(4) { animation-delay: 0.14s; }
.modules-grid .module-card:nth-child(5) { animation-delay: 0.17s; }
.modules-grid .module-card:nth-child(6) { animation-delay: 0.2s; }
.modules-grid .module-card:nth-child(7) { animation-delay: 0.23s; }
.modules-grid .module-card:nth-child(8) { animation-delay: 0.26s; }
.modules-grid .module-card:nth-child(9) { animation-delay: 0.29s; }
.modules-grid .module-card:nth-child(10) { animation-delay: 0.32s; }

.module-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: all var(--transition-spring);
    text-decoration: none;
    color: var(--color-text);
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.35s ease backwards;
}

.module-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--color-primary-50), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.module-card:hover {
    border-color: var(--color-primary-500);
    box-shadow: 0 12px 32px rgba(79, 70, 229, 0.15);
    transform: translateY(-5px) scale(1.02);
    text-decoration: none;
    color: var(--color-text);
}

.module-card:hover::before { opacity: 1; }

.module-icon {
    width: 168px;
    height: 168px;
    color: var(--color-primary);
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.module-icon.module-icon-accent {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-sizing: border-box;
}

.module-icon svg, .module-icon-img { width: 100%; height: 100%; object-fit: contain; }
.module-icon.module-icon-accent svg { width: 85%; height: 85%; }
.module-clipart { display: block; }

.module-name {
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    position: relative;
    z-index: 1;
}

/* ══════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════ */
.form-group { margin-bottom: 1.15rem; }

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.35rem;
    letter-spacing: 0.01em;
}

.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.form-input,
.form-select {
    display: block;
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.form-input::placeholder { color: var(--color-text-muted); }

.form-input.is-invalid { border-color: var(--color-danger); }
.form-input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,0.12); }
.form-error { font-size: 0.78rem; color: var(--color-danger); margin-top: 0.25rem; }

.form-errors-summary {
    padding: 1rem 1.25rem;
    background: var(--color-danger-50);
    border: 1px solid #fca5a5;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
}

.form-errors-summary ul {
    margin: 0;
    padding-left: 1.25rem;
}

.form-errors-summary li { margin: 0.25rem 0; }

textarea.form-input { resize: vertical; min-height: 80px; }

select.form-input,
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.form-section {
    margin-top: 1.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--color-border-light);
}

.form-section-title {
    font-size: 0.92rem;
    font-weight: 650;
    color: var(--color-text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    font-size: 0.88rem;
}

.form-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.form-toggle .toggle-track {
    width: 40px;
    height: 22px;
    background: #cbd5e1;
    border-radius: 11px;
    transition: background var(--transition-fast);
    position: relative;
    flex-shrink: 0;
}

.form-toggle .toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.form-toggle input:checked + .toggle-track { background: var(--color-primary); }
.form-toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* ══════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 550;
    font-family: var(--font-sans);
    border-radius: var(--radius-md);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn.disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

.btn .icon { width: 16px; height: 16px; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(79,70,229,0.3);
}
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,0.35); }

.btn-success {
    background: var(--color-success);
    color: #fff;
    box-shadow: 0 1px 3px rgba(5,150,105,0.3);
}
.btn-success:hover { background: #047857; color: #fff; }

.btn-warning {
    background: var(--color-warning);
    color: #fff;
    box-shadow: 0 1px 3px rgba(217,119,6,0.3);
}
.btn-warning:hover { background: #b45309; color: #fff; }

.btn-secondary {
    background: var(--color-secondary);
    color: #fff;
}
.btn-secondary:hover { background: var(--color-secondary-hover); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); border-color: #cbd5e1; }

.btn-danger {
    background: transparent;
    color: var(--color-danger) !important;
    border-color: var(--color-danger-light);
}
.btn-danger:hover { background: var(--color-danger-light) !important; border-color: #fca5a5; }

.btn-danger-solid {
    background: var(--color-danger);
    color: #fff !important;
    box-shadow: 0 1px 3px rgba(220,38,38,0.3);
}
.btn-danger-solid:hover { background: #b91c1c; color: #fff !important; }

.btn-link {
    background: none;
    border: none;
    color: var(--color-primary);
    padding: 0.25rem 0.5rem;
    font-weight: 500;
}
.btn-link:hover { color: var(--color-primary-hover); background: var(--color-primary-50); }

.btn-block { display: flex; width: 100%; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }

.btn-icon {
    padding: 0.45rem;
    border-radius: var(--radius-md);
    width: 36px;
    height: 36px;
}
.btn-icon .icon { width: 18px; height: 18px; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; border-right-width: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; border-right-width: 1.5px; }

/* ══════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════ */
.table-responsive { overflow-x: auto; border-radius: var(--radius-lg); }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th,
.table td {
    padding: 0.7rem 1rem;
    text-align: left;
    font-size: 0.88rem;
    vertical-align: middle;
}

.table th {
    font-weight: 650;
    color: var(--color-text-secondary);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--color-bg);
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.table th[data-sortable] {
    cursor: pointer;
    user-select: none;
    padding-right: 1.5rem;
    position: relative;
}

.table th[data-sortable]:hover {
    color: var(--color-primary);
}

.table th[data-sortable]::after {
    content: '';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.4;
}

.table th[data-sortable][data-sort="asc"]::after {
    border-top: none;
    border-bottom: 5px solid var(--color-primary);
    opacity: 1;
}

.table th[data-sortable][data-sort="desc"]::after {
    border-top: 5px solid var(--color-primary);
    opacity: 1;
}

.table td {
    border-bottom: 1px solid var(--color-border-light);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

.table .text-right { text-align: right; }
.table .text-center { text-align: center; }
.table .text-mono { font-family: var(--font-mono); font-size: 0.85rem; }

.table .row-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.table tbody tr:hover .row-actions { opacity: 1; }

.link-name {
    font-weight: 550;
    color: var(--color-text);
    transition: color var(--transition-fast);
}
.link-name:hover { color: var(--color-primary); }

.inline-form { display: inline; }

/* ══════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.6rem;
    font-size: 0.73rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    letter-spacing: 0.01em;
    white-space: nowrap;
    line-height: 1.5;
}

.badge-primary { background: var(--color-primary-50); color: var(--color-primary); }
.badge-success { background: var(--color-success-50); color: var(--color-success); }
.badge-warning { background: var(--color-warning-50); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-50); color: var(--color-danger); }
.badge-info { background: var(--color-info-light); color: var(--color-info); }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-dark { background: #1e293b; color: #e2e8f0; }

.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.badge-lg { padding: 0.3rem 0.85rem; font-size: 0.82rem; }

/* ══════════════════════════════════════════
   PROGRESS BAR
   ══════════════════════════════════════════ */
.progress {
    width: 100%;
    height: 8px;
    background: var(--color-bg);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    transition: width var(--transition-slow);
    position: relative;
}

.progress-bar.success { background: var(--color-success); }
.progress-bar.warning { background: var(--color-warning); }
.progress-bar.danger { background: var(--color-danger); }

.progress-sm { height: 5px; }
.progress-lg { height: 12px; }

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.35rem;
}

/* ══════════════════════════════════════════
   TABS
   ══════════════════════════════════════════ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.tab-link {
    padding: 0.65rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 550;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tab-link:hover { color: var(--color-text); text-decoration: none; }
.tab-link.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-link .tab-count {
    background: var(--color-bg);
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}
.tab-link.active .tab-count { background: var(--color-primary-50); color: var(--color-primary); }

.tab-content { display: none; animation: fadeInUp 0.2s ease; }
.tab-content.active { display: block; }

/* ══════════════════════════════════════════
   ALERTS & TOASTS
   ══════════════════════════════════════════ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: all var(--transition-slow);
    border: 1px solid transparent;
}

.alert::before {
    content: '';
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-size: contain;
    background-repeat: no-repeat;
}

.alert-success {
    background: var(--color-success-50);
    color: #065f46;
    border-color: #a7f3d0;
}
.alert-success::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpolyline points='22 4 12 14.01 9 11.01'/%3E%3C/svg%3E"); }

.alert-error {
    background: var(--color-danger-50);
    color: #991b1b;
    border-color: #fca5a5;
}
.alert-error::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='15' y1='9' x2='9' y2='15'/%3E%3Cline x1='9' y1='9' x2='15' y2='15'/%3E%3C/svg%3E"); }

.alert-warning {
    background: var(--color-warning-50);
    color: #92400e;
    border-color: #fcd34d;
}
.alert-warning::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23d97706' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E"); }

.alert-info {
    background: var(--color-info-light);
    color: #075985;
    border-color: #7dd3fc;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    animation: toastIn 0.3s ease;
    max-width: 380px;
}

.toast.removing { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ══════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════ */
.pagination {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border-light);
}

.pagination-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 550;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
    text-decoration: none;
    border: 1px solid transparent;
}

.pagination-link:hover {
    background: var(--color-primary-50);
    color: var(--color-primary);
    border-color: var(--color-primary-100);
    text-decoration: none;
}

.pagination-link.active {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(79,70,229,0.25);
}

.pagination-info {
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    margin: 0 0.75rem;
}

.pagination-ellipsis {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ══════════════════════════════════════════
   SEARCH & FILTER BAR
   ══════════════════════════════════════════ */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    align-items: stretch;
}

.search-bar .form-input { flex: 1; margin: 0; }
.search-bar .form-select { width: auto; min-width: 150px; }

.filter-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.filter-chip:hover, .filter-chip.active {
    background: var(--color-primary-50);
    border-color: var(--color-primary);
    color: var(--color-primary);
    text-decoration: none;
}

/* ══════════════════════════════════════════
   BREADCRUMBS
   ══════════════════════════════════════════ */
.breadcrumbs-wrapper {
    margin-bottom: 1rem;
}

.breadcrumbs {
    font-size: 0.82rem;
}

.breadcrumbs-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumbs-list li {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.breadcrumbs-list li:not(:last-child)::after {
    content: '/';
    color: var(--color-text-muted);
    font-weight: 400;
    pointer-events: none;
}

.breadcrumbs-list a {
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumbs-list a:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.breadcrumbs-current {
    color: var(--color-text);
    font-weight: 550;
}

/* ══════════════════════════════════════════
   CONTENT HEADER
   ══════════════════════════════════════════ */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.content-header-left { flex: 1; min-width: 0; }
.content-header h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.content-header p { font-size: 0.85rem; color: var(--color-text-secondary); margin-top: 0.15rem; }

/* ══════════════════════════════════════════
   DETAIL VIEW
   ══════════════════════════════════════════ */
.detail-grid { display: grid; gap: 0.85rem; }

.detail-item {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--color-border-light);
}

.detail-item:last-child { border-bottom: none; }

.detail-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.detail-value { font-size: 0.92rem; color: var(--color-text); }

/* ══════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 3.5rem 2rem;
    color: var(--color-text-secondary);
    background: linear-gradient(180deg, var(--color-bg) 0%, var(--color-surface) 100%);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--color-border);
}

.empty-state-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    padding: 1rem;
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.empty-state-icon svg {
    width: 100%;
    height: 100%;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 650;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.empty-state .btn {
    min-height: 44px;
    padding: 0.6rem 1.25rem;
}

.empty-state svg { margin: 0 auto 1rem; opacity: 0.35; }

.empty-state-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

/* Loading skeleton para tablas y listas */
.skeleton-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.skeleton-table th,
.skeleton-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border-light);
}

.skeleton-table .skeleton {
    height: 1rem;
    border-radius: var(--radius-sm);
}

.skeleton-table .skeleton.w-3 { width: 60%; }
.skeleton-table .skeleton.w-2 { width: 40%; }
.skeleton-table .skeleton.w-1 { width: 20%; }

.page-loading {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}

.page-loading.active {
    opacity: 1;
    visibility: visible;
}

/* ══════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    transition: opacity var(--transition);
    display: none;
}

.modal-backdrop.active { display: flex; align-items: center; justify-content: center; opacity: 1; }

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 540px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease;
    z-index: var(--z-modal);
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }

@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title { font-size: 1.05rem; font-weight: 650; }

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }

.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ══════════════════════════════════════════
   TWO-COLUMN LAYOUT
   ══════════════════════════════════════════ */
.layout-2col {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}

.layout-2col-wide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* ══════════════════════════════════════════
   TIMELINE
   ══════════════════════════════════════════ */
.timeline { position: relative; padding-left: 2rem; }

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -2rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-surface);
    box-shadow: 0 0 0 2px var(--color-primary-100);
    z-index: 1;
}

.timeline-date { font-size: 0.78rem; color: var(--color-text-secondary); margin-bottom: 0.25rem; }
.timeline-title { font-weight: 600; font-size: 0.9rem; }
.timeline-desc { font-size: 0.85rem; color: var(--color-text-secondary); margin-top: 0.15rem; }

/* ══════════════════════════════════════════
   AVATAR
   ══════════════════════════════════════════ */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.82rem;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: 0.72rem; }
.avatar-md { width: 36px; height: 36px; font-size: 0.82rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-xl { width: 64px; height: 64px; font-size: 1.25rem; border-radius: var(--radius-lg); }

.avatar-group { display: flex; }
.avatar-group .avatar { margin-left: -8px; border: 2px solid var(--color-surface); }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ══════════════════════════════════════════
   DROPDOWN
   ══════════════════════════════════════════ */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: all var(--transition-fast);
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--color-text);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
}

.dropdown-item:hover { background: var(--color-bg); text-decoration: none; }
.dropdown-item.active { background: var(--color-primary-50); color: var(--color-primary); font-weight: 600; }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-divider { height: 1px; background: var(--color-border); margin: 0.25rem 0; }
.dropdown-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); padding: 0.35rem 0.75rem; }
.dropdown-menu-right { left: auto; right: 0; }
.btn-dropdown { display: inline-flex; align-items: center; gap: 0.5rem; }
.btn-dropdown .icon-sm { width: 14px; height: 14px; }

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

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #1e293b;
    color: #f1f5f9;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: var(--z-tooltip);
    pointer-events: none;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* ══════════════════════════════════════════
   LOADING
   ══════════════════════════════════════════ */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
    background: linear-gradient(90deg, var(--color-bg) 25%, #e2e8f0 50%, var(--color-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    height: 1em;
}

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ══════════════════════════════════════════
   COMMAND PALETTE (Ctrl+K) — v3
   ══════════════════════════════════════════ */
.m360-cp {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition), visibility var(--transition);
}

.m360-cp.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.m360-cp-bd {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    cursor: pointer;
}

.m360-cp-modal {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0 1rem;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px -12px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.06);
    border: 1px solid var(--color-border);
    overflow: hidden;
    animation: cpIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cpIn {
    from { opacity: 0; transform: scale(0.94) translateY(-8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.m360-cp-search {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.m360-cp-search svg { color: var(--color-text-muted); flex-shrink: 0; }

#m360-cp-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: transparent;
}

#m360-cp-input::placeholder { color: var(--color-text-muted); }

.m360-cp-esc {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 0.15rem 0.4rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
    cursor: pointer;
}

.m360-cp-results {
    max-height: 380px;
    overflow-y: auto;
    padding: 0.4rem;
    scrollbar-width: thin;
}

.m360-cp-group {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 0.6rem 0.85rem 0.3rem;
}

.m360-cp-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--color-text);
    text-decoration: none;
    transition: background var(--transition-fast);
    gap: 0.75rem;
}

.m360-cp-item:hover,
.m360-cp-item.focused {
    background: var(--color-primary-50);
    color: var(--color-primary);
    text-decoration: none;
}

.m360-cp-item-label {
    font-size: 0.9rem;
    font-weight: 500;
    flex: 1;
}

.m360-cp-item-desc {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.m360-cp-item.focused .m360-cp-item-desc { color: var(--color-primary); opacity: 0.7; }

.m360-cp-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

.m360-cp-footer {
    display: flex;
    gap: 1.25rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.73rem;
    color: var(--color-text-muted);
    background: var(--color-bg);
}

.m360-cp-footer kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    font-size: 0.68rem;
    font-family: var(--font-mono);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--color-text-secondary);
}

/* Legacy compat */
.m360-command-palette { display: none !important; }

/* ══════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════ */
.login-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(99,102,241,0.08) 0%, transparent 50%),
                radial-gradient(circle at 70% 60%, rgba(139,92,246,0.06) 0%, transparent 50%);
    animation: loginBg 20s ease infinite;
}

@keyframes loginBg {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-2%, -2%); }
}

.login-container { width: 100%; max-width: 420px; padding: 1.5rem; position: relative; z-index: 1; }

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2.25rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255,255,255,0.08);
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.login-brand { text-align: center; margin-bottom: 2rem; }

.login-logo {
    display: inline-block;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    letter-spacing: -0.5px;
    box-shadow: 0 4px 16px rgba(99,102,241,0.35);
}

.login-title { font-size: 1.35rem; font-weight: 700; color: var(--color-text); }
.login-subtitle { font-size: 0.9rem; color: var(--color-text-secondary); margin-top: 0.25rem; }

.login-form { margin-top: 1.5rem; }
.login-form .btn { margin-top: 0.5rem; }

.login-links {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border-light);
    text-align: center;
}

.login-links p { margin: 0.5rem 0; font-size: 0.9rem; }

.login-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.login-link:hover { color: var(--color-primary-hover); text-decoration: underline; }

.login-demo { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.75rem; }

.login-demo-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    font-size: inherit;
    font-family: inherit;
}

.login-demo-btn:hover { color: var(--color-primary-hover); }

.login-copyright { text-align: center; font-size: 0.8rem; color: #64748b; margin-top: 1.5rem; }

/* ══════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════ */
.text-muted { color: var(--color-text-secondary); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.1rem; }
.text-mono { font-family: var(--font-mono); }
.text-bold { font-weight: 700; }
.text-semibold { font-weight: 600; }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }
.ml-auto { margin-left: auto; }

.p-0 { padding: 0; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }

.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }

.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.border { border: 1px solid var(--color-border); }
.border-t { border-top: 1px solid var(--color-border); }
.border-b { border-bottom: 1px solid var(--color-border); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }

.bg-surface { background: var(--color-surface); }
.bg-muted { background: var(--color-bg); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Status-specific backgrounds */
.bg-success-subtle { background: var(--color-success-50); }
.bg-warning-subtle { background: var(--color-warning-50); }
.bg-danger-subtle { background: var(--color-danger-50); }
.bg-info-subtle { background: var(--color-info-light); }
.bg-primary-subtle { background: var(--color-primary-50); }

/* Grid utilities */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ══════════════════════════════════════════
   CLIENTES MODULE
   ══════════════════════════════════════════ */
.content-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
    margin-bottom: 0.15rem;
}

.content-subtitle {
    font-size: 0.85rem;
}

.content-subtitle kbd {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 0 var(--color-border);
}

/* Stat cards con iconos coloreados */
.stat-card-primary .stat-icon { background: var(--color-primary-50); color: var(--color-primary); }
.stat-card-success .stat-icon { background: var(--color-success-50); color: var(--color-success-600); }
.stat-card-warning .stat-icon { background: var(--color-warning-50); color: var(--color-warning-600); }

.stats-clientes .stat-card {
    animation: scaleIn 0.4s ease backwards;
}

.stats-clientes .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-clientes .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-clientes .stat-card:nth-child(3) { animation-delay: 0.15s; }

.stats-clientes .stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.stats-clientes .stat-icon svg { width: 22px; height: 22px; }

/* Search bar mejorada */
.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-bar-clientes .search-input-wrapper .form-input {
    padding-left: 2.5rem;
    padding-right: 2.25rem;
}

.search-bar-clientes .search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.search-bar-clientes .search-clear {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.search-bar-clientes .search-clear:hover {
    color: var(--color-danger);
    background: var(--color-danger-50);
}

.search-bar-clientes .search-clear svg { width: 14px; height: 14px; }

/* Tabla clientes */
.client-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.client-avatar {
    flex-shrink: 0;
    text-transform: uppercase;
}

.contact-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    transition: color var(--transition-fast);
}

.contact-link:hover { color: var(--color-primary); }

.icon-sm { width: 14px; height: 14px; flex-shrink: 0; }

.contact-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }

.tags-cell { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }

.icon-whatsapp { color: #25d366 !important; }

.row-actions-clientes .inline-form { display: inline; }

/* Pagination wrapper */
.pagination-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border-light);
}

.pagination-wrapper .pagination-info {
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    text-align: center;
}

/* Responsive tabla clientes */
@media (max-width: 768px) {
    .table-clientes .client-cell { flex-direction: column; align-items: flex-start; }
    .table-clientes .contact-cell { flex-direction: column; }
    .table-clientes .contact-text { max-width: 100%; }
    .table-clientes .row-actions-clientes { flex-wrap: wrap; }
}

/* Vista detalle cliente */
.client-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.client-detail-avatar {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-500));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.client-detail-info { flex: 1; min-width: 0; }

.client-detail-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.client-detail-meta {
    font-size: 0.88rem;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

.client-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-whatsapp { color: #25d366 !important; }
.btn-whatsapp:hover { background: rgba(37, 211, 102, 0.1) !important; color: #20bd5a !important; }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 1024px) {
    .layout-2col { grid-template-columns: 1fr; }
    .layout-2col-wide { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }

    .main-content { margin-left: 0; }
    .topbar-toggle { display: flex; }

    .content-area { padding: 1rem; }
    .topbar { padding: 0.65rem 1rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    .detail-item { grid-template-columns: 1fr; }

    .content-header { flex-direction: column; align-items: stretch; }
    .search-bar { flex-direction: column; }

    .table th, .table td {
        padding: 0.5rem 0.65rem;
        font-size: 0.82rem;
    }

    /* Tabla responsive: cards en móvil */
    .table-responsive .table-mobile-cards {
        display: block;
    }

    .table-responsive .table-mobile-cards thead { display: none; }
    .table-responsive .table-mobile-cards tbody tr {
        display: block;
        padding: 1rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        margin-bottom: 0.75rem;
        background: var(--color-surface);
    }
    .table-responsive .table-mobile-cards tbody tr:last-child { margin-bottom: 0; }
    .table-responsive .table-mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
    }
    .table-responsive .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-text-secondary);
        font-size: 0.78rem;
    }
    .table-responsive .table-mobile-cards .row-actions {
        justify-content: flex-start;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--color-border-light);
    }

    .tabs { gap: 0; }
    .tab-link { padding: 0.5rem 0.75rem; font-size: 0.82rem; }

    .modal { width: 95%; margin: 1rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .modules-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.35rem; }
    .topbar-search { display: none; }
    .topbar-actions { gap: 0.5rem; }
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-fixed) - 1);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar.open ~ .sidebar-overlay { display: block; opacity: 1; }

/* ══════════════════════════════════════════
   CHARTS & PIPELINE
   ══════════════════════════════════════════ */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding-top: 1rem;
}

.chart-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.chart-bar-value {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
}

.chart-bar-track {
    flex: 1;
    width: 100%;
    max-width: 44px;
    background: var(--color-bg);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.chart-bar-fill {
    width: 100%;
    background: linear-gradient(180deg, var(--color-primary), var(--color-primary-500));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    min-height: 2px;
    transition: height 0.3s ease;
}

.chart-bar-label {
    font-size: 0.72rem;
    color: var(--color-text-secondary);
    margin-top: 6px;
}

.pipeline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.pipeline-stage {
    padding: 0.85rem 1rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-primary);
}

.pipeline-count {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}

.pipeline-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text);
}

.pipeline-value {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.agenda-list { display: flex; flex-direction: column; gap: 0.75rem; }

.agenda-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.agenda-time {
    min-width: 80px;
    text-align: center;
    flex-shrink: 0;
}

.agenda-body { flex: 1; min-width: 0; }

/* ══════════════════════════════════════════
   AGENDA CALENDAR (FullCalendar)
   ══════════════════════════════════════════ */
.agenda-mode-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.agenda-mode-tab:hover {
    color: var(--color-primary);
    border-color: var(--color-primary-100);
}

.agenda-mode-tab.active {
    color: var(--color-primary);
    background: var(--color-primary-50);
    border-color: var(--color-primary);
}

.agenda-mode-tab .icon {
    width: 16px;
    height: 16px;
}

.agenda-calendar-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.agenda-calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.agenda-calendar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.agenda-calendar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    margin-left: 0.5rem;
    min-width: 180px;
}

.agenda-view-tabs {
    display: flex;
    gap: 0.25rem;
}

.agenda-view-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.agenda-view-tab:hover {
    color: var(--color-primary);
    background: var(--color-primary-50);
}

.agenda-view-tab.active {
    color: var(--color-primary);
    background: var(--color-primary-50);
    border-color: var(--color-primary-100);
}

.agenda-view-tab .icon {
    width: 16px;
    height: 16px;
}

#agenda-calendar {
    padding: 1rem;
    min-height: 520px;
}

#agenda-calendar .fc {
    font-family: var(--font-sans);
}

#agenda-calendar .fc-theme-standard td,
#agenda-calendar .fc-theme-standard th {
    border-color: var(--color-border);
}

#agenda-calendar .fc-col-header-cell-cushion {
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#agenda-calendar .fc-daygrid-day-number {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

#agenda-calendar .fc-day-today {
    background: var(--color-primary-50);
}

#agenda-calendar .fc-day-today .fc-daygrid-day-number {
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-full);
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#agenda-calendar .fc-event {
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-size: 0.8rem;
    cursor: pointer;
}

#agenda-calendar .fc-event:hover {
    filter: brightness(1.05);
}

#agenda-calendar .fc-timegrid-slot {
    height: 2.5rem;
}

#agenda-calendar .fc-timegrid-slot-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

#agenda-calendar .fc-scrollgrid {
    border-radius: var(--radius-md);
}

#agenda-calendar .fc-button {
    font-family: var(--font-sans);
    font-weight: 500;
}

#agenda-calendar .fc-button-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

#agenda-calendar .fc-button-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

/* ══════════════════════════════════════════
   CRM DASHBOARD
   ══════════════════════════════════════════ */
.crm-dashboard { margin-top: 0.5rem; }

.crm-stats .stat-card {
    cursor: pointer;
    animation: scaleIn 0.4s ease backwards;
}

.crm-stats .stat-card:nth-child(1) { animation-delay: 0.05s; }
.crm-stats .stat-card:nth-child(2) { animation-delay: 0.08s; }
.crm-stats .stat-card:nth-child(3) { animation-delay: 0.11s; }
.crm-stats .stat-card:nth-child(4) { animation-delay: 0.14s; }
.crm-stats .stat-card:nth-child(5) { animation-delay: 0.17s; }
.crm-stats .stat-card:nth-child(6) { animation-delay: 0.2s; }

.crm-stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.crm-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.25rem 0 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xs);
}

.crm-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--color-bg);
    padding: 0.25rem;
    border-radius: var(--radius-md);
}

.crm-tabs .tab-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.crm-tabs .tab-link:hover {
    color: var(--color-primary);
    background: var(--color-primary-50);
}

.crm-tabs .tab-link.active {
    color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.crm-tabs .tab-link .icon { width: 18px; height: 18px; }

.crm-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.crm-search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.crm-search-input { min-width: 180px; max-width: 240px; }

/* CRM Calendar */
.crm-calendar-section {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-top: 0.5rem;
}

.crm-calendar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.crm-calendar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    flex: 1;
    text-align: center;
}

.crm-calendar-grid {
    padding: 1.25rem;
}

.crm-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.crm-calendar-weekdays span { text-align: center; }

.crm-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.crm-cal-day {
    min-height: 100px;
    padding: 0.5rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.crm-cal-day-other {
    background: var(--color-border-light);
    opacity: 0.6;
}

.crm-cal-day-today {
    background: var(--color-primary-50);
    border: 2px solid var(--color-primary);
}

.crm-cal-day-num {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
}

.crm-cal-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.crm-cal-event {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--ev-color, var(--color-primary));
    color: #fff;
    border-radius: var(--radius-xs);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    transition: opacity var(--transition-fast);
}

.crm-cal-event:hover {
    opacity: 0.9;
    color: #fff;
}

.crm-cal-more {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    padding: 0 4px;
}

.crm-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.crm-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
}

.crm-legend-item::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: var(--radius-xs);
    background: var(--leg-color, var(--color-primary));
}

/* CRM Pipeline Kanban */
.crm-pipeline-kanban {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    margin-top: 1rem;
    min-height: 400px;
}

.crm-pipeline-column {
    flex: 0 0 280px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.crm-pipeline-column-header {
    padding: 0.85rem 1rem;
    background: var(--color-surface);
    border-bottom: 3px solid var(--stage-color, var(--color-primary));
    font-weight: 600;
}

.crm-pipeline-column-title {
    display: block;
    color: var(--color-text);
    font-size: 0.95rem;
}

.crm-pipeline-column-count {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    background: var(--stage-color, var(--color-primary));
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
}

.crm-pipeline-column-value {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

.crm-pipeline-column-cards {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.crm-pipeline-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    padding: 0.75rem;
    transition: box-shadow var(--transition-fast);
}

.crm-pipeline-card:hover {
    box-shadow: var(--shadow-sm);
}

.crm-pipeline-card.is-dragging {
    opacity: 0.65;
    cursor: grabbing;
    box-shadow: var(--shadow-md);
}

.crm-pipeline-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.crm-pipeline-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
}

.crm-pipeline-card-company {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 0.2rem;
}

.crm-pipeline-card-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-top: 0.35rem;
}

.crm-pipeline-card-followup {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.35rem;
}

.crm-pipeline-card-followup .icon-sm { width: 14px; height: 14px; flex-shrink: 0; }

.crm-pipeline-card-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.55rem;
}

.crm-pipeline-card-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border);
}

.crm-pipeline-move-form {
    flex: 1;
    min-width: 0;
}

.crm-pipeline-stage-select {
    font-size: 0.78rem;
    padding: 0.25rem 0.5rem;
    height: auto;
    min-height: 28px;
}

.crm-pipeline-column-cards.is-drop-target {
    background: var(--color-primary-50);
    outline: 2px dashed var(--stage-color, var(--color-primary));
    outline-offset: -6px;
    border-radius: var(--radius-md);
}

@media (max-width: 768px) {
    .crm-toolbar { flex-direction: column; align-items: stretch; }
    .crm-actions { flex-wrap: wrap; }
    .crm-search-form { flex: 1; }
    .crm-cal-day { min-height: 80px; }
    .crm-pipeline-column { flex: 0 0 260px; min-width: 260px; }
}

@media (max-width: 900px) {
    .crm-stats { grid-template-columns: repeat(3, 1fr) !important; }
}

@media (max-width: 600px) {
    .crm-stats { grid-template-columns: repeat(2, 1fr) !important; }
    .crm-toolbar { flex-direction: column; align-items: stretch; }
    .crm-search-form { flex-wrap: wrap; }
    .crm-search-input { min-width: 100%; }
}

/* ══════════════════════════════════════════
   ENCUESTAS MODULE
   ══════════════════════════════════════════ */
.encuestas-search .search-input-wrapper { position: relative; flex: 1; min-width: 200px; }
.encuestas-search .search-input-wrapper .form-input { padding-left: 2.5rem; }
.encuestas-search .search-icon {
    position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--color-text-muted); pointer-events: none;
}

.encuestas-stats .stat-icon {
    width: 46px; height: 46px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.encuestas-stats .stat-icon svg { width: 22px; height: 22px; }

.nps-bar-track {
    display: flex; height: 24px; border-radius: var(--radius-md); overflow: hidden;
    background: var(--color-bg);
}
.nps-bar-segment { transition: width var(--transition-slow); min-width: 2px; }
.nps-promoters { background: #10b981; }
.nps-passives { background: #f59e0b; }
.nps-detractors { background: #ef4444; }
.nps-bar-legend { display: flex; gap: 1.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.nps-legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; }
.nps-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.encuestas-response-list { display: flex; flex-direction: column; gap: 0.75rem; }
.response-item {
    display: flex; gap: 0.75rem; align-items: flex-start;
    padding: 0.85rem; border-radius: var(--radius-md);
    background: var(--color-bg); border: 1px solid var(--color-border-light);
}
.response-score {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem; color: #fff; flex-shrink: 0;
}
.response-content { flex: 1; min-width: 0; }
.response-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.response-comment { margin: 0; font-size: 0.88rem; color: var(--color-text-secondary); line-height: 1.5; }
.response-date { font-size: 0.8rem; color: var(--color-text-muted); white-space: nowrap; flex-shrink: 0; }

.score-selector { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.score-option { cursor: pointer; margin: 0; }
.score-option input { position: absolute; opacity: 0; pointer-events: none; }
.score-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-md);
    border: 2px solid var(--color-border); font-weight: 600; font-size: 0.95rem;
    transition: all var(--transition-fast); min-width: 40px;
}
.score-option:hover .score-btn { border-color: var(--color-primary); }
.score-option input:focus-visible + .score-btn { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.response-score-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 0.85rem;
}

.encuestas-mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.mini-stat { text-align: center; padding: 0.75rem; background: var(--color-bg); border-radius: var(--radius-md); }
.mini-stat-value { display: block; font-size: 1.5rem; font-weight: 800; color: var(--color-text); }
.mini-stat-label { font-size: 0.8rem; color: var(--color-text-secondary); }

.encuestas-filter { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

@media (max-width: 768px) {
    .encuestas-show-layout { grid-template-columns: 1fr !important; }
    .encuestas-header { flex-direction: column; align-items: stretch; }
}

/* ══════════════════════════════════════════
   SIDEBAR — GROUPED NAVIGATION
   ══════════════════════════════════════════ */
.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-version {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.25);
    letter-spacing: 0.05em;
    font-weight: 400;
}

.sidebar-nav-top {
    padding: 0.5rem 0.5rem 0;
    flex-shrink: 0;
}

.sidebar-group {
    margin-top: 0.25rem;
}

.sidebar-group-label {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.2);
    padding: 0.75rem 1rem 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    letter-spacing: 0.04em;
}

.sidebar-badge-warning {
    background: rgba(245,158,11,0.2);
    color: #fbbf24;
    border: 1px solid rgba(245,158,11,0.3);
}

/* ── User section in sidebar footer ── */
.sidebar-user-section {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
    user-select: none;
}

.sidebar-user-section:hover { background: rgba(255,255,255,0.05); }

.sidebar-user-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.sidebar-user-status {
    position: absolute;
    bottom: -1px; right: -1px;
    width: 9px; height: 9px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
}

.sidebar-user-caret {
    margin-left: auto;
    opacity: 0.4;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-user-section[aria-expanded="true"] .sidebar-user-caret {
    transform: rotate(180deg);
    opacity: 0.7;
}

/* User popover */
.sidebar-user-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0.5rem;
    right: 0.5rem;
    background: #1e2233;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
    padding: 0.4rem;
    z-index: 100;
    display: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.sidebar-user-popover.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.sidebar-user-popover-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-md);
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 450;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.sidebar-user-popover-item:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    text-decoration: none;
}

.sidebar-user-popover-item .icon {
    width: 16px; height: 16px;
    opacity: 0.7;
}

.sidebar-user-popover-sep {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 0.3rem 0;
}

.sidebar-user-popover-logout { color: #f87171 !important; }
.sidebar-user-popover-logout:hover { background: rgba(239,68,68,0.1) !important; color: #fca5a5 !important; }

.sidebar-user-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    margin-top: 0.6rem;
}

.sidebar-user-quick-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    text-decoration: none;
    color: #cbd5e1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    transition: all var(--transition-fast);
}

.sidebar-user-quick-link:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.1);
    text-decoration: none;
}

.sidebar-user-quick-link-logout {
    color: #fda4af;
    border-color: rgba(239,68,68,0.24);
    background: rgba(239,68,68,0.12);
}

.sidebar-user-quick-link-logout:hover {
    color: #fecdd3;
    background: rgba(239,68,68,0.2);
}

/* ══════════════════════════════════════════
   TOPBAR — UPGRADED
   ══════════════════════════════════════════ */
.topbar-spacer { flex: 1; }

.topbar-title-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.topbar-module-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.topbar-search-kbd {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-family: var(--font-mono);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    color: var(--color-text-muted);
    pointer-events: none;
}

.topbar-icon-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.topbar-icon-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text);
}

.topbar-tenant-badge {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    padding: 0.3rem 0.85rem 0.3rem 0.6rem;
}

.topbar-tenant-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #10b981;
    flex-shrink: 0;
}

.topbar-tenant-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-avatar {
    width: 32px; height: 32px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
    cursor: pointer;
    display: none;
    text-decoration: none;
}

@media (max-width: 768px) {
    .topbar-tenant-badge { display: none; }
    .topbar-avatar { display: flex; }
    .topbar-icon-btn { display: none; }
}

/* ══════════════════════════════════════════
   SHORTCUTS GRID
   ══════════════════════════════════════════ */
.shortcuts-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.shortcut-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: var(--color-text-secondary);
}

.shortcut-row kbd {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 0.2rem 0.5rem;
    color: var(--color-text);
    white-space: nowrap;
    min-width: 70px;
    text-align: center;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════
   DASHBOARD — NEW COMPONENTS
   ══════════════════════════════════════════ */

/* Welcome bar */
.db-welcome {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.db-welcome-greeting {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.db-welcome-name {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.db-wave {
    font-style: normal;
    display: inline-block;
    animation: wave 2s ease-in-out;
    transform-origin: 70% 70%;
}

@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    20%       { transform: rotate(15deg); }
    40%       { transform: rotate(-5deg); }
    60%       { transform: rotate(10deg); }
    80%       { transform: rotate(-3deg); }
}

.db-welcome-date {
    font-size: 0.83rem;
    color: var(--color-text-muted);
}

.db-welcome-right {
    align-self: center;
}

.db-quick-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.db-quick-nav-label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.db-quick-nav-link {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.75rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.db-quick-nav-link:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary-100);
    color: var(--color-primary);
    text-decoration: none;
}

/* KPI Stats grid */
.db-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.db-stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 1.25rem 1.4rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    animation: cardIn var(--transition-slow) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.db-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient, var(--accent, var(--color-primary)));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.db-stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.db-stat-icon-wrap {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--accent, var(--color-primary)) 12%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent, var(--color-primary));
}

.db-stat-icon { width: 22px; height: 22px; }

.db-stat-body { flex: 1; min-width: 0; }

.db-stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--color-text);
    margin-bottom: 0.15rem;
}

.db-stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 0.3rem;
}

.db-stat-sub {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.db-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
}

.db-trend-up   { background: #ecfdf5; color: #059669; }
.db-trend-down { background: #fef2f2; color: #dc2626; }

/* Main grid layout */
.db-main-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.25rem;
}

@media (max-width: 1100px) {
    .db-main-grid { grid-template-columns: 1fr; }
}

/* Activity card */
.db-activity-card { height: fit-content; }

.db-empty-activity {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--color-text-muted);
}

.db-empty-activity svg {
    margin: 0 auto 1rem;
    opacity: 0.3;
}

.db-empty-activity p {
    font-size: 0.9rem;
    line-height: 1.6;
}

.db-activity-list {
    display: flex;
    flex-direction: column;
}

.db-activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--color-border-light);
    transition: background var(--transition-fast);
}

.db-activity-item:last-child { border-bottom: none; }
.db-activity-item:hover { background: var(--color-bg); }

.db-activity-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.db-activity-content { flex: 1; min-width: 0; }

.db-activity-title {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.2rem;
}

.db-activity-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    flex-wrap: wrap;
}

.db-activity-type {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.db-activity-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Right column */
.db-right-col {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Bar chart */
.db-bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.5rem;
    height: 120px;
    padding: 0 0.25rem;
}

.db-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    position: relative;
}

.db-bar-col:hover .db-bar-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }

.db-bar-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    background: var(--color-text);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 5px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: all 0.15s;
    pointer-events: none;
    z-index: 10;
}

.db-bar-tooltip::after {
    content: '';
    position: absolute;
    top: 100%; left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--color-text);
}

.db-bar {
    width: 100%;
    min-height: 4px;
    max-height: 100px;
    height: var(--pct, 10%);
    background: linear-gradient(180deg, var(--color-primary), var(--color-primary-500));
    border-radius: 5px 5px 0 0;
    transition: height var(--transition-slow);
    cursor: pointer;
}

.db-bar-col:hover .db-bar {
    background: linear-gradient(180deg, #818cf8, #6366f1);
}

.db-bar-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Modules grid */
.db-modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.6rem;
}

.db-module-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding: 0.75rem 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all var(--transition-fast);
    text-align: center;
}

.db-module-tile:hover {
    background: color-mix(in srgb, var(--mc, var(--color-primary)) 8%, white);
    border-color: color-mix(in srgb, var(--mc, var(--color-primary)) 25%, var(--color-border));
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.db-module-tile-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--mc, var(--color-primary)) 12%, white);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mc, var(--color-primary));
    flex-shrink: 0;
}

.db-module-tile-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    line-height: 1.3;
    text-align: center;
}

.db-module-tile:hover .db-module-tile-name {
    color: var(--mc, var(--color-primary));
}

/* ══════════════════════════════════════════
   SORT INDICATOR & TABLE ENHANCEMENTS
   ══════════════════════════════════════════ */
.sort-indicator {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.7rem;
    opacity: 0.7;
    vertical-align: middle;
}

th[data-sortable]:hover .sort-indicator { opacity: 1; }

th[data-sortable]::after {
    content: '⇅';
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.65rem;
    opacity: 0.25;
    vertical-align: middle;
}

th[data-sortable][data-sort]:not([data-sort=""])::after { display: none; }

/* ── Input counter ── */
.input-counter {
    display: block;
    text-align: right;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    margin-top: 0.2rem;
}

/* ── Toast types ── */
.toast-success { border-left: 3px solid #059669; }
.toast-error   { border-left: 3px solid #dc2626; }
.toast-warning { border-left: 3px solid #d97706; }
.toast-info    { border-left: 3px solid #0284c7; }

/* ── Page transition ── */
body { transition: opacity 0.15s ease; }

/* ── Focus ring improvements ── */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* ══════════════════════════════════════════
   FAVORITES SYSTEM
   ══════════════════════════════════════════ */

/* ── Sidebar Favorites ── */
.sidebar-favorites { padding: 0 0.5rem; }
.sidebar-favorites .sidebar-group-label {
    display: flex; align-items: center; gap: 0.4rem;
}
.sidebar-fav-dot {
    width: 8px; height: 8px;
    border-radius: 50%; flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}
.sidebar-fav-link {
    padding-left: 0.85rem !important;
}
.sidebar-fav-link .sidebar-fav-dot {
    margin-right: -0.35rem;
}

/* ── Favorite Star Button ── */
.fav-star-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    border: none; background: none;
    color: var(--color-text-muted);
    cursor: pointer; border-radius: var(--radius-full);
    transition: all 0.2s;
    padding: 0; flex-shrink: 0;
    position: relative; z-index: 2;
}
.fav-star-btn svg { width: 16px; height: 16px; }
.fav-star-btn:hover { color: #f59e0b; background: rgba(245,158,11,0.1); transform: scale(1.15); }
.fav-star-btn.fav-active { color: #f59e0b; }
.fav-star-btn.fav-active:hover { color: #d97706; background: rgba(245,158,11,0.1); }

@keyframes favPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}
.fav-star-btn.fav-pop { animation: favPop 0.35s ease; }

/* ── Dashboard Favorites Strip ── */
.dash-favs-section { margin-bottom: 1.5rem; }
.dash-favs-header {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.dash-favs-title {
    font-size: 0.82rem; font-weight: 700; color: var(--color-text-secondary);
    text-transform: uppercase; letter-spacing: 0.04em;
    display: flex; align-items: center; gap: 0.4rem;
}
.dash-favs-title svg { width: 14px; height: 14px; color: #f59e0b; }
.dash-favs-grid {
    display: flex; gap: 0.65rem; overflow-x: auto;
    padding-bottom: 0.5rem; scroll-snap-type: x mandatory;
    scrollbar-width: none;
}
.dash-favs-grid::-webkit-scrollbar { display: none; }
.dash-fav-chip {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.55rem 1rem 0.55rem 0.65rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none; white-space: nowrap;
    transition: all 0.2s; scroll-snap-align: start;
    min-width: max-content;
}
.dash-fav-chip:hover {
    border-color: color-mix(in srgb, var(--fc, var(--color-primary)) 35%, var(--color-border));
    background: color-mix(in srgb, var(--fc, var(--color-primary)) 6%, white);
    box-shadow: var(--shadow-sm); text-decoration: none;
    transform: translateY(-1px);
}
.dash-fav-chip-dot {
    width: 32px; height: 32px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--fc, var(--color-primary)) 14%, white);
    color: var(--fc, var(--color-primary)); flex-shrink: 0;
    font-weight: 800; font-size: 0.8rem;
}
.dash-fav-chip-dot img { width: 20px; height: 20px; object-fit: contain; }
.dash-fav-chip-name { font-size: 0.82rem; font-weight: 600; color: var(--color-text); }
.dash-fav-chip:hover .dash-fav-chip-name { color: var(--fc, var(--color-primary)); }

/* ══════════════════════════════════════════
   PRINT
   ══════════════════════════════════════════ */
@media print {
    .sidebar, .topbar, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    .btn, .form-actions, .search-bar, .pagination { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
