:root {
    --bg-color: #f4f6f8;
    --sidebar-bg: #1e1e2d;
    --card-bg: #ffffff;
    --text-primary: #1e1e2d;
    --text-muted: #a1a5b7;
    --border-color: #eff2f5;

    /* Brand Colors */
    --primary: #009ef7;
    --primary-light: rgba(0, 158, 247, 0.1);
    --success: #50cd89;
    --success-light: rgba(80, 205, 137, 0.1);
    --warning: #f1bc00;
    --danger: #f1416c;
    --danger-light: rgba(241, 65, 108, 0.1);
    --purple: #7239ea;
    --purple-light: rgba(114, 57, 234, 0.1);

    /* Shadows & Border Radius */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Transitions */
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: #fff;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 40px;
    padding: 0 12px;
    color: #fff;
}

.sidebar-logo i {
    color: var(--primary);
    font-size: 28px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #9899ac;
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-links li a i {
    font-size: 20px;
}

.nav-links li a:hover,
.nav-links li.active a {
    background-color: #2b2b40;
    color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    max-width: calc(100vw - 260px);
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-left p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    padding: 8px 16px;
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
}

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-size: 14px;
    font-weight: 600;
}

.user-info .role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Metrics Cards Section */
.cards-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.card-icon.blue {
    background-color: var(--primary-light);
    color: var(--primary);
}

.card-icon.green {
    background-color: var(--success-light);
    color: var(--success);
}

.card-icon.purple {
    background-color: var(--purple-light);
    color: var(--purple);
}

.card-icon.red {
    background-color: var(--danger-light);
    color: var(--danger);
}

.card-info h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.card-info p {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-container {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    position: relative;
    height: 300px;
    /* Fixed height para mantener proporciones */
}

.chart-container h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Table Section */
.top-clientes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.top-cliente-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
}

.top-cliente-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.tc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 12px;
}

.tc-header h4 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.tc-body {
    flex: 1;
}

.tc-prob {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.tc-prob strong {
    color: var(--text-primary);
    font-size: 16px;
}

.tc-motivos {
    list-style: none;
    margin-bottom: 24px;
}

.tc-motivos li {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.tc-footer {
    margin-top: auto;
}

.table-section {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.table-header-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.table-header-container h3 {
    font-size: 18px;
    font-weight: 600;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.filters input,
.filters select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    color: var(--text-primary);
    background-color: #fcfcfc;
    transition: var(--transition);
}

.filters input:focus,
.filters select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.table-responsive {
    overflow-x: auto;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.premium-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px dashed var(--border-color);
    cursor: pointer;
}

.premium-table tbody tr {
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.premium-table tbody tr:hover {
    background-color: #f9f9f9;
}

.premium-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-primary);
    vertical-align: middle;
}

.premium-table .text-center {
    text-align: center;
}

/* Status Badges */
.badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge.success {
    background-color: var(--success-light);
    color: var(--success);
}

.badge.danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

.badge.warning {
    background-color: rgba(241, 188, 0, 0.1);
    color: var(--warning);
}

.badge.primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.badge.purple {
    background-color: var(--purple-light);
    color: var(--purple);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(30, 30, 45, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 650px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hover);
    transform: translateY(20px);
    transition: var(--transition);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--danger);
}

.modal-content {
    padding: 24px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

.detail-item span {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

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

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

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

.btn-primary:hover {
    background-color: #008ae6;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-outline:hover {
    background-color: #f5f5f5;
    color: var(--text-primary);
}