*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f1117;
    --bg-card: #1a1d2e00;
    --bg-card-hover: #222640;
    --text-primary: #e8eaf6;
    --text-secondary: #9ea4b8;
    --accent-blue: #4fc3f7;
    --accent-green: #66bb6a;
    --accent-red: #ef5350;
    --accent-purple: #ab47bc;
    --glow-blue: rgba(79, 195, 247, 0.15);
    --glow-green: rgba(102, 187, 106, 0.15);
    --glow-red: rgba(239, 83, 80, 0.15);
    --border-color: rgba(255, 255, 255, 0.06);
    --font-mono: 'Segoe UI', 'Cascadia Code', 'Consolas', monospace;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-mono);
    background: radial-gradient(circle at 15% 20%, #103c71 0%, #0a2342 38%, #060d1b 100%);
    color: var(--text-primary);
    min-height: 100vh;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #1c2f4b rgba(8, 10, 20, 0.65);
}

body::-webkit-scrollbar {
    width: 9px;
}

body::-webkit-scrollbar-track {
    background: rgba(6, 10, 22, 0.85);
}

body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #2a73c6 0%, #1b3e68 100%);
    border-radius: 12px;
}

main {
    min-height: 100vh;
}

/* Dashboard Container */
.dashboard {
    width: min(100%, 1380px);
    margin: 0 auto;
    padding: 32px 32px 48px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 48px;
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-primary);
    margin: 0;
}

.logo-wrap {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    background: rgba(4, 12, 28, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
}

.fa-logo {
    height: 48px;
    width: auto;
    display: block;
}

.header-core {
    flex: 1;
    text-align: center;
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(102, 187, 106, 0.1);
    border: 1px solid rgba(102, 187, 106, 0.25);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.75rem;
    color: var(--accent-green);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* Counter Cards */
.counters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
    align-items: stretch;
}

.counter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.counter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
}

.counter-card.total::before { background: var(--accent-blue); }
.counter-card.active::before { background: var(--accent-green); }

.counter-card:hover {
    transform: translateY(-2px);
}

.counter-card.total:hover { box-shadow: 0 8px 32px var(--glow-blue); }
.counter-card.active:hover { box-shadow: 0 8px 32px var(--glow-green); }

.counter-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.counter-card.total .counter-label { color: var(--accent-blue); }
.counter-card.active .counter-label { color: var(--accent-green); }

.counter-value {
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

.counter-value.animating {
    color: #fff;
}

.counter-delta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 12px;
    min-height: 18px;
}

.counter-delta .delta-up {
    color: var(--accent-green);
    font-weight: 600;
}

/* Image Preview */
.image-preview-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px 28px;
    margin-bottom: 32px;
    text-align: center;
}

.image-preview-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
}

.image-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.image-transition {
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
}

.image-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #05060b;
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.35);
}

.image-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transform: scale(1.02);
    animation-duration: 8s;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
}

.image-layer.original {
    animation-name: revealOriginal;
}

.image-layer.detected {
    animation-name: revealDetected;
}

.image-stage-caption {
    margin-top: 16px;
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.image-panel-grid {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
}

.image-panel {
    text-align: center;
}

.image-thumb {
    border-radius: 16px;
    width: 360px;
    max-width: 95vw;
    height: 260px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    transition: transform 0.25s ease;
}

.image-thumb:hover {
    transform: scale(1.05);
}

.image-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.no-image {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 32px;
}

/* Footer / Status */
.dashboard-footer {
    text-align: center;
    padding: 16px 0;
}

.last-updated {
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.last-updated .time-ago {
    color: var(--accent-blue);
    font-weight: 600;
}

@keyframes revealOriginal {
    0% { opacity: 1; transform: scale(1.02) translateX(0); }
    45% { opacity: 1; transform: scale(1.01) translateX(0); }
    60% { opacity: 0; transform: scale(1.02) translateX(-4%); }
    100% { opacity: 0; transform: scale(1.02) translateX(-4%); }
}

@keyframes revealDetected {
    0% { opacity: 0; transform: scale(1.05) translateX(4%); }
    45% { opacity: 0; transform: scale(1.05) translateX(4%); }
    60% { opacity: 1; transform: scale(1.0) translateX(0); }
    100% { opacity: 1; transform: scale(1.0) translateX(0); }
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 1px;
}

/* Responsive */
@media (max-width: 768px) {
    .counters-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .counter-value {
        font-size: 2.25rem;
    }

    .dashboard {
        padding: 20px 14px 32px;
    }

    .image-thumb {
        width: 100%;
        height: auto;
    }
}
