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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a0e27;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(74, 234, 220, 0.15) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

header h1 {
    font-size: 3.5em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #4aeadc 0%, #7877c6 50%, #9c7ef6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -1px;
}

header p {
    font-size: 1.2em;
    color: #a0aec0;
    font-weight: 300;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
}

.video-section,
.stats-section {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.mode-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.mode-btn {
    flex: 1;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #a0aec0;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.mode-btn.active {
    background: linear-gradient(135deg, #4aeadc 0%, #7877c6 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(74, 234, 220, 0.4);
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 25px;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    border: 2px solid rgba(74, 234, 220, 0.3);
    box-shadow: 0 0 30px rgba(74, 234, 220, 0.1);
    transition: all 0.3s ease;
}

.video-container:hover {
    border-color: rgba(74, 234, 220, 0.5);
    box-shadow: 0 0 40px rgba(74, 234, 220, 0.2);
}

#webcam,
#canvas {
    display: block;
    width: 100%;
    height: auto;
}

#webcam {
    position: relative;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 10;
}

.loading.hidden {
    display: none;
}

.upload-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed rgba(74, 234, 220, 0.4);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-zone:hover {
    border-color: rgba(74, 234, 220, 0.7);
    background: rgba(10, 14, 39, 0.98);
}

.upload-zone.drag-over {
    border-color: #4aeadc;
    background: rgba(74, 234, 220, 0.1);
}

.upload-content {
    text-align: center;
    color: #a0aec0;
}

.upload-icon {
    font-size: 4em;
    display: block;
    margin-bottom: 15px;
}

.upload-content p {
    font-size: 1.2em;
    margin-bottom: 5px;
}

.upload-sub {
    font-size: 0.9em !important;
    color: #718096;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: linear-gradient(135deg, #4aeadc 0%, #7877c6 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(74, 234, 220, 0.4);
    border: 1px solid rgba(74, 234, 220, 0.5);
}

.btn.primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(74, 234, 220, 0.6);
}

.btn.secondary {
    background: rgba(255, 71, 87, 0.2);
    color: #ff6b81;
    border: 1px solid rgba(255, 71, 87, 0.5);
}

.btn.secondary:hover:not(:disabled) {
    background: rgba(255, 71, 87, 0.3);
    transform: translateY(-2px);
}

.btn:not(.primary):not(.secondary) {
    background: rgba(255, 255, 255, 0.05);
    color: #a0aec0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn:not(.primary):not(.secondary):hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.icon {
    font-size: 1.2em;
}

.settings {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.settings h3 {
    margin-bottom: 15px;
    color: #ffffff;
    font-weight: 600;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    color: #a0aec0;
    font-weight: 500;
}

.setting-item span {
    color: #4aeadc;
    font-weight: 700;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4aeadc 0%, #7877c6 100%);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(74, 234, 220, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4aeadc 0%, #7877c6 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(74, 234, 220, 0.5);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stats-header h2 {
    color: #ffffff;
}

.fps-counter {
    background: linear-gradient(135deg, #4aeadc 0%, #7877c6 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    box-shadow: 0 0 20px rgba(74, 234, 220, 0.3);
}

.fps-label {
    margin-right: 8px;
}

.stat-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, rgba(74, 234, 220, 0.1) 0%, rgba(120, 119, 198, 0.1) 100%);
    border: 1px solid rgba(74, 234, 220, 0.3);
    color: white;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 20px rgba(74, 234, 220, 0.2);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    animation: fadeInUp 0.5s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(74, 234, 220, 0.3);
    border-color: rgba(74, 234, 220, 0.5);
}

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

.stat-icon {
    font-size: 2em;
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
}

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

.detected-objects {
    margin-bottom: 30px;
}

.detected-objects h3 {
    margin-bottom: 15px;
    color: #ffffff;
    font-weight: 600;
}

.object-list {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.object-list::-webkit-scrollbar {
    width: 8px;
}

.object-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.object-list::-webkit-scrollbar-thumb {
    background: rgba(74, 234, 220, 0.3);
    border-radius: 4px;
}

.object-list::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 234, 220, 0.5);
}

.empty-state {
    color: #718096;
    text-align: center;
    padding: 20px;
}

.object-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.3s;
}

.object-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(74, 234, 220, 0.3);
}

.object-name {
    font-weight: 600;
    color: #ffffff;
    text-transform: capitalize;
}

.object-count {
    background: linear-gradient(135deg, #4aeadc 0%, #7877c6 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 600;
}

.info-box {
    background: rgba(74, 234, 220, 0.05);
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid #4aeadc;
    border: 1px solid rgba(74, 234, 220, 0.2);
}

.info-box h3 {
    color: #ffffff;
    margin-bottom: 10px;
}

.info-box p {
    color: #a0aec0;
    line-height: 1.6;
    margin-bottom: 10px;
}

.info-box p:last-child {
    margin-bottom: 0;
}

.info-box strong {
    color: #4aeadc;
}

.object-filter,
.color-legend,
.detection-history {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    margin-top: 20px;
}

.object-filter h3,
.color-legend h3,
.detection-history h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-weight: 600;
}

.filter-categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.filter-categories label {
    color: #a0aec0;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #a0aec0;
    font-size: 0.95em;
}

.legend-color {
    width: 30px;
    height: 18px;
    border-radius: 4px;
    display: inline-block;
}

.history-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.history-gallery::-webkit-scrollbar {
    width: 8px;
}

.history-gallery::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.history-gallery::-webkit-scrollbar-thumb {
    background: rgba(74, 234, 220, 0.3);
    border-radius: 4px;
}

.history-gallery::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 234, 220, 0.5);
}

.history-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.history-item:hover {
    border-color: rgba(74, 234, 220, 0.5);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(74, 234, 220, 0.3);
}

.history-item img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.history-item .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 71, 87, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8em;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

.performance-metrics {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

.performance-metrics:hover {
    border-color: rgba(74, 234, 220, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.performance-metrics h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-weight: 600;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-item:last-child {
    border-bottom: none;
}

.metric-label {
    color: #a0aec0;
    font-size: 0.95em;
}

.metric-value {
    color: #4aeadc;
    font-weight: 600;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2em;
    }

    .controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}
