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

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            padding: 25px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .header h1 {
            font-size: 1.8em;
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .nav-buttons {
            display: flex;
            gap: 15px;
        }

        .nav-btn {
            padding: 12px 20px;
            background: rgba(255, 255, 255, 0.2);
            color: white;
            text-decoration: none;
            border-radius: 8px;
            transition: all 0.3s ease;
            border: none;
            cursor: pointer;
        }

        .nav-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: translateY(-2px);
        }

        .hamburger-btn {
            background: none;
            border: none;
            color: white;
            font-size: 1.5em;
            cursor: pointer;
            padding: 8px;
            border-radius: 8px;
            transition: background 0.3s ease;
        }

        .hamburger-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .menu-drawer {
            position: fixed;
            top: 0;
            left: -350px;
            width: 350px;
            height: 100vh;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            transition: left 0.3s ease;
            z-index: 1000;
            box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }

        .menu-drawer.open {
            left: 0;
        }

        .menu-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }

        .menu-overlay.show {
            opacity: 1;
            visibility: visible;
        }

        .menu-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 1px solid rgba(102, 126, 234, 0.2);
        }

        .menu-title {
            font-size: 1.2em;
            font-weight: bold;
            color: #333;
        }

        .close-btn {
            background: none;
            border: none;
            font-size: 1.5em;
            cursor: pointer;
            color: #666;
            padding: 5px;
            border-radius: 50%;
            transition: background 0.3s ease;
        }

        .close-btn:hover {
            background: rgba(102, 126, 234, 0.1);
        }

        .menu-items {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .menu-item {
            display: flex;
            align-items: center;
            gap: 15px;
            padding: 15px 20px;
            background: rgba(102, 126, 234, 0.1);
            border-radius: 12px;
            text-decoration: none;
            color: #333;
            transition: all 0.3s ease;
            border: 1px solid rgba(102, 126, 234, 0.2);
        }

        .menu-item:hover {
            background: rgba(102, 126, 234, 0.2);
            transform: translateX(-5px);
        }

        .menu-item .icon {
            font-size: 1.2em;
            width: 25px;
            text-align: center;
        }

        .menu-item .text {
            font-weight: 500;
        }

        .menu-item.logout {
            background: rgba(220, 53, 69, 0.1);
            border-color: rgba(220, 53, 69, 0.2);
            color: #dc3545;
            margin-top: 20px;
        }

        .menu-item.logout:hover {
            background: rgba(220, 53, 69, 0.2);
        }

        .menu-section-title {
            padding: 12px 20px;
            font-size: 0.85em;
            font-weight: bold;
            color: #999;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-top: 10px;
            border-top: 1px solid rgba(255,255,255,0.1);
        }

        .menu-section-title:first-child {
            border-top: none;
            margin-top: 0;
        }

        /* הסתרת קטעים */
        .analytics-section {
            display: none;
        }

        .analytics-section.active {
            display: block;
        }

        .content {
            padding: 30px;
        }

        /* כרטיס סטטיסטיקות מאוחד */
        .unified-stats-card {
            background: white;
            padding: 24px;
            border-radius: 12px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
            margin-bottom: 30px;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: 20px 30px;
        }

        .stat-item {
            display: flex;
            flex-direction: column;
            gap: 6px;
            text-align: center;
        }

        .stat-value {
            font-size: 1rem;
            font-weight: 700;
            color: #667eea;
        }

        .stat-text {
            font-size: 1rem;
            color: #666;
            font-weight: 400;
        }

        .dashboard-grid {
            display: grid;
            /* reduced min width by 50% to make cards more compact */
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        /* Compact stat cards: render number and label on a single line */
    .stat-card {
            background: white;
            /* padding reduced ~50% */
            padding: 8px 10px;
            border-radius: 12px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
            transition: transform 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            /* adjusted height so content fits comfortably for wrapped labels */
            min-height: 56px;
        }

        /* Stat number (left side) */
    .stat-card .stat-number {
            /* font-size reduced ~25-30% to keep ratio */
            font-size: 0.95rem;
            font-weight: 700;
            color: #111;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 90px;
            text-align: left;
        }

        /* Stat label (right side) */
        .stat-card .stat-label {
            font-size: 0.75rem;
            color: #666;
            /* allow wrapping so the full label is visible */
            white-space: normal;
            overflow: visible;
            text-overflow: clip;
            text-align: right;
            flex: 1 1 auto;
            padding-left: 8px;
            line-height: 1.15;
            word-break: break-word;
        }

        .stat-card .stat-change {
            font-size: 0.85rem;
            margin-left: 8px;
            white-space: nowrap;
            display: none; /* hidden by default; JS will show when there's a value */
        }

        .stat-card:hover {
            transform: translateY(-5px);
        }

        .stat-number {
            font-size: 0.95rem;
            font-weight: bold;
            margin-bottom: 10px;
        }

        .stat-label {
            color: #666;
            font-size: 1.1em;
        }

        .stat-change {
            font-size: 0.9em;
            margin-top: 5px;
        }

        .positive {
            color: #4CAF50;
        }

        .negative {
            color: #f44336;
        }

        .new {
            color: #2196F3;
            font-weight: bold;
        }

        .charts-section {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 25px;
            margin-bottom: 30px;
        }

        .chart-container {
            background: white;
            padding: 25px;
            border-radius: 15px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .chart-title {
            font-size: 1.4em;
            margin-bottom: 20px;
            color: #333;
            text-align: center;
        }

        .period-btn {
            background: #f0f0f0;
            border: 1px solid #ddd;
            border-radius: 20px;
            padding: 4px 14px;
            font-size: 0.75em;
            cursor: pointer;
            transition: all 0.2s;
            font-family: inherit;
            white-space: nowrap;
        }
        .period-btn:hover { background: #e0e0e0; }
        .period-btn.active {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }

        .top-lessons-modal {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.45);
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .top-lessons-content {
            background: white;
            border-radius: 16px;
            padding: 28px 32px;
            min-width: 320px;
            max-width: 480px;
            width: 90%;
            box-shadow: 0 8px 32px rgba(0,0,0,0.2);
            position: relative;
            direction: rtl;
        }
        .top-lessons-close {
            position: absolute;
            top: 14px;
            left: 16px;
            background: none;
            border: none;
            font-size: 1.2em;
            cursor: pointer;
            color: #888;
        }
        .top-lesson-row {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 7px 0;
            border-bottom: 1px solid #f0f0f0;
            font-size: 0.95em;
        }
        .top-lesson-row:last-child { border-bottom: none; }
        .top-lesson-rank {
            font-weight: bold;
            color: #667eea;
            min-width: 24px;
            text-align: center;
        }
        .top-lesson-bar-wrap {
            flex: 1;
            background: #f0f0f0;
            border-radius: 4px;
            height: 8px;
            overflow: hidden;
        }
        .top-lesson-bar {
            height: 100%;
            background: linear-gradient(90deg, #667eea, #764ba2);
            border-radius: 4px;
            transition: width 0.4s;
        }
        .top-lesson-count {
            font-size: 0.85em;
            color: #666;
            min-width: 28px;
            text-align: left;
        }

        .reports-section {
            background: white;
            padding: 25px;
            border-radius: 15px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .filters {
            display: flex;
            gap: 15px;
            margin-bottom: 25px;
            flex-wrap: wrap;
        }

        .filter-group {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .filter-group label {
            font-weight: bold;
            color: #333;
        }

        .filter-group select,
        .filter-group input {
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 1em;
        }

        .btn {
            padding: 12px 25px;
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 1em;
            transition: all 0.3s ease;
        }

        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        .btn.secondary {
            background: linear-gradient(135deg, #95a5a6, #7f8c8d);
        }

        .table-container {
            max-height: 500px;
            overflow-y: auto;
            border: 1px solid #ddd;
            border-radius: 8px;
        }

        .data-table {
            width: 100%;
            border-collapse: collapse;
            background: white;
        }

        .data-table th,
        .data-table td {
            padding: 12px;
            text-align: right;
            border-bottom: 1px solid #eee;
            /* Force single-line cells and truncate overflow with ellipsis */
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 320px; /* reasonable width for a table cell; adjust if needed */
        }

        .data-table th {
            background: #f8f9fa;
            font-weight: bold;
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .data-table tr:hover {
            background: #f8f9fa;
        }

        .loading {
            text-align: center;
            padding: 50px;
            color: #666;
        }

        .spinner {
            border: 3px solid #f3f3f3;
            border-top: 3px solid #667eea;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .export-section {
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }

        .export-btn {
            background: linear-gradient(135deg, #27ae60, #2ecc71);
            margin-left: 10px;
        }

        @media (max-width: 768px) {
            body {
                padding: 10px 5px;
            }

            .container {
                margin: 0;
                border-radius: 15px;
            }

            .header {
                padding: 20px 15px;
                flex-direction: column;
                gap: 15px;
            }

            .header h1 {
                font-size: 1.4em;
                text-align: center;
            }

            .nav-buttons {
                width: 100%;
                justify-content: space-between;
                gap: 10px;
            }

            .menu-drawer {
                width: 100%;
                left: -100%;
            }

            .menu-drawer.open {
                left: 0;
            }

            .charts-section {
                grid-template-columns: 1fr;
            }

            .filters {
                flex-direction: column;
                gap: 15px;
                margin-bottom: 20px;
            }

            .filter-group {
                width: 100%;
            }

            .filter-group select,
            .filter-group input {
                width: 100%;
                font-size: 16px;
            }

            .content {
                padding: 15px;
            }

            .dashboard-grid {
                grid-template-columns: 1fr;
                gap: 15px;
                margin-bottom: 20px;
            }

            .stat-card {
                padding: 20px 15px;
                border-radius: 12px;
            }

            .stat-number {
                font-size: 0.95rem;
                margin-bottom: 8px;
            }

            .stat-label {
                font-size: 1em;
            }

            .charts-section {
                gap: 15px;
                margin-bottom: 20px;
            }

            .chart-container {
                padding: 20px 15px;
                border-radius: 12px;
            }

            .chart-title {
                font-size: 1.2em;
                margin-bottom: 15px;
            }
        }

        @media (max-width: 480px) {
            body {
                padding: 5px 2px;
            }

            .container {
                border-radius: 10px;
            }

            .header {
                padding: 15px 10px;
            }

            .header h1 {
                font-size: 1.2em;
                gap: 8px;
            }

            .nav-buttons {
                gap: 8px;
                flex-wrap: wrap;
            }

            .nav-btn {
                padding: 8px 12px;
                font-size: 0.9em;
                flex: 1;
                text-align: center;
                min-width: 0;
            }

            .content {
                padding: 10px;
            }

            .dashboard-grid {
                gap: 10px;
                margin-bottom: 15px;
            }

            .stat-card {
                padding: 15px 10px;
                border-radius: 10px;
            }

            .stat-number {
                font-size: 0.95rem;
                margin-bottom: 5px;
            }

            .stat-label {
                font-size: 0.9em;
            }

            .stat-change {
                font-size: 0.8em;
            }

            .charts-section {
                gap: 10px;
                margin-bottom: 15px;
            }

            .chart-container {
                padding: 15px 10px;
                border-radius: 10px;
            }

            .chart-title {
                font-size: 1.1em;
                margin-bottom: 15px;
            }

            canvas {
                max-height: 250px !important;
            }

            .filters {
                margin-bottom: 15px;
                gap: 10px;
            }

            .filter-group label {
                font-size: 0.9em;
            }

            .filter-group select,
            .filter-group input {
                padding: 8px;
                font-size: 16px;
            }
        }
