        /* Authentication Loading Screen */
        .auth-loading-screen {
            position: fixed;
            top: 70px; /* Start below navigation header (approx header height) */
            left: 0;
            width: 100%;
            height: calc(100% - 70px); /* Full height minus header */
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(8px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 100; /* Lower z-index since it doesn't need to cover navigation */
        }

        .auth-loading-content {
            text-align: center;
            padding: 2rem;
        }

        .auth-loading-content .loading-spinner {
            width: 48px;
            height: 48px;
            border: 4px solid #e5e7eb;
            border-top-color: #16a34a;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 1rem;
        }

        .auth-loading-content .loading-text {
            font-size: 1.125rem;
            color: #6b7280;
            font-weight: 500;
        }

        /* Live Data Page Specific Styles */
        :root {
            --color-white: #ffffff;
            --color-gray-50: #f9fafb;
            --color-gray-100: #f3f4f6;
            --color-gray-200: #e5e7eb;
            --color-gray-300: #d1d5db;
            --color-gray-400: #9ca3af;
            --color-gray-500: #6b7280;
            --color-gray-600: #4b5563;
            --color-gray-700: #374151;
            --color-gray-800: #1f2937;
            --color-gray-900: #111827;
            --color-primary: #16a34a;
            --color-primary-dark: #15803d;
            --color-success: #10b981;
            --color-warning: #f59e0b;
            --color-danger: #ef4444;
            --border-radius-md: 0.5rem;
            --border-radius-lg: 0.75rem;
            --border-radius-xl: 1rem;
            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
            --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
            --space-2: 0.5rem;
            --space-3: 0.75rem;
            --space-4: 1rem;
            --space-5: 1.25rem;
            --space-6: 1.5rem;
            --font-size-xs: 0.75rem;
            --font-size-sm: 0.875rem;
            --font-size-base: 1rem;
            --font-size-lg: 1.125rem;
            --font-size-xl: 1.25rem;
            --font-weight-medium: 500;
            --font-weight-semibold: 600;
            --font-weight-bold: 700;
            --line-height-relaxed: 1.625;
            --transition-base: 150ms ease;
            --transition-medium: 250ms ease;
        }

        body {
            background: linear-gradient(to bottom, #f9fafb, #ffffff);
            min-height: 100vh;
        }

        .dashboard-main {
            padding-top: 2rem;
        }

        .dashboard-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 1.5rem 3rem;
        }

        /* Page Header */
        .page-header {
            text-align: center;
            margin-bottom: var(--space-6);
        }

        .page-header h1 {
            font-size: 2rem;
            font-weight: var(--font-weight-bold);
            color: var(--color-gray-900);
            margin-bottom: var(--space-2);
        }

        .page-header p {
            font-size: var(--font-size-lg);
            color: var(--color-gray-600);
        }

        /* Device Selection */
        .device-selector {
            margin-bottom: var(--space-6);
            padding: var(--space-5);
            background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
            border-radius: var(--border-radius-xl);
            box-shadow: var(--shadow-md);
            border: 1px solid var(--color-gray-200);
        }

        .device-selector-label {
            display: block;
            font-weight: var(--font-weight-semibold);
            font-size: var(--font-size-lg);
            color: var(--color-gray-900);
            margin-bottom: var(--space-3);
        }

        .device-select {
            width: 100%;
            max-width: 400px;
            padding: var(--space-3) var(--space-4);
            border: 2px solid var(--color-gray-200);
            border-radius: var(--border-radius-md);
            background: var(--color-white);
            font-size: var(--font-size-base);
            transition: var(--transition-medium);
            cursor: pointer;
        }

        .device-select:hover {
            border-color: var(--color-gray-300);
        }

        .device-select:focus {
            outline: none;
            border-color: var(--color-primary);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

        /* Live Data Section */
        .live-data-section {
            margin-top: var(--space-6);
        }

        .activity-card {
            background: var(--color-white);
            border-radius: var(--border-radius-xl);
            box-shadow: var(--shadow-lg);
            overflow: hidden;
            border: 1px solid var(--color-gray-200);
        }

        .activity-card--full {
            min-height: 600px;
            display: flex;
            flex-direction: column;
        }

        .activity-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--space-5);
            background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
            border-bottom: 2px solid var(--color-gray-200);
        }

        .activity-title {
            font-size: var(--font-size-xl);
            font-weight: var(--font-weight-bold);
            color: var(--color-gray-900);
            margin: 0 0 0.5rem 0;
        }

        .activity-legend {
            margin: 0;
            font-size: var(--font-size-sm);
            color: var(--color-gray-600);
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .legend-badge {
            display: inline-block;
            padding: 0.125rem 0.5rem;
            border-radius: 0.25rem;
            font-size: 0.7rem;
            font-weight: var(--font-weight-semibold);
            color: white;
        }

        .legend-label {
            font-weight: var(--font-weight-medium);
            color: var(--color-gray-700);
        }

        .live-indicator {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: var(--space-2) var(--space-3);
            background: var(--color-white);
            border-radius: var(--border-radius-md);
            font-size: var(--font-size-sm);
            font-weight: var(--font-weight-medium);
            color: var(--color-gray-700);
            border: 1px solid var(--color-gray-200);
        }

        .live-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: var(--color-gray-400);
            animation: pulse 2s ease-in-out infinite;
            box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
        }

        .live-dot--connected {
            background: var(--color-secondary);
        }

        .live-dot--connecting {
            background: var(--color-warning);
        }

        .live-dot--error {
            background: var(--color-accent);
        }

        .live-dot--disconnected {
            background: var(--color-gray-400);
            animation: none;
            box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
        }

        @keyframes pulse {
            0%, 100% {
                opacity: 1;
                transform: scale(1);
                box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.4);
            }
            50% {
                opacity: 0.4;
                transform: scale(0.85);
                box-shadow: 0 0 0 6px rgba(5, 150, 105, 0.1);
            }
        }

        .activity-content {
            flex: 1;
            overflow-y: auto;
            padding: var(--space-4);
        }

        /* Column Headers */
        .activity-table-header {
            display: grid;
            grid-template-columns: 2fr 1.5fr 1.5fr 1fr;
            gap: var(--space-3);
            align-items: center;
            padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
            margin-bottom: var(--space-3);
            background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
            border-radius: var(--border-radius-md);
            border: 1px solid var(--color-gray-300);
            position: sticky;
            top: 0;
            z-index: 10;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        }

        .activity-table-header > div {
            font-size: var(--font-size-xs);
            font-weight: var(--font-weight-bold);
            color: var(--color-gray-700);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            text-align: left;
        }

        .activity-list {
            display: flex;
            flex-direction: column;
            gap: 0;
        }

        .activity-loading,
        .activity-empty,
        .activity-error {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: var(--space-6);
            text-align: center;
            background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
            border-radius: var(--border-radius-lg);
            border: 2px dashed var(--color-gray-300);
            margin: var(--space-4);
        }

        .loading-spinner {
            width: 50px;
            height: 50px;
            border: 4px solid var(--color-gray-200);
            border-top-color: var(--color-primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-bottom: var(--space-4);
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        .loading-text {
            font-size: var(--font-size-base);
            color: var(--color-gray-600);
            font-weight: var(--font-weight-medium);
        }

        .empty-icon,
        .error-icon {
            font-size: 3rem;
            margin-bottom: var(--space-3);
        }

        .empty-text,
        .error-text {
            font-size: var(--font-size-lg);
            font-weight: var(--font-weight-semibold);
            color: var(--color-gray-900);
            margin-bottom: var(--space-2);
        }

        .empty-subtext {
            font-size: var(--font-size-sm);
            color: var(--color-gray-600);
        }

        .activity-item {
            display: grid;
            grid-template-columns: 2fr 1.5fr 1.5fr 1fr;
            gap: var(--space-3);
            align-items: center;
            padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
            margin-bottom: 0.375rem;
            border-radius: var(--border-radius-md);
            border: 1px solid var(--color-gray-200);
            transition: all 0.2s ease;
            box-shadow: var(--shadow-sm);
        }

        .activity-item:hover {
            /* No hover effect - keep item unchanged */
        }

        .activity-item:last-child {
            margin-bottom: 0;
        }

        /* Flash animations for new detections based on speed threshold
           Animations pulse between bright and final resting colour */
        @keyframes flashGreen {
            0% {
                background: rgba(16, 185, 129, 0.03);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            15% {
                background: linear-gradient(135deg, rgba(16, 185, 129, 0.20) 0%, rgba(16, 185, 129, 0.12) 100%);
                box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3), var(--shadow-md);
                transform: scale(1.02);
            }
            30% {
                background: rgba(16, 185, 129, 0.03);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            45% {
                background: linear-gradient(135deg, rgba(16, 185, 129, 0.20) 0%, rgba(16, 185, 129, 0.12) 100%);
                box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3), var(--shadow-md);
                transform: scale(1.02);
            }
            100% {
                background: rgba(16, 185, 129, 0.03);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
        }

        @keyframes flashYellow {
            0% {
                background: rgba(234, 179, 8, 0.04);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            15% {
                background: linear-gradient(135deg, rgba(234, 179, 8, 0.20) 0%, rgba(234, 179, 8, 0.12) 100%);
                box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.3), var(--shadow-md);
                transform: scale(1.02);
            }
            30% {
                background: rgba(234, 179, 8, 0.04);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            45% {
                background: linear-gradient(135deg, rgba(234, 179, 8, 0.20) 0%, rgba(234, 179, 8, 0.12) 100%);
                box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.3), var(--shadow-md);
                transform: scale(1.02);
            }
            100% {
                background: rgba(234, 179, 8, 0.04);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
        }

        @keyframes flashOrange {
            0% {
                background: rgba(249, 115, 22, 0.05);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            15% {
                background: linear-gradient(135deg, rgba(249, 115, 22, 0.20) 0%, rgba(249, 115, 22, 0.12) 100%);
                box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.3), var(--shadow-md);
                transform: scale(1.02);
            }
            30% {
                background: rgba(249, 115, 22, 0.05);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            45% {
                background: linear-gradient(135deg, rgba(249, 115, 22, 0.20) 0%, rgba(249, 115, 22, 0.12) 100%);
                box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.3), var(--shadow-md);
                transform: scale(1.02);
            }
            100% {
                background: rgba(249, 115, 22, 0.05);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
        }

        @keyframes flashBrightRed {
            0% {
                background: rgba(239, 68, 68, 0.12);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            15% {
                background: linear-gradient(135deg, rgba(239, 68, 68, 0.25) 0%, rgba(239, 68, 68, 0.18) 100%);
                box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35), var(--shadow-md);
                transform: scale(1.02);
            }
            30% {
                background: rgba(239, 68, 68, 0.12);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            45% {
                background: linear-gradient(135deg, rgba(239, 68, 68, 0.25) 0%, rgba(239, 68, 68, 0.18) 100%);
                box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35), var(--shadow-md);
                transform: scale(1.02);
            }
            100% {
                background: rgba(239, 68, 68, 0.12);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
        }

        @keyframes flashDeepRed {
            0% {
                background: rgba(185, 28, 28, 0.25);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            15% {
                background: linear-gradient(135deg, rgba(185, 28, 28, 0.40) 0%, rgba(185, 28, 28, 0.30) 100%);
                box-shadow: 0 0 0 4px rgba(185, 28, 28, 0.5), var(--shadow-md);
                transform: scale(1.03);
            }
            30% {
                background: rgba(185, 28, 28, 0.25);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            45% {
                background: linear-gradient(135deg, rgba(185, 28, 28, 0.40) 0%, rgba(185, 28, 28, 0.30) 100%);
                box-shadow: 0 0 0 4px rgba(185, 28, 28, 0.5), var(--shadow-md);
                transform: scale(1.03);
            }
            100% {
                background: rgba(185, 28, 28, 0.25);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
        }

        @keyframes flashNeutral {
            0% {
                background: var(--color-white);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            15% {
                background: linear-gradient(135deg, rgba(107, 114, 128, 0.15) 0%, rgba(107, 114, 128, 0.08) 100%);
                box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3), var(--shadow-md);
                transform: scale(1.02);
            }
            30% {
                background: var(--color-white);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            45% {
                background: linear-gradient(135deg, rgba(107, 114, 128, 0.15) 0%, rgba(107, 114, 128, 0.08) 100%);
                box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3), var(--shadow-md);
                transform: scale(1.02);
            }
            100% {
                background: var(--color-white);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
        }

        .activity-item.new-detection.flash-green {
            animation: flashGreen 4s ease-in-out;
        }

        .activity-item.new-detection.flash-yellow {
            animation: flashYellow 4s ease-in-out;
        }

        .activity-item.new-detection.flash-orange {
            animation: flashOrange 4s ease-in-out;
        }

        .activity-item.new-detection.flash-brightred {
            animation: flashBrightRed 4s ease-in-out;
        }

        .activity-item.new-detection.flash-deepred {
            animation: flashDeepRed 4s ease-in-out;
        }

        .activity-item.new-detection.flash-neutral {
            animation: flashNeutral 4s ease-in-out;
        }

        /* Violation flash override */
        .activity-item.new-detection.flash-green.activity-violation,
        .activity-item.new-detection.flash-yellow.activity-violation,
        .activity-item.new-detection.flash-orange.activity-violation,
        .activity-item.new-detection.flash-brightred.activity-violation,
        .activity-item.new-detection.flash-deepred.activity-violation,
        .activity-item.new-detection.flash-neutral.activity-violation {
            animation: flashViolation 2s ease-in-out;
        }

        @keyframes flashViolation {
            0% {
                background: linear-gradient(135deg, rgba(220, 38, 38, 0.05) 0%, rgba(220, 38, 38, 0.02) 100%);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            15% {
                background: linear-gradient(135deg, rgba(220, 38, 38, 0.20) 0%, rgba(220, 38, 38, 0.12) 100%);
                box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.4), var(--shadow-md);
                transform: scale(1.02);
            }
            30% {
                background: linear-gradient(135deg, rgba(220, 38, 38, 0.05) 0%, rgba(220, 38, 38, 0.02) 100%);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            45% {
                background: linear-gradient(135deg, rgba(220, 38, 38, 0.20) 0%, rgba(220, 38, 38, 0.12) 100%);
                box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.4), var(--shadow-md);
                transform: scale(1.02);
            }
            100% {
                background: linear-gradient(135deg, rgba(220, 38, 38, 0.05) 0%, rgba(220, 38, 38, 0.02) 100%);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
        }

        /* Calibration flash override (purple glow for calibration detections) */
        .activity-item.new-detection.flash-green.activity-calibration,
        .activity-item.new-detection.flash-yellow.activity-calibration,
        .activity-item.new-detection.flash-orange.activity-calibration,
        .activity-item.new-detection.flash-brightred.activity-calibration,
        .activity-item.new-detection.flash-deepred.activity-calibration,
        .activity-item.new-detection.flash-neutral.activity-calibration {
            animation: flashCalibration 2s ease-in-out;
        }

        @keyframes flashCalibration {
            0% {
                background: linear-gradient(135deg, rgba(147, 51, 234, 0.06) 0%, rgba(147, 51, 234, 0.03) 100%);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            15% {
                background: linear-gradient(135deg, rgba(147, 51, 234, 0.25) 0%, rgba(147, 51, 234, 0.15) 100%);
                box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.5), var(--shadow-md);
                transform: scale(1.02);
            }
            30% {
                background: linear-gradient(135deg, rgba(147, 51, 234, 0.06) 0%, rgba(147, 51, 234, 0.03) 100%);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
            45% {
                background: linear-gradient(135deg, rgba(147, 51, 234, 0.25) 0%, rgba(147, 51, 234, 0.15) 100%);
                box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.5), var(--shadow-md);
                transform: scale(1.02);
            }
            100% {
                background: linear-gradient(135deg, rgba(147, 51, 234, 0.06) 0%, rgba(147, 51, 234, 0.03) 100%);
                box-shadow: var(--shadow-sm);
                transform: scale(1);
            }
        }

        .activity-time {
            font-size: var(--font-size-sm);
            color: var(--color-gray-600);
            font-weight: var(--font-weight-medium);
            white-space: nowrap;
            text-align: left;
        }

        .activity-details {
            display: contents;
        }

        .activity-speed {
            font-size: var(--font-size-lg);
            font-weight: var(--font-weight-bold);
            color: var(--color-gray-900);
            text-align: left;
            white-space: nowrap;
        }

        .activity-direction {
            font-size: var(--font-size-sm);
            font-weight: var(--font-weight-semibold);
            text-align: left;
        }

        .activity-percentage {
            padding: 0.375rem 0.5rem;
            border-radius: var(--border-radius-md);
            font-size: var(--font-size-base);
            font-weight: var(--font-weight-bold);
            text-align: left;
            background: var(--color-gray-100);
            color: var(--color-gray-800);
            border: 1px solid var(--color-gray-200);
            white-space: nowrap;
        }

        /* Responsive */
        @media (max-width: 768px) {
            body {
                background: var(--color-white);
            }

            .dashboard-main {
                padding-top: 0.5rem;
            }

            .dashboard-container {
                padding: 0 0.5rem 1.5rem;
            }

            .page-header h1 {
                font-size: 1.5rem;
            }

            .page-header p {
                font-size: var(--font-size-base);
            }

            .device-selector {
                padding: var(--space-3);
                margin-bottom: var(--space-4);
            }

            .device-select {
                max-width: 100%;
            }

            .activity-card {
                border-radius: var(--border-radius-lg);
            }

            .activity-card--full {
                min-height: 400px;
            }

            .activity-header {
                padding: var(--space-3);
                flex-direction: column;
                align-items: flex-start;
                gap: var(--space-2);
            }

            .activity-title {
                font-size: var(--font-size-lg);
            }

            .activity-content {
                padding: var(--space-3);
            }

            .live-indicator {
                align-self: flex-end;
            }

            .activity-table-header {
                grid-template-columns: 2fr 1.5fr 1.5fr 1fr;
                gap: 0.5rem;
                padding: 0.75rem 0.5rem 0.75rem 1rem;
            }

            .activity-table-header > div {
                font-size: 0.7rem;
            }

            .activity-item {
                grid-template-columns: 2fr 1.5fr 1.5fr 1fr;
                gap: 0.5rem;
                padding: 0.75rem 0.5rem 0.75rem 1rem;
            }

            .activity-time {
                font-size: 0.7rem;
            }

            .activity-speed {
                font-size: 0.95rem;
            }

            .activity-direction {
                font-size: 0.75rem;
            }

            .activity-percentage {
                font-size: 0.8rem;
                padding: 0.25rem 0.375rem;
            }

            /* Hide calibration buttons on mobile */
            .btn-calibrate-mode,
            .cal-icon-btn {
                display: none !important;
            }
        }

        /* Smooth scrolling */
        .activity-content {
            scroll-behavior: smooth;
        }

        /* Custom scrollbar */
        .activity-content::-webkit-scrollbar {
            width: 8px;
        }

        .activity-content::-webkit-scrollbar-track {
            background: var(--color-gray-100);
        }

        .activity-content::-webkit-scrollbar-thumb {
            background: var(--color-gray-400);
            border-radius: 4px;
        }

        .activity-content::-webkit-scrollbar-thumb:hover {
            background: var(--color-gray-500);
        }

        /* ========================================
           Calibration System Styles
           ======================================== */

        /* Calibration Mode Toggle Button */
        .btn-calibrate-mode {
            padding: 0.5rem 1rem;
            background: linear-gradient(135deg, #10b981 0%, #059669 100%);
            color: white;
            border: none;
            border-radius: 0.5rem;
            font-weight: 600;
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn-calibrate-mode:hover {
            background: linear-gradient(135deg, #059669 0%, #047857 100%);
            box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
            transform: translateY(-1px);
        }

        .btn-calibrate-mode.active {
            background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
            box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
        }

        .btn-calibrate-mode.active:hover {
            background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
            box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
        }

        /* System Calibration Button */
        .btn-system-calibrate {
            padding: 0.5rem 1rem;
            background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
            color: white;
            border: none;
            border-radius: 0.5rem;
            font-weight: 600;
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 2px 4px rgba(139, 92, 246, 0.2);
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn-system-calibrate:hover {
            background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
            box-shadow: 0 4px 8px rgba(139, 92, 246, 0.3);
            transform: translateY(-1px);
        }

        /* Calibration Icon on Detection Items */
        .cal-icon-btn {
            padding: 0.25rem 0.5rem;
            background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
            color: white;
            border: none;
            border-radius: 0.375rem;
            font-size: 1rem;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 2px 4px rgba(22, 163, 74, 0.2);
            flex-shrink: 0;
        }

        .cal-icon-btn:hover {
            background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
            box-shadow: 0 4px 8px rgba(22, 163, 74, 0.3);
            transform: scale(1.1);
        }

        /* Calibration Modal */
        .cal-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 10000;
            align-items: center;
            justify-content: center;
        }

        .cal-modal-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(4px);
        }

        .cal-modal-content {
            position: relative;
            background: white;
            border-radius: 1rem;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
            max-width: 500px;
            width: 90%;
            max-height: 90vh;
            overflow-y: auto;
            z-index: 10001;
        }

        .cal-modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 1.5rem;
            border-bottom: 2px solid #e5e7eb;
        }

        .cal-modal-header h2 {
            margin: 0;
            font-size: 1.5rem;
            color: #111827;
        }

        .cal-modal-close {
            background: none;
            border: none;
            font-size: 2rem;
            color: #6b7280;
            cursor: pointer;
            padding: 0;
            width: 2rem;
            height: 2rem;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 0.5rem;
            transition: all 0.2s ease;
        }

        .cal-modal-close:hover {
            background: #f3f4f6;
            color: #111827;
        }

        .cal-modal-body {
            padding: 1.5rem;
        }

        .cal-info-section {
            background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
            border-radius: 0.75rem;
            padding: 1rem;
            margin-bottom: 1.5rem;
            border: 1px solid #e5e7eb;
        }

        .cal-info-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.5rem 0;
        }

        .cal-info-row:not(:last-child) {
            border-bottom: 1px solid #e5e7eb;
        }

        .cal-info-label {
            font-weight: 600;
            color: #6b7280;
            font-size: 0.875rem;
        }

        .cal-info-value {
            font-weight: 700;
            color: #111827;
            font-size: 1.125rem;
        }

        .cal-form-group {
            margin-bottom: 1.5rem;
        }

        .cal-form-label {
            display: block;
            font-weight: 600;
            color: #374151;
            margin-bottom: 0.5rem;
            font-size: 0.9375rem;
        }

        .cal-required {
            color: #ef4444;
        }

        .cal-input-group {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .cal-form-input {
            flex: 1;
            padding: 0.75rem 1rem;
            border: 2px solid #d1d5db;
            border-radius: 0.5rem;
            font-size: 1rem;
            font-weight: 600;
            transition: all 0.2s ease;
        }

        .cal-form-input:focus {
            outline: none;
            border-color: #22c55e;
            box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
        }

        .cal-input-unit {
            font-weight: 600;
            color: #6b7280;
            font-size: 0.9375rem;
        }

        .cal-help-text {
            display: block;
            margin-top: 0.375rem;
            font-size: 0.8125rem;
            color: #6b7280;
        }

        .cal-preview {
            background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
            border: 2px solid #22c55e;
            border-radius: 0.75rem;
            padding: 1rem;
            margin-bottom: 1.5rem;
        }

        .cal-preview-label {
            font-size: 0.875rem;
            font-weight: 600;
            color: #166534;
            margin-bottom: 0.5rem;
        }

        .cal-preview-value {
            font-size: 1.25rem;
            font-weight: 700;
            color: #1e3a8a;
        }

        .cal-form-textarea {
            width: 100%;
            padding: 0.75rem 1rem;
            border: 2px solid #d1d5db;
            border-radius: 0.5rem;
            font-size: 0.9375rem;
            font-family: inherit;
            resize: vertical;
            transition: all 0.2s ease;
        }

        .cal-form-textarea:focus {
            outline: none;
            border-color: #22c55e;
            box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
        }

        .cal-modal-footer {
            display: flex;
            gap: 0.75rem;
            padding: 1.5rem;
            border-top: 2px solid #e5e7eb;
            justify-content: flex-end;
        }

        .cal-btn {
            padding: 0.75rem 1.5rem;
            border: none;
            border-radius: 0.5rem;
            font-weight: 600;
            font-size: 0.9375rem;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .cal-btn-secondary {
            background: #f3f4f6;
            color: #374151;
        }

        .cal-btn-secondary:hover {
            background: #e5e7eb;
        }

        .cal-btn-primary {
            background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
            color: white;
            box-shadow: 0 2px 4px rgba(22, 163, 74, 0.2);
        }

        .cal-btn-primary:hover:not(:disabled) {
            background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
            box-shadow: 0 4px 8px rgba(22, 163, 74, 0.3);
            transform: translateY(-1px);
        }

        .cal-btn-primary:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        /* Mobile Responsive for Calibration */
        @media (max-width: 768px) {
            .cal-modal-content {
                width: 95%;
                max-height: 95vh;
            }

            .cal-modal-header h2 {
                font-size: 1.25rem;
            }

            .btn-calibrate-mode {
                font-size: 0.8125rem;
                padding: 0.375rem 0.75rem;
            }
        }

        /* ==========================================================================
           ENHANCED MOBILE & TABLET RESPONSIVE STYLES
           ========================================================================== */

        /* iPad / Tablet (768px - 1024px) */
        @media (min-width: 768px) and (max-width: 1024px) {
            .dashboard-container {
                padding: 0 1rem 2rem;
            }

            .activity-table-header,
            .activity-item {
                grid-template-columns: 2.5fr 1.5fr 1.5fr 1fr;
                gap: 0.75rem;
            }

            .device-selector {
                padding: var(--space-4);
            }
        }

        /* Small Mobile (max-width: 480px) */
        @media (max-width: 480px) {
            .dashboard-container {
                padding: 0 0.25rem 1rem;
            }

            .page-header {
                margin-bottom: var(--space-4);
                padding: 0 0.5rem;
            }

            .page-header h1 {
                font-size: 1.25rem;
            }

            .page-header p {
                font-size: var(--font-size-sm);
            }

            .activity-card {
                border-radius: var(--border-radius-md);
                margin: 0 0.25rem;
            }

            .activity-card--full {
                min-height: 350px;
            }

            .activity-header {
                padding: var(--space-2);
            }

            .activity-title {
                font-size: var(--font-size-base);
            }

            .activity-content {
                padding: var(--space-2);
            }

            /* Compact table for very small screens */
            .activity-table-header,
            .activity-item {
                grid-template-columns: 2fr 1.2fr 1.2fr 0.8fr;
                gap: 0.25rem;
                padding: 0.5rem 0.25rem 0.5rem 0.5rem;
            }

            .activity-table-header > div {
                font-size: 0.65rem;
            }

            .activity-time {
                font-size: 0.65rem;
            }

            .activity-speed {
                font-size: 0.85rem;
            }

            .activity-direction {
                font-size: 0.7rem;
            }

            .activity-percentage {
                font-size: 0.7rem;
                padding: 0.2rem 0.25rem;
            }

            /* Device selector full width */
            .device-selector {
                padding: var(--space-2);
                margin: 0 0.25rem var(--space-3);
                border-radius: var(--border-radius-md);
            }

            .device-select {
                font-size: 16px; /* Prevent iOS zoom */
                padding: var(--space-2) var(--space-3);
            }

            /* Live indicator compact */
            .live-indicator {
                padding: var(--space-1) var(--space-2);
                font-size: var(--font-size-xs);
            }

            .live-dot {
                width: 8px;
                height: 8px;
            }
        }

        /* Touch device enhancements */
        @media (hover: none) and (pointer: coarse) {
            /* Touch-friendly targets */
            .device-select,
            .btn-calibrate-mode {
                min-height: 44px;
                touch-action: manipulation;
                -webkit-tap-highlight-color: transparent;
            }

            /* Prevent text selection on interactive elements */
            .activity-item {
                -webkit-user-select: none;
                user-select: none;
            }

            /* Better scroll behaviour */
            .activity-content {
                -webkit-overflow-scrolling: touch;
                overscroll-behavior: contain;
            }
        }

        /* Safe area insets for notched devices (iPhone X+) */
        @supports (padding: max(0px)) {
            .dashboard-container {
                padding-left: max(0.5rem, env(safe-area-inset-left));
                padding-right: max(0.5rem, env(safe-area-inset-right));
                padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
            }
        }

        /* Landscape mobile orientation */
        @media (max-height: 500px) and (orientation: landscape) {
            .page-header {
                margin-bottom: var(--space-2);
            }

            .page-header h1 {
                font-size: 1.25rem;
                margin-bottom: 0.25rem;
            }

            .page-header p {
                display: none; /* Hide subtitle in landscape to save space */
            }

            .device-selector {
                margin-bottom: var(--space-2);
            }

            .activity-card--full {
                min-height: 250px;
            }

            .activity-header {
                padding: var(--space-2);
                flex-direction: row;
                justify-content: space-between;
            }
        }
