:root {
    /* Colors */
    --bg-color: #f8fafd;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --brand-blue: #1d4ed8;
    --brand-purple: #5c43f6;
    --brand-green: #059669;
    --brand-green-bright: #00d27f;
    
    /* Icon wrapper backgrounds */
    --icon-green-bg: #e6f7ef;
    --icon-green-color: #059669;
    --icon-blue-bg: #eef2ff;
    --icon-blue-color: #3b82f6;
    --icon-orange-bg: #fff7ed;
    --icon-orange-color: #f59e0b;
    --icon-purple-bg: #f5f3ff;
    --icon-purple-color: #7c3aed;
    --icon-gray-bg: #f1f5f9;
    --icon-gray-color: #64748b;
    --icon-yellow-bg: #fefce8;
    --icon-yellow-color: #eab308;
    --icon-cyan-bg: #e0f2fe;
    --icon-cyan-color: #0ea5e9;
    --icon-blue-dark-bg: #dbeafe;
    --icon-blue-dark-color: #2563eb;
    
    /* Borders */
    --border-color: #e2e8f0;
    
    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

.mikpi-dashboard-container * {
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    margin: 0;
    width: 100%;
    min-height: 100%;
    box-sizing: border-box;
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
}

.app {
    width: 100%;
    min-height: 100dvh;
}

html.is-desktop #page-dashboard.active,
#page-dashboard.active {
    display: block !important;
    width: 100% !important;
}

body {
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

.mikpi-dashboard-container {
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 12px 24px;
    min-height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    color: var(--text-main);
}

.dashboard {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    color: #1e3a8a; /* Darker blue */
}

.logo-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    height: 42px;
    width: auto;
    display: block;
    object-fit: contain;
}

.logo i {
    color: #2563eb;
    font-size: 24px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    min-height: 46px;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    transition: background 0.2s;
}

.user-dropdown {
    top: calc(100% + 8px) !important; /* Push it below the user menu */
    background-color: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
    z-index: 9999 !important;
    border-radius: var(--radius-md) !important;
}

body.dark-mode .user-dropdown {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

.user-menu:hover {
    background: #f8fafc;
}

.user-avatar {
    background: var(--brand-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.user-avatar.sm {
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 14px;
}

.user-avatar.lg {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

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

.user-name {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.1;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.1;
    opacity: 0.75;
}

.user-menu > i {
    color: var(--text-muted);
    font-size: 14px;
    margin-left: 4px;
}

/* ==========================================================================
   HERO CARD
   ========================================================================== */
.hero-card {
    background-color: transparent;
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
    margin-bottom: 12px;
    color: white;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}
.hero-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('../img/sfe noche.jpeg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}
.hero-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(11, 17, 32, 0.95) 0%, rgba(11, 17, 32, 0.8) 40%, rgba(11, 17, 32, 0.4) 100%);
    z-index: 1;
}
.hero-card > * {
    position: relative;
    z-index: 2;
}

.hero-content {
    padding: 24px 32px;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 60%;
}

.hero-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hero-user-details h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wave {
    animation: wave 2.5s infinite;
    transform-origin: 70% 70%;
    display: inline-block;
}

@keyframes wave {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

.hero-user-details p {
    color: #94a3b8;
    font-size: 14px;
}

.hero-performance {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.performance-label {
    color: #94a3b8;
    font-size: 14px;
}

.performance-value-wrapper {
    display: flex;
    align-items: baseline;
    gap: 16px;
}

.performance-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--brand-green-bright);
    letter-spacing: -1px;
}

.badge.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--brand-green-bright);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge.success i {
    font-size: 16px;
}

.progress-bar-container {
    margin-top: 8px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    margin-bottom: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--brand-green-bright);
    border-radius: var(--radius-full);
    position: relative;
}

/* Little dot at the end of progress */
.progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--brand-green-bright);
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #94a3b8;
}


/* ==========================================================================
   STATS ROW
   ========================================================================== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.stat-card.combined-stat {
    flex-direction: row;
    gap: 0;
    padding: 0;
}

.stat-block {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.stat-divider {
    width: 1px;
    background-color: var(--border-color);
    margin: 12px 0;
}

.stat-icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.stat-value.green-text {
    color: var(--brand-green);
    font-size: 16px;
    margin-top: 2px;
}

.stat-subtext {
    font-size: 12px;
    color: var(--text-muted);
}


/* ==========================================================================
   MIDDLE ROW (Ranking & Accesos)
   ========================================================================== */
.middle-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.ranking-section, .shortcuts-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

h2 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
    padding-left: 4px;
}

.ranking-cards, .shortcuts-cards {
    display: flex;
    gap: 8px;
}

.ranking-card {
    flex: 1;
    background: var(--bg-color); /* Slight contrast against the section card */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ranking-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.ranking-details {
    display: flex;
    flex-direction: column;
}

.ranking-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.ranking-value {
    font-size: 15px;
    font-weight: 700;
}

/* Shortcuts Cards */
.shortcut-card {
    flex: 1;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.shortcut-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.shortcut-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.shortcut-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0; /* allows text truncation if needed */
}

.shortcut-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.shortcut-subtext {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chevron {
    color: var(--text-light);
    font-size: 16px;
}

/* ==========================================================================
   BOTTOM NAV ROW
   ========================================================================== */
.bottom-nav-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.nav-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.nav-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.nav-card .chevron {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s, right 0.2s;
}

.nav-card:hover .chevron {
    opacity: 1;
    right: 12px;
}

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

.nav-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-title {
    font-size: 14px;
    font-weight: 700;
}

.nav-subtext {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.nav-desc {
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.4;
}

/* ==========================================================================
   UTILITY COLOR CLASSES
   ========================================================================== */
.green-light { background-color: var(--icon-green-bg); color: var(--icon-green-color); }
.blue-light { background-color: var(--icon-blue-bg); color: var(--icon-blue-color); }
.blue-light-alt { background-color: #f0f9ff; color: #0284c7; } /* Sky */
.orange-light { background-color: var(--icon-orange-bg); color: var(--icon-orange-color); }
.purple-light { background-color: var(--icon-purple-bg); color: var(--icon-purple-color); }
.yellow-light { background-color: var(--icon-yellow-bg); color: var(--icon-yellow-color); }
.gray-light { background-color: var(--icon-gray-bg); color: var(--icon-gray-color); }
.cyan-light { background-color: var(--icon-cyan-bg); color: var(--icon-cyan-color); }

.blue-solid { background-color: #3b82f6; }
.cyan-solid { background-color: #0ea5e9; }
.blue-dark-solid { background-color: #2563eb; }

/* Responsive adjustments if needed */
@media (max-width: 1024px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .middle-row {
        grid-template-columns: 1fr;
    }
    .bottom-nav-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .bottom-nav-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .ranking-cards, .shortcuts-cards {
        flex-direction: column;
    }
    .hero-content {
        max-width: 100%;
        padding: 24px;
    }
    .stat-card.combined-stat {
        flex-direction: column;
    }
    .stat-divider {
        width: 100%;
        height: 1px;
        margin: 0;
    }
}

/* ==========================================================================
   DARK MODE OVERRIDES (MIKPI SPECIFIC)
   ========================================================================== */
body.dark-mode {
    /* Colors */
    --bg-color: #0B1424;
    --card-bg: #334155;
    --text-main: #F8FAFC;
    --text-muted: #CBD5E1;
    --text-light: #94A3B8;
    
    --brand-blue: #3B82F6;
    --brand-purple: #8B5CF6;
    --brand-green: #22C55E;
    --brand-green-bright: #22C55E;
    
    /* Icon wrapper backgrounds - adapted for dark mode */
    --icon-green-bg: rgba(34, 197, 94, 0.15);
    --icon-green-color: #22C55E;
    --icon-blue-bg: rgba(59, 130, 246, 0.15);
    --icon-blue-color: #3B82F6;
    --icon-orange-bg: rgba(245, 158, 11, 0.15);
    --icon-orange-color: #F59E0B;
    --icon-purple-bg: rgba(139, 92, 246, 0.15);
    --icon-purple-color: #A78BFA;
    --icon-gray-bg: rgba(148, 163, 184, 0.15);
    --icon-gray-color: #94A3B8;
    --icon-yellow-bg: rgba(250, 204, 21, 0.15);
    --icon-yellow-color: #FACC15;
    --icon-cyan-bg: rgba(56, 189, 248, 0.15);
    --icon-cyan-color: #38BDF8;
    --icon-blue-dark-bg: rgba(96, 165, 250, 0.15);
    --icon-blue-dark-color: #60A5FA;
    
    /* Borders */
    --border-color: #475569;
}

body.dark-mode {
    background-color: #0B1424 !important;
}

body.dark-mode .app {
    background-color: #0B1424 !important;
}

body.dark-mode .app-header {
    background-color: #111827 !important;
    border-bottom: 1px solid #334155 !important;
}

body.dark-mode .logo {
    color: #F8FAFC;
}

body.dark-mode .mikpi-dashboard-container {
    background-color: #0B1424;
}

body.dark-mode .card, 
body.dark-mode .stats-card {
    background: #334155;
    border-color: #475569;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body.dark-mode .hero-card {
    background: transparent;
    border: 1px solid #334155;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
body.dark-mode .hero-card::after {
    background: linear-gradient(90deg, rgba(5, 12, 28, 0.95) 0%, rgba(5, 12, 28, 0.85) 40%, rgba(5, 12, 28, 0.5) 100%);
}

body.dark-mode .hero-overlay {
    background: linear-gradient(90deg, #101B2D 0%, rgba(16,27,45,0.7) 50%, transparent 100%);
}

body.dark-mode .progress-bar-bg {
    background: #1A2638;
}

body.dark-mode .shortcut-card, 
body.dark-mode .nav-card {
    background: #243247;
    border-color: #475569;
}

body.dark-mode .shortcut-card:hover, 
body.dark-mode .nav-card:hover {
    background: #334155;
    border-color: #64748B;
}

body.dark-mode .bottom-nav-row {
    background: #1A2638;
    border-color: #334155;
}

body.dark-mode .user-menu {
    background: #243247;
    border-color: #475569;
}

body.dark-mode .user-menu:hover {
    background: #334155;
}

body.dark-mode .user-dropdown {
    background-color: #1A2638 !important;
    border-color: #334155 !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35) !important;
}

body.dark-mode .glass-btn {
    background: #243247;
    border-color: #475569;
    color: #F8FAFC;
}

body.dark-mode .glass-btn:hover {
    background: #334155;
}

body.dark-mode .page-header-wrap {
    background-color: #111827 !important;
    border-bottom-color: #334155 !important;
}

body.dark-mode #faq-modal > div {
    background-color: #101B2D !important;
    border-color: #334155 !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35) !important;
}

/* ANIMACIONES DE TRANSICION Y CARDS */
.dash-card,
.stat-card,
.stat-block,
.ranking-card,
.nav-card,
.shortcut-box {
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease !important;
}

/* Hover effect on desktop, except for nav-card to avoid bottom nav jumping */
@media (hover: hover) and (pointer: fine) {
  .dash-card:hover,
  .stat-card:hover,
  .stat-block:hover,
  .ranking-card:hover,
  .shortcut-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 35px rgba(15, 23, 42, 0.14) !important;
  }
}

.dash-card:active,
.stat-card:active,
.stat-block:active,
.ranking-card:active,
.nav-card:active,
.shortcut-box:active {
  transform: translateY(-1px) scale(0.98);
}

.app-content {
  animation: fadeInPage 0.35s ease both;
}

.app-content.is-leaving {
  animation: fadeOutPage 0.28s ease both;
}

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

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

@media (prefers-reduced-motion: reduce) {
  .dash-card, .stat-card, .stat-block, .ranking-card, .nav-card, .shortcut-box, .app-content {
    animation: none !important;
    transition: none !important;
  }
}