:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --bg-base: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(15, 23, 42, 0.6);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-panel: rgba(255, 255, 255, 0.7);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1);
    --input-bg: rgba(255, 255, 255, 0.8);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

body {
    background: var(--bg-base);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Utilidades de Centrado (Login) */
.centered-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.glass {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 24px;
    color: var(--text-main);
}

.card-login {
    width: 100%;
    max-width: 420px;
    padding: 3rem;
    text-align: center;
}

.card-login h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 2.5rem;
    letter-spacing: -0.05rem;
}

.card-login h1 span {
    color: var(--primary);
}

.theme-toggle {
    position: fixed;
    top: 25px;
    right: 25px;
    cursor: pointer;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.logo {
    transition: filter 0.3s ease;
}

[data-theme="dark"] .logo,
:root:not([data-theme="light"]) .logo {
    filter: invert(1) brightness(2);
}

/* Inputs y Botones */
.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input,
select {
    width: 100%;
    padding: 1rem 1.2rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: 0.3s;
}

select option {
    background: var(--bg-base);
    color: var(--text-main);
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.btn {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.3s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Layout SaaS con Sidebar */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: 0.3s;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

.content-area {
    flex: 1;
    padding: 3rem;
    background: var(--bg-base);
    overflow-y: auto;
}

/* Dashboard Premium Components */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.stat-trend {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.trend-up {
    color: #10b981;
}

.trend-down {
    color: #ef4444;
}

.chart-container {
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: 24px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    height: 350px;
}

/* Dashboard & Admin adjustment */
.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.panel-card {
    padding: 2.5rem;
    margin-bottom: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1.2rem 1rem;
    border-bottom: 1px solid var(--border);
}

.status-pill {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.status-error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sistema de Modales Glassmorphism */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 2.5rem;
    border-radius: 24px;
    width: 100%;
    max-width: 650px;
    box-shadow: var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Visor de Código / JSON */
.code-block {
    background: #0f172a;
    padding: 1.5rem;
    border-radius: 12px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #e2e8f0;
    overflow-x: auto;
    border: 1px solid var(--border);
    margin-top: 1rem;
}

/* Diagnóstico (Resultados de Test) */
.test-success-pill {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    margin-bottom: 1.5rem;
}

.diag-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.diag-item {
    background: var(--input-bg);
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.diag-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
}

.diag-value {
    font-weight: 700;
    font-size: 0.9rem;
}

/* Switches (Toggles) Modernos */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

/* Badge de Origen / Tipo */
.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--input-bg);
    border: 1px solid var(--border);
}

.badge-api {
    color: var(--primary);
    border-color: var(--primary);
}

/* Ajustes de Tabla de Entidades */
.entity-row:hover {
    background: rgba(139, 92, 246, 0.03);
}

.crud-group {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.crud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Scrollbars para modales */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

/* Sistema de Alertas Lynx */
.lynx-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.lynx-alert-box {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 20px;
    width: 380px;
    text-align: center;
    box-shadow: var(--shadow);
    transform: scale(0.9);
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lynx-alert-overlay.active {
    display: flex;
}

.lynx-alert-overlay.active .lynx-alert-box {
    transform: scale(1);
}

.lynx-alert-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.lynx-alert-title {
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.lynx-alert-msg {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.quick-menu-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: var(--glass-blur);
    transition: 0.3s;
    user-select: none;
}

.quick-menu-btn:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}