:root {
    --bg-color: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7);
    --card-bg: rgba(30, 41, 59, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #10b981;
    --accent-hover: #059669;
    --border: rgba(255, 255, 255, 0.1);
    --blur: blur(16px);
}

.hidden {
    display: none !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(16, 185, 129, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.15), transparent 25%);
    color: var(--text-primary);
    min-height: 100vh;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: var(--blur);
    border-right: 1px solid var(--border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    z-index: 1001;
    transition: left 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.logo-icon {
    background: linear-gradient(135deg, #10b981, #3b82f6);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    border-left: 4px solid var(--accent);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
    gap: 1rem;
}

.mobile-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-name-header {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.logout-btn-header {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn-header:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.05);
}


.top-header h1 {
    font-size: 2rem;
    font-weight: 600;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.status-filters {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.filter-radio {
    cursor: pointer;
}

.filter-radio input {
    display: none;
}

.filter-radio span {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: inline-block;
    transition: all 0.2s;
}

.filter-radio input:checked+span {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 16px;
    transition: transform 0.3s;
}

.metric-card:hover {
    transform: translateY(-5px);
}

.metric-card h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    border-radius: 16px;
    position: relative;
    height: 350px;
}

.chart-body {
    flex: 1;
    min-height: 0;
    position: relative;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-header h3 {
    margin: 0;
    font-size: 1rem;
}

.expand-btn {
    background: var(--accent);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    z-index: 1000;
    position: relative;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.expand-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}


.chart-card h3 {
    margin: 0;
    font-weight: 500;
    color: var(--text-secondary);
}

.fade-span {
    grid-column: span 2;
}

/* Table */
.table-card {
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow-x: auto;
    /* Permite scroll horizontal si la tabla es grande */
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.5rem 0.6rem;
    /* Más compacto */
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.data-table th:last-child,
.data-table td:last-child {
    white-space: nowrap;
    width: 120px;
    /* Asegura espacio para Editar, Acciones, Borrar */
    text-align: right;
}

.data-table th {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.data-table th.sortable {
    cursor: pointer;
    transition: background 0.2s;
}

.data-table th.sortable:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.data-table th.sortable::after {
    content: ' ↕';
    opacity: 0.3;
    font-size: 0.7rem;
    margin-left: 4px;
}

.data-table th.active-sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

.data-table th.active-sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.ganada {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.badge.abierta {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.badge.perdida {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    margin-right: 0.15rem;
    padding: 0.3rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-2px);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1e293b;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.close:hover {
    color: white;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Timeline */
.timeline {
    margin-bottom: 2rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

.timeline-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 3px solid var(--accent);
}

.timeline-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Login */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f172a;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(16, 185, 129, 0.2), transparent 35%),
        radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.2), transparent 35%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 3rem;
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.logo-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.glass {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Responsive Mobile Styles */
@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 1001;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    body.sidebar-open .sidebar {
        left: 0 !important;
    }

    .main-content {
        padding: 1rem !important;
        width: 100%;
        overflow-x: hidden;
    }

    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding-bottom: 1rem;
    }

    .top-header h1 {
        font-size: 1.5rem;
    }

    .mobile-toggle {
        display: flex !important;
        position: absolute;
        right: 1rem;
        top: 1.5rem;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .user-name-header {
        display: none;
    }

    .form-row {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .modal-content {
        padding: 1.5rem;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .btn {
        width: 100%;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr !important;
    }

    .expand-btn {
        display: none !important;
    }

    .chart-card {
        grid-column: 1 / -1 !important;
        height: 300px !important;
    }

    .table-card {
        margin-top: 1rem;
        border-radius: 8px;
    }
}

/* Sidebar Footer styles removed */