:root {
    --primary: #0072CE;
    --primary-light: #E6F2FF;
    --primary-dark: #005bb5;
    --bg-body: #F1F5F9;
    --bg-white: #FFFFFF;
    --text-main: #1C2434;
    --text-body: #64748B;
    --border-color: #E2E8F0;
    --success: #219653;
    --success-bg: #EBFBF0;
    --danger: #D34053;
    --danger-bg: #FDF2F4;
    --warning: #FFA70B;
    --warning-bg: #FFF8EA;
    --sidebar-width: 280px;
    --header-height: 80px;
}

body {
    margin: 0; 
    font-family: 'Inter', sans-serif; 
    background: var(--bg-body); 
    color: var(--text-main); 
    font-size: 15px;
    overflow: hidden; 
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

.dashboard-wrapper { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(226, 232, 240, 0.6);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 50;
    transition: transform 0.3s ease, width 0.3s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
}

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    background: linear-gradient(180deg, #F0F7FF 0%, rgba(255, 255, 255, 0) 100%);
    border-bottom: 1px solid rgba(226, 232, 240, 0.4);
}
.sidebar-logo img { height: 38px; width: auto; max-width: 180px; object-fit: contain; transition: transform 0.3s; }
.sidebar-logo:hover img { transform: scale(1.05); }

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 1.2rem;
}

/* Legacy label - hidden, replaced by collapsible groups */
.menu-group-label {
    font-size: 0.7rem;
    color: #94A3B8;
    font-weight: 700;
    text-transform: uppercase;
    margin: 1.5rem 0 0.5rem 1rem;
    letter-spacing: 0.8px;
}

/* Collapsible Menu Groups */
.menu-group {
    margin-bottom: 2px;
}

.menu-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    margin-bottom: 2px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-body);
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    user-select: none;
}

.menu-group-header:hover {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.menu-group-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-group-header-left .nav-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
    flex-shrink: 0;
}

.menu-chevron {
    width: 16px;
    height: 16px;
    stroke-width: 2px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #94A3B8;
    flex-shrink: 0;
}

.menu-group.expanded .menu-chevron {
    transform: rotate(90deg);
}

.menu-group.expanded .menu-group-header {
    color: var(--text-body);
    background: transparent;
}

.menu-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding-left: 0.5rem;
}

.menu-group.expanded .menu-group-items {
    max-height: 1000px;
}

.nav-sub-item {
    padding-left: 2.5rem !important;
    font-size: 0.9em;
}

.nav-sub-item .nav-icon {
    width: 17px;
    height: 17px;
}

/* Nested Sub-Groups within menu groups */
.nav-sub-group {
    margin-bottom: 2px;
}

.nav-sub-group-toggle {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
}

.nav-sub-group-toggle span {
    flex: 1;
}

.sub-group-chevron {
    width: 14px;
    height: 14px;
    stroke-width: 2px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #94A3B8;
    flex-shrink: 0;
    margin-left: auto;
}

.nav-sub-group.expanded .sub-group-chevron {
    transform: rotate(90deg);
}

.nav-sub-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-sub-group.expanded .nav-sub-group-items {
    max-height: 300px;
}

.nav-nested-item {
    padding-left: 3.8rem !important;
    font-size: 0.85em;
}

.nav-item {
    display: flex;
    align-items: center;
    color: var(--text-body);
    padding: 0.85rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.nav-icon { 
    width: 20px; 
    height: 20px; 
    margin-right: 1rem; 
    stroke-width: 2px;
    transition: color 0.3s;
}

.nav-item:hover {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(0, 114, 206, 0.08) 0%, rgba(0, 114, 206, 0.02) 100%);
    color: var(--primary);
    border: 1px solid rgba(0, 114, 206, 0.1);
    box-shadow: 0 4px 15px rgba(0, 114, 206, 0.1);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    bottom: 15%;
    width: 4px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.main-area { flex: 1; display: flex; flex-direction: column; position: relative; overflow: hidden; }

.top-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 20px rgba(0,0,0,0.01);
    z-index: 40;
    position: sticky;
    top: 0;
}

.header-left { display: flex; align-items: center; }

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    margin-right: 15px;
    padding: 5px;
}

.header-title h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.header-title p { font-size: 0.875rem; color: var(--text-body); margin: 4px 0 0 0; }

.header-controls { display: flex; gap: 1rem; align-items: center; }

.time-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    background: white;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}
.time-select:focus { border-color: var(--primary); }

.user-profile { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    cursor: pointer; 
    padding: 6px 12px;
    border-radius: 30px;
    transition: background 0.2s;
}
.user-profile:hover { background: rgba(0,0,0,0.03); }

.user-avatar { 
    width: 38px; 
    height: 38px; 
    background: linear-gradient(135deg, var(--primary) 0%, #4a90e2 100%); 
    color: white; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-weight: 600; 
    box-shadow: 0 4px 10px rgba(0, 114, 206, 0.25);
}

.content-body { 
    flex: 1; 
    overflow-y: auto; 
    padding: 2rem; 
    background: var(--bg-body);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 45;
    backdrop-filter: blur(2px);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.col-span-4 { grid-column: span 4; }
.col-span-3 { grid-column: span 3; }
.col-span-2 { grid-column: span 2; }
.col-span-1 { grid-column: span 1; }

.card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
    min-width: 0;
}

.card:hover { transform: translateY(-2px); box-shadow: 0 4px 6px rgba(0,0,0,0.05); }

.card-stat { position: relative; overflow: hidden; }
.stat-icon-circle {
    width: 48px; height: 48px; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 1rem;
}
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-main); margin: 0 0 5px 0; }
.stat-label { font-size: 0.875rem; color: var(--text-body); font-weight: 500; }

.stat-meta {
    display: flex; align-items: center; gap: 5px; font-size: 0.75rem; font-weight: 600; margin-top: 10px;
}
.meta-up { color: var(--success); background: var(--success-bg); padding: 2px 8px; border-radius: 4px; }
.meta-down { color: var(--danger); background: var(--danger-bg); padding: 2px 8px; border-radius: 4px; }
.meta-neutral { color: var(--warning); background: var(--warning-bg); padding: 2px 8px; border-radius: 4px; }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.card-title { font-size: 1.1rem; font-weight: 700; margin: 0; }

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-top: 10px;
}

.styled-table { 
    width: 100%; 
    min-width: 600px;
    border-collapse: collapse; 
}

.styled-table th { text-align: left; padding: 12px 0; color: var(--text-body); font-weight: 500; font-size: 0.85rem; border-bottom: 1px solid var(--border-color); }
.styled-table td { padding: 16px 0; border-bottom: 1px solid var(--bg-body); color: var(--text-main); font-size: 0.9rem; vertical-align: middle;}
.styled-table tr:last-child td { border-bottom: none; }

.progress-item { margin-bottom: 1rem; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 0.875rem; font-weight: 500; }
.progress-track { height: 8px; width: 100%; background: #EFF4FB; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; }

.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.badge { padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

@media (max-width: 1024px) {
    .grid-container { grid-template-columns: repeat(2, 1fr); }
    .col-span-3 { grid-column: span 2; }
    .col-span-1 { grid-column: span 2; } 
    .grid-container:first-of-type {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    .top-header { padding: 0 1rem; }
    .header-title h1 { font-size: 1.2rem; }
    .header-title p { display: none; }
    .content-body { padding: 0.5rem; }

    .grid-container {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .col-span-1, .col-span-2, .col-span-3, .col-span-4 {
        width: 100%;
        grid-column: auto;
    }

    .grid-container:first-of-type {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 280px;
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    }

    .sidebar.open { left: 0; }
    .sidebar-overlay.active { display: block; }

    .header-controls { gap: 0.5rem; }
    .guide-trigger-btn { width: 32px; height: 32px; }
    .toast-container { right: 12px; bottom: 12px; }
    .toast { min-width: 250px; padding: 12px 16px; }

    .guide-chat-widget {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .setup-modal { padding: 1.5rem; border-radius: 16px; }
    .setup-header h2 { font-size: 1.4rem; }
    .setup-steps-container { height: 260px; }
}

@media (max-width: 480px) {
    .grid-container:first-of-type {
        grid-template-columns: 1fr; 
    }
    .card { padding: 1.25rem; }
}

.setup-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.setup-overlay.active {
    display: flex;
    opacity: 1;
}

.setup-modal {
    width: 600px;
    max-width: 90%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.setup-modal::before {
    content: '';
    position: absolute;
    top: -50px; left: -50px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, var(--primary-light) 0%, rgba(255,255,255,0) 70%);
    z-index: 0;
}

.setup-content {
    position: relative;
    z-index: 1;
}

.setup-header {
    text-align: center;
    margin-bottom: 2rem;
}

.setup-header h2 {
    font-size: 1.8rem;
    color: var(--primary-dark);
    margin: 0 0 0.5rem 0;
}

.setup-header p {
    color: var(--text-body);
    font-size: 1rem;
}

.setup-steps-container {
    position: relative;
    height: 240px;
}

.setup-step {
    position: absolute;
    top: 0; left: 0; width: 100%;
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.4s ease;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.setup-step.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

.setup-step.prev {
    transform: translateX(-50px);
    opacity: 0;
}

.step-icon {
    width: 64px; height: 64px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.step-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

.step-desc {
    color: var(--text-body);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    max-width: 400px;
}

.setup-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-setup {
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 114, 206, 0.2);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary {
    background: transparent;
    color: var(--text-body);
}
.btn-secondary:hover { color: var(--text-main); background: rgba(0,0,0,0.03); }

.step-indicators {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 2rem;
}

.dot {
    width: 8px; height: 8px;
    background: var(--border-color);
    border-radius: 50%;
    transition: all 0.3s;
}
.dot.active {
    width: 24px;
    background: var(--primary);
    border-radius: 10px;
}

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: white;
    border-left: 4px solid var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 4px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    min-width: 300px;
    transform: translateX(100%);
    animation: slideIn 0.3s forwards;
    position: relative;
    overflow: hidden;
    gap: 12px;
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast.error { 
    border-left-color: var(--danger); 
    color: var(--danger);
}
.toast.error .toast-content { color: var(--text-main); }

.toast.success { 
    border-left-color: var(--success); 
    color: var(--success);
}
.toast.success .toast-content { color: var(--text-main); }

.toast-content {
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.95rem;
}

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

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(10px); }
}

.guide-trigger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #FF9900 0%, #FFCC00 100%);
    color: #1a1a1a;
    border: none;
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 153, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 1001;
}

.guide-trigger-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 153, 0, 0.5);
}

.guide-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 360px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.25);
    border: 1px solid rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
    
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.guide-chat-widget.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.guide-header {
    background: linear-gradient(135deg, var(--primary) 0%, #4a90e2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.guide-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.guide-close-btn:hover { background: rgba(255,255,255,0.4); }

.guide-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.guide-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.guide-msg.bot {
    background: white;
    border: 1px solid #e2e8f0;
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.guide-msg.user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.guide-input-area {
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    background: white;
    display: flex;
    gap: 8px;
}

.guide-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    outline: none;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.guide-input:focus { border-color: var(--primary); }

.guide-send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s;
}
.guide-send-btn:hover { transform: scale(1.05); background: var(--primary-dark); }
.guide-send-btn:active { transform: scale(0.95); }