/* Variables */
:root {
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --main-bg: #f1f5f9;
    --white: #ffffff;
    --primary: #3b82f6;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --gray: #9ca3af;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--main-bg);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

.app-container {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--white);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    width: 80%;
    max-width: 180px;
    height: auto;
    object-fit: contain;
}

.sidebar-nav {
    padding: 15px 0;
}

.nav-item {
    margin-bottom: 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--white);
    text-decoration: none;
    transition: all 0.3s;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--sidebar-hover);
    border-left: 4px solid var(--primary);
}

.nav-link i {
    width: 20px;
    font-size: 16px;
}

.nav-section {
    margin-bottom: 5px;
}

.nav-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.nav-toggle:hover {
    background-color: var(--sidebar-hover);
}

.toggle-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-content i {
    width: 20px;
    font-size: 16px;
}

.toggle-icon {
    transition: transform 0.3s;
    font-size: 12px;
}

.toggle-icon.rotated {
    transform: rotate(180deg);
}

.nav-submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: rgba(0,0,0,0.2);
}

.nav-submenu.show {
    max-height: 500px;
}

.nav-submenu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px 10px 52px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 14px;
}

.nav-submenu li a:hover {
    background-color: var(--sidebar-hover);
    color: var(--white);
}

.nav-submenu li a i {
    width: 16px;
    font-size: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    background-color: var(--white);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-btn {
    position: relative;
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    color: var(--text-secondary);
}

.icon-btn:hover {
    background-color: var(--main-bg);
}

.badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: var(--danger);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 15px;
    background-color: var(--main-bg);
    border-radius: 20px;
    cursor: pointer;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.username {
    font-weight: 500;
    font-size: 14px;
}

.user-menu i {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Dashboard Container */
.dashboard-container {
    padding: 30px;
    max-width: 100%;
    overflow-x: hidden;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Widget */
.widget {
    background-color: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    max-height: 800px;
}

.widget-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.widget-period {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--main-bg);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.widget-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ========== WIDGET 1: VENTAS ========== */
.metric-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--main-bg);
    border-radius: 8px;
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateX(4px);
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.metric-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.metric-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.metric-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.metric-sub {
    font-size: 11px;
    color: var(--text-secondary);
}

.progress-section {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--main-bg);
    border-radius: 8px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
}

.progress-percentage {
    font-weight: 700;
    color: var(--primary);
}

.progress-bar-container {
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.benefit-box {
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.benefit-box.positive {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border: 1px solid #6ee7b7;
}

.benefit-box.negative {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border: 1px solid #fca5a5;
}

.benefit-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.benefit-box.positive .benefit-header { color: #065f46; }
.benefit-box.negative .benefit-header { color: #991b1b; }

.benefit-value {
    font-size: 20px;
    font-weight: 700;
}

.benefit-box.positive .benefit-value { color: #065f46; }
.benefit-box.negative .benefit-value { color: #991b1b; }

/* ========== WIDGET 2: INVENTARIO ========== */
.stock-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stock-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: var(--main-bg);
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.stock-summary-item.critical {
    background: #fee2e2;
    border-color: #ef4444;
    animation: pulse-red 2s infinite;
}

.stock-summary-item.warning {
    background: #fef3c7;
    border-color: #f59e0b;
}

.stock-summary-item.low {
    background: #dbeafe;
    border-color: #3b82f6;
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.stock-icon { font-size: 20px; margin-bottom: 6px; }
.stock-summary-item.critical .stock-icon { color: #ef4444; }
.stock-summary-item.warning .stock-icon { color: #f59e0b; }
.stock-summary-item.low .stock-icon { color: #3b82f6; }

.stock-info { display: flex; flex-direction: column; }
.stock-count { font-size: 20px; font-weight: 700; line-height: 1; }
.stock-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }

.stock-alerts-list { margin-bottom: 20px; }
.stock-alerts-list h4 { font-size: 13px; margin-bottom: 12px; color: var(--text-primary); font-weight: 600; }

.stock-alert-item {
    padding: 10px;
    background: var(--main-bg);
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--gray);
}

.stock-alert-item:has(.stock-alert-badge.sin_stock) { border-left-color: #ef4444; }
.stock-alert-item:has(.stock-alert-badge.critico) { border-left-color: #f59e0b; }
.stock-alert-item:has(.stock-alert-badge.bajo) { border-left-color: #3b82f6; }

.stock-alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.stock-alert-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stock-alert-name small {
    color: var(--text-secondary);
    font-weight: 400;
    margin-right: 4px;
    font-size: 11px;
}

.stock-alert-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    margin-left: 8px;
}

.stock-alert-badge.sin_stock { background: #ef4444; color: white; }
.stock-alert-badge.critico { background: #f59e0b; color: white; }
.stock-alert-badge.bajo { background: #3b82f6; color: white; }

.stock-bar-container {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.stock-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.stock-alert-footer {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
}

.stock-alert-footer strong { color: var(--text-primary); }
.stock-alert-footer .faltante { color: #ef4444; font-weight: 600; }

.stock-ok {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #d1fae5;
    border-radius: 8px;
    color: #065f46;
    font-size: 13px;
    margin-bottom: 20px;
}

.stock-ok i { font-size: 18px; }

.expense-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.expense-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--main-bg);
    border-radius: 8px;
}

.expense-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.expense-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.expense-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }
.expense-value { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.activity-section { margin-top: 20px; max-height: 250px; overflow-y: auto; }
.activity-section h4 { font-size: 14px; margin-bottom: 12px; color: var(--text-primary); }

.activity-item {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.activity-info { flex: 1; }
.activity-info strong { display: block; font-size: 14px; margin-bottom: 3px; }
.activity-info p { font-size: 13px; color: var(--text-secondary); margin-bottom: 3px; }
.activity-time { font-size: 11px; color: var(--gray); }

/* ========== WIDGET 3: PROYECTOS Y RRHH ========== */
.projects-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.project-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: var(--main-bg);
    border-radius: 8px;
    text-align: center;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-bottom: 8px;
}

.stat-info { display: flex; flex-direction: column; }
.stat-number { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }

.chart-section {
    height: 150px;
    margin-bottom: 20px;
    position: relative;
}

.milestones {
    margin: 20px 0;
}

.milestones h4 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.milestones h4 i {
    color: var(--primary);
}

.milestone-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--main-bg);
    border-radius: 6px;
    margin-bottom: 8px;
}

.milestone-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.milestone-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.milestone-dot.blue { background-color: var(--primary); }
.milestone-dot.gray { background-color: var(--gray); }

.milestone-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.milestone-text strong {
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.milestone-text small {
    font-size: 11px;
    color: var(--text-secondary);
}

.milestone-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mini-progress-bar {
    width: 60px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.6s ease;
}

.progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 30px;
    text-align: right;
}

.empty-message {
    color: var(--gray);
    font-size: 13px;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.vacations-control {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.vacations-control h4 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.vacations-control h4 i {
    color: var(--warning);
}

.vacations-pending {
    background: #fef3c7;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
}

.pending-badge {
    display: inline-block;
    background: var(--warning);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    margin-bottom: 8px;
}

.vacation-request {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-top: 1px solid rgba(245, 158, 11, 0.2);
}

.vacation-info {
    display: flex;
    flex-direction: column;
}

.vacation-info strong {
    font-size: 13px;
    color: var(--text-primary);
}

.vacation-info small {
    font-size: 11px;
    color: var(--text-secondary);
}

.vacation-days {
    font-size: 12px;
    font-weight: 600;
    color: var(--warning);
}

.vacations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vacation-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vacation-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.vacation-details {
    flex: 1;
    min-width: 0;
}

.vacation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.vacation-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.vacation-count {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
}

.vacation-bar-container {
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.vacation-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}

/* ========== WIDGET 4: TAREAS Y CALENDARIO ========== */
.widget-tasks-calendar .widget-header {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.widget-tasks-calendar .widget-header h3 {
    color: white;
}

.btn-add-task {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s;
}

.btn-add-task:hover {
    background: rgba(255,255,255,0.3);
}

.tasks-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.task-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    background: var(--main-bg);
    border-radius: 6px;
    text-align: center;
    border-left: 3px solid var(--gray);
}

.task-stat.in-progress { border-left-color: var(--primary); }
.task-stat.completed { border-left-color: var(--success); }
.task-stat.overdue { border-left-color: var(--danger); }

.task-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.task-stat-label {
    font-size: 9px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 4px;
}

.tasks-section {
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.section-header h4 {
    font-size: 13px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-header h4 i {
    color: var(--primary);
}

.tasks-list {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.empty-tasks {
    text-align: center;
    padding: 20px;
    color: var(--gray);
}

.empty-tasks i {
    font-size: 32px;
    color: var(--success);
    margin-bottom: 8px;
}

.empty-tasks p {
    font-size: 13px;
    margin: 0;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--main-bg);
    border-radius: 6px;
    margin-bottom: 6px;
    border-left: 3px solid var(--gray);
    transition: all 0.2s;
    cursor: pointer;
}

.task-item:hover {
    transform: translateX(2px);
    box-shadow: var(--shadow);
}

.task-item.prioridad-urgente { border-left-color: #ef4444; }
.task-item.prioridad-alta { border-left-color: #f59e0b; }
.task-item.prioridad-media { border-left-color: #3b82f6; }
.task-item.prioridad-baja { border-left-color: #9ca3af; }

.task-item.overdue {
    background: #fef2f2;
}

.task-item.completed {
    opacity: 0.6;
}

.task-item.completed .task-title {
    text-decoration: line-through;
}

.task-checkbox {
    position: relative;
    flex-shrink: 0;
}

.task-complete-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: white;
}

.task-complete-checkbox:checked ~ .checkmark,
.task-complete-checkbox:checked + .checkmark {
    background: var(--success);
    border-color: var(--success);
}

.task-complete-checkbox:checked ~ .checkmark::after,
.task-complete-checkbox:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.task-checkbox:hover .checkmark {
    border-color: var(--primary);
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.task-project, .task-deadline {
    font-size: 10px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-deadline.overdue {
    color: var(--danger);
    font-weight: 600;
}

.priority-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.priority-badge.prioridad-urgente { background: #fee2e2; color: #991b1b; }
.priority-badge.prioridad-alta { background: #fef3c7; color: #92400e; }
.priority-badge.prioridad-media { background: #dbeafe; color: #1e40af; }
.priority-badge.prioridad-baja { background: #f3f4f6; color: #4b5563; }

/* Calendar */
.calendar-section {
    margin-top: 10px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 4px;
}

.calendar-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    text-transform: capitalize;
}

.calendar-nav-btn {
    background: var(--main-bg);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.calendar-nav-btn:hover {
    background: var(--primary);
    color: white;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    text-align: center;
}

.calendar-day-header {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 0;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1;
    padding: 4px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--main-bg);
}

.calendar-day:hover {
    background: #dbeafe;
    transform: scale(1.05);
}

.calendar-day.today {
    background: var(--primary);
    color: white;
    font-weight: 700;
}

.calendar-day.has-events {
    background: #dbeafe;
    color: var(--primary);
    font-weight: 600;
}

.calendar-day.today.has-events {
    background: var(--primary);
    color: white;
}

.calendar-day.has-events::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
}

.calendar-day.today.has-events::after {
    background: white;
}

.calendar-day.empty {
    visibility: hidden;
}

.calendar-day.other-month {
    opacity: 0.3;
}

/* ========== MODALES ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s;
}

.modal-small {
    max-width: 400px;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--main-bg);
    color: var(--danger);
}

.modal-body {
    padding: 20px;
}

form {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input[type="color"] {
    padding: 4px;
    height: 42px;
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    background: var(--main-bg);
    border-radius: 0 0 12px 12px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--main-bg);
}

/* Day details modal */
.day-event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--main-bg);
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--primary);
}

.day-event-item.task {
    border-left-color: var(--warning);
}

.day-event-item.meeting {
    border-left-color: var(--primary);
}

.day-event-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.day-event-item.task .day-event-icon {
    background: var(--warning);
}

.day-event-info {
    flex: 1;
    min-width: 0;
}

.day-event-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.day-event-time {
    font-size: 11px;
    color: var(--text-secondary);
}

.empty-day {
    text-align: center;
    padding: 20px;
    color: var(--gray);
    font-size: 13px;
}

.empty-day i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--text-primary);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 3000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    pointer-events: none;
    font-size: 14px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast i {
    font-size: 18px;
}

/* Scrollbars */
.sidebar::-webkit-scrollbar,
.widget-content::-webkit-scrollbar,
.tasks-list::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.dashboard-grid::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.widget-content::-webkit-scrollbar-track,
.tasks-list::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track,
.dashboard-grid::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-hover);
    border-radius: 3px;
}

.widget-content::-webkit-scrollbar-thumb,
.tasks-list::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb,
.dashboard-grid::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        max-height: none;
    }
    
    .widget {
        max-height: none;
    }
    
    .stock-summary,
    .projects-stats {
        grid-template-columns: 1fr;
    }
    
    .expense-summary {
        grid-template-columns: 1fr;
    }
    
    .tasks-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
    }
}

/* User info en topbar */
.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Badge de rol */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.role-badge.administrador { background: #dbeafe; color: #1e40af; }
.role-badge.jefe_departamento { background: #ede9fe; color: #5b21b6; }
.role-badge.jefe_proyecto { background: #d1fae5; color: #065f46; }
.role-badge.empleado { background: #f3f4f6; color: #4b5563; }

/* ============================================ */
/* FOTO DE USUARIO EN TOPBAR */
/* ============================================ */

.avatar-clickable {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s;
}

.avatar-clickable:hover {
    transform: scale(1.05);
}

.avatar-clickable:hover .avatar-edit-icon {
    opacity: 1;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.avatar-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    font-weight: 600;
    font-size: 13px;
}

.avatar-edit-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.avatar-edit-icon i {
    font-size: 8px;
    color: white;
}

.user-role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 2px;
}

/* ============================================ */
/* MODAL DE FOTO */
/* ============================================ */

.modal-foto {
    max-width: 480px;
}

.foto-modal-body {
    padding: 0 !important;
}

.foto-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 1px solid var(--border);
}

.foto-preview {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 4px solid white;
    margin-bottom: 20px;
}

.foto-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.foto-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--gray);
    gap: 8px;
}

.foto-preview-placeholder i {
    font-size: 48px;
    color: #cbd5e1;
}

.foto-preview-placeholder span {
    font-size: 13px;
    font-weight: 500;
}

.foto-info {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.foto-info strong {
    font-size: 18px;
    color: var(--text-primary);
}

.foto-info small {
    font-size: 13px;
    color: var(--text-secondary);
}

.foto-actions {
    padding: 25px 20px;
}

.foto-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.foto-buttons .btn {
    flex: 1;
    min-width: 140px;
    justify-content: center;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.foto-help {
    text-align: center;
    margin-top: 15px;
    color: var(--text-secondary);
}

.foto-help small {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
}

.foto-help i {
    color: var(--primary);
}

/* Loading overlay en foto */
.foto-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.foto-loading i {
    color: white;
    font-size: 32px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 480px) {
    .foto-preview {
        width: 120px;
        height: 120px;
    }
    
    .foto-buttons {
        flex-direction: column;
    }
    
    .foto-buttons .btn {
        width: 100%;
    }
}

/* ============================================ */
/* AVATAR DINÁMICO (foto o iniciales) */
/* ============================================ */

.avatar-dynamic {
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-dynamic-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Ajustar el contenedor de vacaciones para que el avatar se vea bien */
.vacation-avatar .avatar-dynamic {
    width: 32px !important;
    height: 32px !important;
}

/* Ajustar el contenedor de actividad */
.activity-item .avatar-dynamic {
    flex-shrink: 0;
}