:root {
    --primary-dark: #1e1e3f;
    --accent-blue: #3b82f6;
    --success-green: #10b981;
    --bg-gray: #f3f4f6;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif; 
    background: var(--bg-gray); 
    color: #374151; 
    line-height: 1.5;
    font-display: swap;
}

body.sidebar-open {
    overflow: hidden;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e1b4b 100%);
    height: 100vh;
    position: fixed;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    padding: 25px 20px; 
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
}

/* Hide close button on desktop */
@media (min-width: 1024px) {
    .close-sidebar-btn {
        display: none;
    }
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.sidebar-logo { 
    max-width: 160px; 
    height: auto; 
    transition: transform 0.3s ease;
}

.sidebar-logo:hover {
    transform: scale(1.05);
}

.sidebar-title {
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    text-transform: uppercase;
    opacity: 0.8;
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    margin-top: 20px;
}

.user-profile { 
    padding: 20px; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
}

.user-profile .profile-container {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.user-avatar::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.user-avatar:hover {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.5);
}

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

.user-info span { 
    font-size: 10px; 
    letter-spacing: 1.5px; 
    color: #94a3b8; 
    text-transform: uppercase;
    font-weight: 700;
    opacity: 0.8;
}

.user-info strong { 
    display: block; 
    color: #f8fafc; 
    font-size: 15px; 
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    letter-spacing: -0.2px;
}

.nav-menu { 
    flex-grow: 1; 
    padding: 15px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    color: #cbd5e1;
    text-decoration: none;
    gap: 14px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 12px;
    margin-bottom: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-link i {
    font-size: 18px;
    transition: all 0.3s ease;
    width: 24px;
    text-align: center;
}

.nav-link:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05));
    color: #f1f5f9;
    transform: translateX(3px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.2);
}

.nav-link:hover i {
    transform: translateX(4px) scale(1.1);
    color: #60a5fa;
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.25), rgba(167, 139, 250, 0.15));
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.4);
    font-weight: 700;
}

.nav-link.active i {
    color: #60a5fa;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #3b82f6 0%, #a78bfa 100%);
    border-radius: 0 4px 4px 0;
}

.sidebar-footer { 
    padding: 20px; 
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.1);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}

.sidebar-footer a { 
    color: #94a3b8; 
    text-decoration: none; 
    font-size: 13px; 
    font-weight: 600;
    display: flex; 
    align-items: center; 
    gap: 10px; 
    padding: 12px 14px;
    border-radius: 10px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-footer a:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    transform: translateX(2px);
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar.open + .sidebar-overlay,
body.sidebar-open .sidebar-overlay { /* admin sidebar renders the overlay before the sidebar */
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    width: 100%;
    padding: 40px;
    max-width: 1200px;
    transition: margin-left 0.3s ease;
}

/* Common Headers */
.content-header { margin-bottom: 30px; }
.content-header h1 { font-size: 28px; color: #111827; margin-bottom: 8px; }
.content-header p { color: #6b7280; font-size: 14px; }

/* Dashboard / Panel */
.welcome-section { margin-bottom: 35px; }
.welcome-section h1 { font-size: 32px; font-weight: 700; color: var(--primary-dark); }
.welcome-section p { color: #6b7280; font-size: 15px; margin-top: 5px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 28px;
    border-radius: 24px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.12);
    border-color: var(--accent-blue);
}

.stat-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.icon-box {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
}

.stat-card:hover .icon-box {
    transform: scale(1.1) rotate(5deg);
}

.blue-light { background: #eff6ff; color: #3b82f6; }
.purple-light { background: #faf5ff; color: #a855f7; }
.green-light { background: #f0fdf4; color: #22c55e; }

.badge {
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: -0.2px;
}
.orange-bg { background: #fff7ed; color: #f97316; }
.yellow-bg { background: #fefce8; color: #eab308; }
.success-bg { background: #dcfce7; color: #15803d; }

.stat-card.completed {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    box-shadow: 0 20px 40px -10px rgba(16, 185, 129, 0.4);
}

.stat-card.completed::before {
    content: '';
    position: absolute;
    top: -20%;
    right: -10%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    pointer-events: none;
}

.stat-card.completed h2, 
.stat-card.completed p, 
.stat-card.completed .card-header .badge {
    color: white;
}

.stat-card.completed .card-header .badge {
    background: rgba(255, 255, 255, 0.25);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}

.stat-card.completed .icon-box {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.stat-card.completed .progress-container {
    background: rgba(255, 255, 255, 0.2);
}

.stat-card.completed .progress-bar {
    background: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

.stat-card h2 { 
    font-size: 28px; 
    font-weight: 800; 
    color: #0f172a; 
    margin-bottom: 6px; 
    letter-spacing: -0.5px;
}

.stat-card p { 
    color: #64748b; 
    font-size: 15px; 
    font-weight: 500;
}

.progress-container {
    width: 100%;
    height: 8px;
    background: #f3f4f6;
    border-radius: 10px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-bar { height: 100%; border-radius: 10px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }
.blue-bar { background: var(--accent-blue); }
.cyan-bar { background: #06b6d4; }
.dark-blue-bar { background: var(--primary-dark); }

/* General Progress Card */
.general-progress-card {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.general-progress-card .card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
}

.icon-box-sm { background: #f1f5f9; padding: 10px; border-radius: 8px; color: #64748b; font-size: 18px; }

.progress-item { margin-bottom: 25px; }
.progress-item:last-child { margin-bottom: 0; }

.label-group {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #4b5563;
    margin-bottom: 10px;
}
.pct { font-weight: 700; color: var(--primary-dark); }
.progress-container.large { height: 12px; }

/* Document Cards - Premium Redesign */
.document-grid { margin-top: 20px; }

.doc-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    border-radius: 16px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    padding: 20px 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border: 1px solid rgba(226, 232, 240, 0.6);
}

.doc-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.doc-card:hover {
    transform: translateX(8px) translateY(-2px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.95) 100%);
}

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

.doc-card.completed {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(34, 197, 94, 0.05) 100%);
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.doc-card.completed::before {
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.6), transparent);
}

.doc-card.completed:hover {
    transform: translateX(8px) translateY(-2px);
    box-shadow: 0 20px 50px rgba(16, 185, 129, 0.25), 0 6px 16px rgba(0, 0, 0, 0.12);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(34, 197, 94, 0.08) 100%);
}

.doc-card.completed .status { 
    color: var(--success-green); 
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.doc-card.completed .details .title {
    color: #059669;
    font-weight: 700;
}

.doc-card.completed .details .file-name {
    color: #0f766e;
}

.doc-card.completed .status-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.status { font-size: 22px; margin-right: 20px; color: #d1d5db; }
.details { flex-grow: 1; }
.details .title { display: block; font-weight: 600; font-size: 16px; color: #1f2937; }
.details .doc-desc { display: block; font-size: 13px; line-height: 1.4; color: #4b5563; margin-top: 2px; }
.details .file-name { font-size: 13px; color: #6b7280; margin-top: 4px; display: flex; align-items: center; gap: 6px; }

.status-badge {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.status-badge.uploaded { background: #f1f5f9; color: #475569; }
.status-badge.pendiente { background: #fefce8; color: #a16207; }
.status-badge.validado { background: #f0fdf4; color: #15803d; }
.status-badge.rechazado { background: #fef2f2; color: #b91c1c; }

.sync-badge { padding: 2px 6px; border-radius: 4px; font-size: 14px; display: inline-flex; align-items: center; }
/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    text-decoration: none;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-primary { 
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white; 
}
.btn-primary:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3); 
    filter: brightness(1.1);
}

.btn-secondary { 
    background: white; 
    color: #475569; 
    border: 1px solid #e2e8f0;
}
.btn-secondary:hover { 
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
    transform: translateY(-1px);
}

.btn-dark { 
    background: var(--primary-dark); 
    color: white; 
}
.btn-dark:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 8px 20px rgba(30, 30, 63, 0.3);
    background: #2d2d5a;
}

.btn-success { 
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white; 
}
.btn-success:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3); 
}

.btn-danger { 
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white; 
}
.btn-danger:hover { 
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn:disabled, .btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Updated action-btn to use new styles */
.action-btn {
    cursor: pointer;
    background: white;
    border: 1.5px solid #e2e8f0;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.action-btn i, .action-btn span, .btn i, .btn span {
    pointer-events: none;
}

.action-btn input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    left: 0;
    top: 0;
    z-index: 10;
}

.action-btn.upload { 
    background: var(--primary-dark); 
    color: white; 
    border: none; 
}
.action-btn.upload:hover { 
    background: #2d2d5a; 
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(30, 30, 63, 0.2); 
}

.action-btn.replace { 
    background: #f8fafc; 
    color: #475569; 
    border: 1.5px solid #e2e8f0; 
}
.action-btn.replace:hover { 
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}

.action-btn.loading {
    background: #94a3b8 !important;
    color: white !important;
    border: none !important;
    cursor: wait !important;
}

.action-btn i {
    font-size: 16px;
}

.info-bar {
    margin-top: 35px;
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    gap: 15px;
    align-items: center;
    color: #64748b;
    border: 1px solid #e2e8f0;
    justify-content: space-between;
    flex-wrap: wrap;
}

.info-bar > div:first-child {
    display: flex;
    gap: 15px;
    align-items: center;
    flex: 1;
}

.bulk-upload-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.info-bar i { font-size: 24px; color: var(--accent-blue); }

/* Weekly Grid */
.weeks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.week-card {
    background: white;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.week-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-color: #bfdbfe;
}

.week-card.completed { border-color: var(--success-green); }

/* Keyboard focus on clickable cards */
.week-card:focus-visible,
.stat-card:focus-visible,
.progress-item:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 3px;
}
.week-header { display: flex; align-items: center; gap: 10px; color: #9ca3af; font-size: 14px; }
.week-card.completed .week-header { color: var(--success-green); }
.week-number { font-size: 32px; font-weight: 800; margin-top: 8px; color: #1f2937; }
.week-edit-hint { margin-top: 6px; font-size: 12px; font-weight: 600; color: #059669; display: flex; align-items: center; gap: 4px; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.7);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 580px;
    border-radius: 20px;
    padding: 35px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.title-group { display: flex; align-items: center; gap: 12px; font-size: 20px; color: var(--primary-dark); font-weight: 700; }
.close-modal { background: #f1f5f9; border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; color: #64748b; transition: all 0.2s; }
.close-modal:hover { background: #e2e8f0; color: #1e293b; }

.modal-body label { display: block; margin-bottom: 10px; font-weight: 600; font-size: 14px; color: #475569; }

textarea {
    width: 100%;
    height: 160px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 25px;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    transition: border-color 0.2s;
}

textarea:focus { outline: none; border-color: var(--accent-blue); }

.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
    cursor: pointer;
    margin-bottom: 30px;
    transition: all 0.2s;
}

.drop-zone:hover { background: #f8fafc; border-color: var(--accent-blue); color: var(--accent-blue); }
.drop-zone i { font-size: 32px; display: block; margin-bottom: 12px; }

.btn-submit {
    width: 100%;
    padding: 16px;
    background: var(--primary-dark);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-submit:hover { background: #2d2d5a; transform: translateY(-2px); }

/* Diary */
.diary-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.btn-new-entry {
    background: var(--primary-dark);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.btn-new-entry:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.diary-form-card {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
    border: 1px solid #f1f5f9;
}

.form-row { display: flex; gap: 25px; margin-bottom: 20px; }
.form-group { flex: 1; }
.form-group label { display: block; font-size: 14px; font-weight: 600; color: #475569; margin-bottom: 8px; }

.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
}

.form-actions { display: flex; gap: 12px; margin-top: 25px; }

.btn-save { background: var(--primary-dark); color: white; border: none; padding: 12px 30px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.btn-cancel { background: #f1f5f9; color: #475569; border: none; padding: 12px 30px; border-radius: 8px; font-weight: 600; cursor: pointer; }

/* Entry List Items */
.entry-item {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.entry-item:hover { border-color: #e2e8f0; }

.entry-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.date-badge { background: #e0f2fe; color: #0369a1; padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.btn-delete { background: #fef2f2; border: none; color: #ef4444; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-delete:hover { background: #fee2e2; color: #dc2626; }

.entry-title { font-size: 18px; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.entry-text { color: #64748b; font-size: 15px; line-height: 1.6; }

/* Auth Pages Styles */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1e3f 0%, #2d2d5a 100%);
    padding: 20px;
}

.auth-card {
    background: white;
    width: 100%;
    max-width: 450px;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.auth-header { text-align: center; margin-bottom: 30px; }
.auth-header h1 { color: var(--primary-dark); font-size: 28px; margin-bottom: 10px; }
.auth-header p { color: #64748b; font-size: 14px; }

.auth-form .form-group { margin-bottom: 20px; }
.auth-form label { display: block; font-size: 14px; font-weight: 600; color: #475569; margin-bottom: 8px; }
.auth-form input, .auth-form select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.2s;
}
.auth-form input:focus { border-color: var(--accent-blue); outline: none; }

.btn-auth {
    width: 100%;
    padding: 14px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin-top: 10px;
}
.btn-auth:hover { background: #2563eb; transform: translateY(-2px); }

.auth-footer { text-align: center; margin-top: 25px; font-size: 14px; color: #64748b; }
.auth-footer a { color: var(--accent-blue); font-weight: 600; text-decoration: none; }

/* Bulk Upload Styles */
.bulk-upload-section {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.bulk-upload-btn {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.bulk-upload-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.bulk-upload-btn.uploading {
    background: #f59e0b;
    cursor: not-allowed;
}

.bulk-upload-btn.uploading:hover {
    background: #f59e0b;
    transform: none;
    box-shadow: none;
}

@media (max-width: 480px) {
    .auth-card { padding: 30px 20px; }
}

.mobile-header {
    display: none;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #0f172a;
    padding: 0 16px;
    height: 60px;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 2001; /* Above sidebar z-index (2000) */
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    width: 100%;
    box-sizing: border-box;
}

.mobile-logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0; /* Allow shrinking */
    overflow: hidden;
    max-width: calc(100% - 56px); /* Reserve space for hamburger button */
}

.mobile-logo-img {
    height: 36px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    transition: transform 0.3s ease;
    flex-shrink: 0; /* Prevent logo from shrinking */
}

.mobile-logo-img:hover {
    transform: scale(1.05);
}

.mobile-logo-text {
    font-weight: 800;
    font-size: 14px;
    letter-spacing: -0.3px;
    color: #1e1e3f;
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1; /* Take remaining space */
    min-width: 0; /* Allow text to shrink */
}

.mobile-logo-text span {
    color: #3b82f6;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.hamburger-btn {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    color: #1e293b;
    font-size: 24px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0; /* Prevent button from shrinking */
    margin-left: 8px;
}

.hamburger-btn:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    transform: scale(1.05) translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.hamburger-btn:active {
    transform: scale(0.95) translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.hamburger-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Small Mobile Optimization */
@media (max-width: 360px) {
    .mobile-header {
        padding: 0 12px;
        height: 56px;
    }
    
    .mobile-logo-section {
        gap: 8px;
        max-width: calc(100% - 52px); /* Adjust for smaller button */
    }
    
    .mobile-logo-img {
        height: 32px;
    }
    
    .mobile-logo-text {
        font-size: 12px;
        letter-spacing: -0.2px;
    }
    
    .hamburger-btn {
        width: 36px;
        height: 36px;
        font-size: 22px;
        margin-left: 6px;
    }
}

/* Ensure main content doesn't overlap with mobile header */
@media (max-width: 767px) {
    .main-content {
        margin-top: 0; /* Sticky mobile header already takes its own space in the flow */
        margin-left: 0; /* No sidebar on mobile */
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Ensure no horizontal scrolling */
    body {
        overflow-x: hidden;
    }
    
    /* Stack sections vertically */
    .welcome-section,
    .stats-grid,
    .general-progress-card,
    .document-grid,
    .info-bar,
    .weeks-grid,
    .diary-form-card,
    .entry-item {
        width: 100%;
        box-sizing: border-box;
    }
}

/* Sidebar slide from left to right */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e1b4b 100%);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%); /* Hidden by default off-screen on the left */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2000;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    will-change: transform; /* Optimize for animation */
}

.sidebar.open {
    transform: translateX(0); /* Slides in from left to 0 position */
}

/* Ensure sidebar is visible when open */
.sidebar.open {
    visibility: visible;
}

/* Desktop - Always visible */
@media (min-width: 1024px) {
    .sidebar {
        visibility: visible;
        transform: translateX(0);
    }
}

/* Mobile - Hidden by default, visible when open */
@media (max-width: 1023px) {
    .sidebar {
        visibility: hidden;
    }
    
    .sidebar.open {
        visibility: visible;
    }
}

/* Desktop - Always visible */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0); /* Always visible on desktop */
        position: fixed;
        width: var(--sidebar-width);
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
    }
}

/* Tablet - Collapsed by default */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Stack the in-container mobile header (alumno pages) above the content */
    .dashboard-container {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
        z-index: 1001; /* Below sidebar + overlay so the open menu isn't covered */
    }
    
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 30px;
    }
    
    /* Adjust nav-link for tablet */
    .nav-link {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .user-info strong {
        font-size: 14px;
        max-width: 140px;
    }
}

/* Mobile - Collapsed by default */
@media (max-width: 767px) {
    .dashboard-container {
        flex-direction: column;
    }

    .mobile-header {
        display: flex !important;
        z-index: 1001;
    }
    
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        height: 100vh;
        overflow-y: auto;
        -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
        width: 100%;
        box-sizing: border-box;
        min-height: calc(100vh - 60px);
    }
    
    /* Scoped Alumno Dashboard Improvements */
    .dashboard-alumno .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .dashboard-alumno .stat-card {
        padding: 20px;
    }

    .dashboard-alumno .welcome-section {
        margin-bottom: 25px;
    }

    .dashboard-alumno .welcome-section h1 {
        font-size: 24px;
    }

    .dashboard-alumno .general-progress-card {
        padding: 20px;
    }
    
    /* Mobile nav-link adjustments */
    .nav-link {
        padding: 12px 16px;
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .nav-link:hover {
        transform: translateX(2px);
    }
    
    .user-profile {
        padding: 15px;
    }
    
    .user-info strong {
        font-size: 14px;
        max-width: 160px;
    }
    
    .sidebar-header {
        padding: 20px 15px;
    }
    
    .sidebar-logo {
        max-width: 100px;
    }
    
    .sidebar-title {
        font-size: 11px;
    }
    
    .sidebar-footer {
        padding: 15px;
    }
    
    .sidebar-footer a {
        font-size: 12px;
        padding: 8px 10px;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 480px) {
    .sidebar {
        width: 260px;
    }
    
    .nav-link {
        padding: 10px 14px;
        font-size: 13px;
        gap: 12px;
    }
    
    .nav-link i {
        font-size: 16px;
    }
    
    .user-info strong {
        font-size: 13px;
        max-width: 120px;
    }
    
    .sidebar-header {
        padding: 15px 12px;
    }
    
    .sidebar-logo {
        max-width: 90px;
    }
    
    .sidebar-footer a {
        font-size: 11px;
        padding: 6px 8px;
    }
}

/* Tablet Scale (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .main-content { padding: 40px; }
}

/* TV / Ultra Large Screens (> 1920px) */
@media (min-width: 1921px) {
    :root { --sidebar-width: 320px; }
    body { font-size: 18px; }
    .main-content { max-width: 1600px; padding: 60px; }
    .welcome-section h1 { font-size: 48px; }
    .stat-card h2 { font-size: 36px; }
    .nav-link { padding: 18px 30px; font-size: 18px; }
}

@media (max-width: 480px) {
    .content-header h1 { font-size: 24px; }
    .welcome-section h1 { font-size: 26px; }
    .modal-content { padding: 25px; }

    .bulk-upload-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }
}

/* Notification System */
#notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.notification {
    min-width: 300px;
    max-width: 400px;
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: notificationSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

@keyframes notificationSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification.fade-out {
    animation: notificationFadeOut 0.4s forwards;
}

@keyframes notificationFadeOut {
    to { transform: translateX(100%); opacity: 0; }
}

.notification i { font-size: 20px; }
.notification.success i { color: var(--success-green); }
.notification.error i { color: #ef4444; }
.notification.info i { color: var(--accent-blue); }
.notification.warning i { color: #f59e0b; }

.notification-content { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* Close (X) button */
.notification-close {
    flex-shrink: 0;
    align-self: flex-start;
    width: 32px;
    height: 32px;
    margin: -6px -10px 0 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notification-close:hover,
.notification-close:focus-visible { background: #f1f5f9; color: #334155; }
.notification-close i { font-size: 14px; color: inherit !important; }

/* Paused while the mouse is over the notification */
.notification { cursor: pointer; }
.notification.paused .notification-progress-bar { animation-play-state: paused; }

/* Respect the system 'reduce motion' setting */
@media (prefers-reduced-motion: reduce) {
    .notification,
    .notification.fade-out { animation-duration: 0.01ms; }
}
.notification-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.notification-message { font-size: 13px; color: #64748b; }

.notification-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(0,0,0,0.1);
    width: 100%;
}

.notification-progress-bar {
    height: 100%;
    background: inherit;
    width: 100%;
    animation: notificationProgress 6s linear forwards;
}

.notification.success .notification-progress-bar { background: var(--success-green); }
.notification.error .notification-progress-bar { background: #ef4444; }
.notification.info .notification-progress-bar { background: var(--accent-blue); }
.notification.warning .notification-progress-bar { background: #f59e0b; }

@keyframes notificationProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ==========================================================================
   Mobile & touch devices (iPhone / Android)
   ========================================================================== */

/* Dynamic viewport units: 100vh on mobile browsers includes the area behind
   the address/tool bars, which hid the bottom of the sidebar (logout link). */
@supports (height: 100dvh) {
    .dashboard-container { min-height: 100dvh; }
    .sidebar, .sidebar-overlay { height: 100dvh; }
}

/* Sidebar close button (was never visible on phones) */
.sidebar-header { position: relative; }

.close-sidebar-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    font-size: 18px;
    cursor: pointer;
}

@media (min-width: 1024px) {
    .close-sidebar-btn { display: none; }
}

/* Keep scrolling inside the open menu instead of the page behind it */
.sidebar {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.sidebar-overlay { touch-action: none; }
.sidebar-footer { padding-bottom: max(20px, env(safe-area-inset-bottom)); }

/* Modals: scroll inside on short screens / when the keyboard is open */
.modal-content {
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
@supports (height: 100dvh) {
    .modal-content { max-height: calc(100dvh - 40px); }
}

@media (pointer: coarse) {
    /* iOS Safari zooms into any field with font-size < 16px */
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Minimum comfortable tap target */
    .hamburger-btn {
        width: 44px;
        height: 44px;
    }

    .notification-close {
        width: 40px;
        height: 40px;
    }
}

/* On touch screens :hover sticks after a tap; cancel the hover movement */
@media (hover: none) {
    .sidebar-logo:hover,
    .user-avatar:hover,
    .nav-link:hover,
    .nav-link:hover i,
    .sidebar-footer a:hover,
    .stat-card:hover,
    .stat-card:hover .icon-box,
    .stat-card:hover .icon-box i,
    .doc-card:hover,
    .doc-card.completed:hover,
    .btn-primary:hover,
    .btn-secondary:hover,
    .btn-dark:hover,
    .btn-success:hover,
    .btn-danger:hover,
    .action-btn.upload:hover,
    .week-card:hover,
    .btn-submit:hover,
    .btn-auth:hover,
    .bulk-upload-btn:hover,
    .mobile-logo-img:hover,
    .hamburger-btn:hover,
    .student-card:hover,
    .btn-download-all:hover,
    .btn-download-all:hover i,
    .grado-item:hover,
    .especialidad-item:hover,
    .guide-card:hover,
    .guide-card:hover .card-icon,
    .memoria-status-card:hover,
    .upload-zone:hover,
    .upload-zone:hover .upload-icon,
    .upload-btn:hover,
    .btn-edit:hover,
    .btn-delete:hover,
    .grado-card:hover,
    .btn-save:hover {
        transform: none;
    }
}

@media (max-width: 480px) {
    /* Toasts span the screen width instead of overflowing on 320-375px phones */
    #notification-container {
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
    }
    .notification {
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    #copyright-modal .modal-content {
        padding: 28px 20px !important;
    }

    /* Document cards: button drops below the text instead of overflowing */
    .doc-card {
        flex-wrap: wrap;
        padding: 16px;
    }
    .doc-card .details {
        min-width: 0;
        flex-basis: calc(100% - 60px);
    }
    .doc-card .details .file-name {
        word-break: break-word;
    }
    .doc-card .action-btn {
        width: 100%;
        justify-content: center;
        margin-top: 12px;
    }
}
