/*
 * Core dashboard styling.
 *
 * Shared by the live template and the standalone dashboard page.
 */

:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --muted: #6b7280;
    --accent: #2b6ef6;
    --danger: #ef4444;
    --success: #16a34a;
    --shadow: 0 6px 24px rgba(24, 39, 75, 0.06);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { transition: var(--transition); }

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    background: var(--bg);
    color: #0f1724;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.bg-canvas {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -2; opacity: 0.3; pointer-events: none;
}

.container-dashboard { max-width: 1400px; margin: 1.5rem auto; padding: 0 1rem; position: relative; z-index: 1; }

.page-header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.page-header h2 {
    background: linear-gradient(90deg, #2b6ef6, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 1.5rem;
}

.dashboard-brand { min-width: 0; display: flex; align-items: center; flex: 0 1 auto; }
.dashboard-brand img {
    display: block;
    width: auto;
    height: 34px;
    max-width: min(180px, 45vw);
    max-height: 34px;
    object-fit: contain;
    object-position: left center;
}
.page-header > .d-flex:last-child { flex: 0 0 auto; white-space: nowrap; }

.btn-icon {
    width: 38px; height: 38px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.5); border: none; font-size: 1.1rem; flex-shrink: 0;
}
.btn-icon:hover { background: var(--accent); color: white; transform: translateY(-2px); }

.card-soft {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.video-container {
    position: relative; border-radius: 16px; overflow: hidden;
    background: #1e293b; box-shadow: var(--shadow);
    aspect-ratio: 16 / 9; max-height: 70vh;
}

.video-poster {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(43, 110, 246, 0.1), rgba(16, 185, 129, 0.1));
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: white; z-index: 2; transition: opacity 0.4s ease;
}
.video-poster.hidden { opacity: 0; pointer-events: none; }
.video-poster .poster-title { font-weight: 600; font-size: 1.1rem; color: #1e293b; margin-top: 1rem; }

#stream-container { position: relative; width: 100%; height: 100%; }

.video-controls {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 1rem; opacity: 0; transition: opacity 0.3s ease; z-index: 3; flex-wrap: wrap; gap: 0.5rem;
}
.video-container:hover .video-controls, .video-controls.show { opacity: 1; }

.control-btn {
    background: rgba(255, 255, 255, 0.2); border: none; color: white;
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(8px); font-size: 1.1rem; cursor: pointer;
}
.control-btn:hover { background: var(--accent); transform: scale(1.1); }

.video-demo-button--smoke {
    --bs-btn-color: #475569;
    --bs-btn-border-color: #475569;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #475569;
    --bs-btn-hover-border-color: #475569;
    --bs-btn-focus-shadow-rgb: 71, 85, 105;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #334155;
    --bs-btn-active-border-color: #334155;
    --bs-btn-disabled-color: #64748b;
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: #64748b;
}
.video-demo-button--safety {
    --bs-btn-color: #0f766e;
    --bs-btn-border-color: #0f766e;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #0f766e;
    --bs-btn-hover-border-color: #0f766e;
    --bs-btn-focus-shadow-rgb: 15, 118, 110;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #115e59;
    --bs-btn-active-border-color: #115e59;
    --bs-btn-disabled-color: #5f9e99;
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: #5f9e99;
}
.video-demo-button--fire {
    --bs-btn-color: #e8590c;
    --bs-btn-border-color: #e8590c;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #e8590c;
    --bs-btn-hover-border-color: #e8590c;
    --bs-btn-focus-shadow-rgb: 232, 89, 12;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #c2410c;
    --bs-btn-active-border-color: #c2410c;
    --bs-btn-disabled-color: #ee8a55;
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: #ee8a55;
}

.buttons-slider-container { position: relative; overflow: hidden; margin: 20px 0; }
.buttons-slider { overflow-x: auto; scroll-behavior: smooth; white-space: nowrap; scrollbar-width: none; padding: 10px 60px; }
.buttons-slider::-webkit-scrollbar { display: none; }

.slide-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background-color: white; border: none; color: #333; font-size: 1.3rem; cursor: pointer;
    padding: 6px 9px; border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); z-index: 10;
}
.slide-btn:hover { background-color: #007bff; color: #fff; transform: translateY(-50%) scale(1.1); }
.slide-btn.left { left: 10px; }
.slide-btn.right { right: 10px; }

.side-panel { max-height: none; overflow: visible; }
.events-list { max-height: none; overflow: visible; }
.event-item { overflow: visible; max-width: 100%; word-break: break-word; padding: 0.75rem; border-radius: 8px;
    background: rgba(43, 110, 246, 0.05); margin-bottom: 0.5rem; border-left: 3px solid var(--accent); animation: slideIn 0.3s ease; }
.event-item:hover { background: rgba(43, 110, 246, 0.1); transform: translateX(2px); }

.metrics-vertical { display: flex; flex-direction: column; gap: 8px; overflow: visible; }
.metric-box { overflow: visible; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.skin-issue-event { cursor: pointer; position: relative; border-left-width: 4px; }
.skin-issue-event:hover { background: rgba(43, 110, 246, 0.15); transform: translateX(4px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
.skin-issue-event .event-icon {
    width: 40px; height: 40px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; color: white; font-size: 1.2rem; flex-shrink: 0;
}
.skin-issue-event .event-content { flex-grow: 1; }
.skin-issue-event .event-title { font-weight: 600; font-size: 0.95rem; color: #0f1724; margin-bottom: 0.25rem; }
.skin-issue-event .event-details { font-size: 0.8rem; }

/* Age / Gender floating badge (shared style) */
.age-display-box {
    position: absolute; top: 0; left: 0; pointer-events: none; z-index: 13;
    transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2,0,0.2,1);
    opacity: 0; will-change: transform, opacity;
}
.age-display-box .age-display-inner {
    background: rgba(7, 11, 20, 0.74); color: #f8fafc; padding: 0.6rem 0.9rem;
    border-radius: 10px; min-width: 96px; max-width: 18rem;
    box-shadow: 0 6px 18px rgba(2,6,23,0.24); border: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; gap: 0.18rem;
}
.age-display-box .age-value { font-size: 1.3rem; font-weight: 800; line-height: 1; text-align: center; }
.age-display-box .age-label { font-size: 0.66rem; color: rgba(248,250,252,0.88); font-weight: 600; text-align: center; }
.age-display-box .age-category { font-size: 0.72rem; color: rgba(248,250,252,0.78); font-weight: 600; text-align: center; }
.age-display-box .age-confidence { font-size: 0.65rem; color: rgba(248,250,252,0.62); text-align: center; }

/* Emotion box */
#emotion-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 180px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(20, 30, 80, 0.08);
    z-index: 13;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    opacity: 0.99;
    transition: opacity 0.3s ease;
}

.emotion-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f2f8;
}

.emotion-icon {
    font-size: 20px;
    animation: emotionPulse 2s infinite;
}

@keyframes emotionPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.emotion-title {
    font-size: 14px;
    font-weight: 700;
    color: #1b2333;
}

.emotion-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: none;
    overflow: visible;
}

.emotion-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.emotion-label {
    width: 60px;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: #1b2333;
}

.emotion-bar-wrap {
    flex: 1;
    display: flex;
    align-items: center;
}

.emotion-track {
    position: relative;
    width: 100%;
    height: 11px;
    border-radius: 999px;
    background: #e6e9f2;
    overflow: hidden;
}

.emotion-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6a9cff, #6dd3b0);
    transition:
        width 2.5s cubic-bezier(0.25, 0.1, 0.25, 1),
        background 1.8s cubic-bezier(0.25, 0.1, 0.25, 1);
    will-change: width;
}

@media (max-width: 576px) {
    #emotion-box {
        box-sizing: border-box;
        top: 10px !important;
        left: 10px !important;
        width: clamp(145px, 40vw, 170px);
        max-width: calc(100% - 20px);
        height: auto;
        padding: 8px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 4px 12px rgba(20, 30, 80, 0.08);
        gap: 5px;
    }

    #emotion-box .emotion-header {
        gap: 6px;
        padding-bottom: 4px;
    }

    #emotion-box .emotion-icon {
        font-size: 16px;
    }

    #emotion-box .emotion-title {
        font-size: 11px;
        font-weight: 600;
    }

    #emotion-box .emotion-list {
        gap: 4px;
    }

    #emotion-box .emotion-row {
        display: grid;
        grid-template-columns: 50px minmax(0, 1fr);
        justify-content: initial;
        gap: 5px;
    }

    #emotion-box .emotion-label {
        width: auto;
        font-size: 9px;
        white-space: nowrap;
    }

    #emotion-box .emotion-bar-wrap {
        flex: 0 0 auto;
        flex-grow: 0;
        min-width: 0;
        width: clamp(65px, 20vw, 85px);
        justify-self: end;
    }

    #emotion-box .emotion-track {
        width: 100%;
        height: clamp(7px, 2vw, 8px);
        flex: 0 0 auto;
    }

    #emotion-box .emotion-fill {
        transition:
            width 240ms cubic-bezier(0.25, 0.1, 0.25, 1),
            background 240ms cubic-bezier(0.25, 0.1, 0.25, 1);
    }
}

/* Auth pages */
.auth-logo {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #10b981);
    display: flex; align-items: center; justify-content: center; color: white;
    box-shadow: 0 6px 20px rgba(43, 110, 246, 0.25);
}
.auth-logo i { font-size: 2.2rem; }
.auth-footer { text-align: center; margin-top: 1rem; color: var(--muted); font-size: 0.9rem; }

.btn-primary { background: linear-gradient(135deg, var(--accent), #10b981); border: none; }
.btn-primary:hover { background: linear-gradient(135deg, #1d4ed8, #059669); transform: translateY(-2px); }

/* Responsive */
@media (min-width: 992px) {
    .side-panel-mobile { display: none !important; }
    .side-panel-desktop { display: block !important; }
}
@media (max-width: 991.98px) {
    #camera-col,
    #side-panel-desktop {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
    }

    #camera-col { order: 1; }

    #side-panel-desktop {
        display: block !important;
        order: 2;
    }

    .side-panel-mobile { display: none !important; }

    #side-panel-desktop .side-panel {
        width: 100%;
        max-height: none;
        overflow: visible;
    }

    #events-list-desktop {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        max-width: 100%;
        max-height: none;
        overflow: visible;
    }

    #events-list-desktop .event-item {
        width: 100%;
        min-width: 0;
        margin-bottom: 0;
        overflow: visible;
        word-break: normal;
        overflow-wrap: anywhere;
    }

    #events-list-desktop .skin-issue-event {
        align-items: flex-start !important;
    }

    #events-list-desktop .skin-issue-event .event-content {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .video-container { aspect-ratio: 16 / 10; max-height: 60vh; }
}

@media (max-width: 575.98px) {
    .page-header { padding: 0.75rem; gap: 0.5rem; }
    .dashboard-brand img { height: 30px; max-width: 42vw; max-height: 30px; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .dashboard-brand img { height: 28px; max-height: 28px; }
}

/* ==================== FINAL CAMERA FULLSCREEN + RESULTS FIX ==================== */
/* This section supports native fullscreen on desktop/Android/Safari where available,
   and an app-level fallback for Chrome iPhone/iOS WebKit limitations. */

#fullscreen-btn {
    height: 28px;
    padding: 0 0.55rem;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

#fullscreen-btn:hover,
#fullscreen-btn.fs-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.fs-exit-btn,
.fullscreen-results-panel {
    display: none;
}

body.fs-mode {
    overflow: hidden !important;
    width: 100vw !important;
    height: 100dvh !important;
}

body.fs-mode #page-header,
body.fs-mode #side-panel-desktop,
body.fs-mode #side-panel-mobile,
body.fs-mode .bg-canvas {
    display: none !important;
}

body.fs-mode #main-row,
body.fs-mode #camera-col,
body.fs-mode #camera-col > .card-soft {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

body.fs-mode #camera-col > .card-soft > .d-flex.justify-content-between {
    display: none !important;
}

#video-container:fullscreen,
#video-container:-webkit-full-screen,
body.fs-mode #video-container.app-fullscreen-fallback {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    aspect-ratio: unset !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: #000 !important;
    overflow: hidden !important;
    position: relative !important;
    z-index: 2147483000 !important;
}

body.fs-mode #video-container.app-fullscreen-fallback {
    position: fixed !important;
    inset: 0 !important;
    touch-action: none;
}

@supports not (height: 100dvh) {
    body.fs-mode #video-container.app-fullscreen-fallback {
        height: 100vh !important;
    }
}

#video-container:fullscreen #stream-container,
#video-container:-webkit-full-screen #stream-container,
body.fs-mode #video-container.app-fullscreen-fallback #stream-container {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: #000 !important;
}

#video-container:fullscreen #stream-container video,
#video-container:-webkit-full-screen #stream-container video,
body.fs-mode #video-container.app-fullscreen-fallback #stream-container video {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    border-radius: 0 !important;
    background: #000 !important;
}

#video-container:fullscreen #stream-container canvas,
#video-container:-webkit-full-screen #stream-container canvas,
body.fs-mode #video-container.app-fullscreen-fallback #stream-container canvas {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    pointer-events: none !important;
}

#video-container:fullscreen,
#video-container:fullscreen *,
#video-container:-webkit-full-screen,
#video-container:-webkit-full-screen *,
body.fs-mode #video-container.app-fullscreen-fallback,
body.fs-mode #video-container.app-fullscreen-fallback * {
    transition: none !important;
}

#video-container:fullscreen .fs-exit-btn,
#video-container:-webkit-full-screen .fs-exit-btn,
body.fs-mode #video-container.app-fullscreen-fallback .fs-exit-btn {
    display: flex !important;
    position: absolute !important;
    top: calc(12px + env(safe-area-inset-top)) !important;
    right: calc(12px + env(safe-area-inset-right)) !important;
    width: 40px !important;
    height: 40px !important;
    z-index: 2147483010 !important;
}

#video-container:fullscreen #videoControls,
#video-container:-webkit-full-screen #videoControls,
body.fs-mode #video-container.app-fullscreen-fallback #videoControls {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    min-height: 68px !important;
    opacity: 1 !important;
    z-index: 2147483008 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px calc(14px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)) !important;
    background: linear-gradient(transparent, rgba(0,0,0,.58) 32%, rgba(0,0,0,.9)) !important;
}

#video-container:fullscreen #snapshotBtn,
#video-container:-webkit-full-screen #snapshotBtn,
body.fs-mode #video-container.app-fullscreen-fallback #snapshotBtn {
    grid-column: 1 !important;
    justify-self: start !important;
}

#video-container:fullscreen #buttons-slider-container,
#video-container:-webkit-full-screen #buttons-slider-container,
body.fs-mode #video-container.app-fullscreen-fallback #buttons-slider-container {
    grid-column: 2 !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    overflow: hidden !important;
    z-index: auto !important;
}

#video-container:fullscreen #status-wrapper,
#video-container:-webkit-full-screen #status-wrapper,
body.fs-mode #video-container.app-fullscreen-fallback #status-wrapper,
body.fs-mode #video-container.app-fullscreen-fallback #videoControls .ms-auto {
    grid-column: 3 !important;
    justify-self: end !important;
    margin-left: 0 !important;
}

#video-container:fullscreen [data-detector-group="industrial"],
#video-container:-webkit-full-screen [data-detector-group="industrial"],
body.fs-mode #video-container.app-fullscreen-fallback [data-detector-group="industrial"] {
    display: none !important;
}

#video-container:fullscreen [data-detector-group="realtime"],
#video-container:-webkit-full-screen [data-detector-group="realtime"],
body.fs-mode #video-container.app-fullscreen-fallback [data-detector-group="realtime"] {
    display: inline-flex !important;
}

#video-container:fullscreen #buttonsSlider,
#video-container:-webkit-full-screen #buttonsSlider,
body.fs-mode #video-container.app-fullscreen-fallback #buttonsSlider {
    padding: 4px 38px !important;
}

#video-container:fullscreen #buttons-slider-container .slide-btn,
#video-container:-webkit-full-screen #buttons-slider-container .slide-btn,
body.fs-mode #video-container.app-fullscreen-fallback #buttons-slider-container .slide-btn {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    font-size: .85rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: rgba(255,255,255,.88) !important;
}

#video-container:fullscreen #buttons-slider-container .slide-btn:hover,
#video-container:-webkit-full-screen #buttons-slider-container .slide-btn:hover,
body.fs-mode #video-container.app-fullscreen-fallback #buttons-slider-container .slide-btn:hover {
    transform: translateY(-50%) scale(1.02) !important;
}

#video-container:fullscreen #buttons-slider-container .slide-btn.left,
#video-container:-webkit-full-screen #buttons-slider-container .slide-btn.left,
body.fs-mode #video-container.app-fullscreen-fallback #buttons-slider-container .slide-btn.left {
    left: 4px !important;
}

#video-container:fullscreen #buttons-slider-container .slide-btn.right,
#video-container:-webkit-full-screen #buttons-slider-container .slide-btn.right,
body.fs-mode #video-container.app-fullscreen-fallback #buttons-slider-container .slide-btn.right {
    right: 4px !important;
}

/* Fullscreen result panel for Skin/Vital events */
#video-container:fullscreen .fullscreen-results-panel,
#video-container:-webkit-full-screen .fullscreen-results-panel,
body.fs-mode #video-container.app-fullscreen-fallback .fullscreen-results-panel {
    display: flex !important;
    position: absolute !important;
    top: calc(62px + env(safe-area-inset-top)) !important;
    right: calc(14px + env(safe-area-inset-right)) !important;
    width: min(520px, 38vw) !important;
    max-height: calc(100vh - 155px) !important;
    z-index: 2147483007 !important;
    flex-direction: column !important;
    background: rgba(255,255,255,.94) !important;
    backdrop-filter: blur(14px) !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 32px rgba(0,0,0,.28) !important;
    overflow: hidden !important;
}

.fullscreen-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: .86rem;
    font-weight: 700;
    color: #0f1724;
    border-bottom: 1px solid rgba(0,0,0,.08);
    background: linear-gradient(135deg, rgba(43,110,246,.1), rgba(16,185,129,.1));
}

.fullscreen-results-body {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

/* Vital signs result cards */
#events-list-desktop .vital-signs-event {
    border-left-color: var(--success) !important;
}

#events-list-desktop .vital-signs-event .metrics-vertical {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

#events-list-desktop .vital-signs-event .vs-metric-card {
    margin: 0;
    padding: 11px 12px;
    border: 1px solid rgba(43, 110, 246, 0.12);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(43, 110, 246, 0.075), rgba(16, 185, 129, 0.06));
    box-shadow: 0 6px 18px rgba(24, 39, 75, 0.08);
}

#events-list-desktop .vital-signs-event .vs-metric-card--blood-pressure {
    grid-column: 1 / -1;
}

#events-list-desktop .vital-signs-event .vs-metric-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: start;
    gap: 10px;
}

#events-list-desktop .vital-signs-event .vs-metric-copy {
    min-width: 0;
}

#events-list-desktop .vital-signs-event .vs-metric-name {
    font-size: 0.94rem;
    line-height: 1.25;
    font-weight: 650;
    color: #1b2333;
}

#events-list-desktop .vital-signs-event .vs-metric-range {
    margin-top: 4px;
    font-size: 0.74rem;
    line-height: 1.35;
    color: #667085;
}

#events-list-desktop .vital-signs-event .vs-metric-reading {
    display: inline-flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 4px;
    min-width: max-content;
    white-space: nowrap;
    word-break: normal;
    font-variant-numeric: tabular-nums;
}

#events-list-desktop .vital-signs-event .vs-metric-value {
    font-size: 1.56rem;
    line-height: 1;
    font-weight: 800;
    color: var(--accent, #2b6ef6);
    white-space: nowrap;
}

#events-list-desktop .vital-signs-event .vs-metric-unit {
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 500;
    color: #667085;
    white-space: nowrap;
}

#events-list-desktop .vital-signs-event .vs-metric-status {
    margin-top: 9px;
    min-height: 1.15em;
    font-size: 0.76rem;
    line-height: 1.35;
    font-weight: 500;
}

#events-list-desktop .vital-signs-event .vs-metric-card--blood-pressure .vs-metric-name {
    white-space: nowrap;
}

/* Skin cards: keep same design language but slightly larger and clearer */
#events-list-desktop .skin-issue-event {
    padding: 0.9rem !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, rgba(43,110,246,.055), rgba(16,185,129,.045));
    box-shadow: 0 5px 16px rgba(24,39,75,.07);
}

#events-list-desktop .skin-issue-event .event-icon {
    width: 44px;
    height: 44px;
}

#events-list-desktop .skin-issue-event .event-title {
    font-size: 1rem;
}

@media (max-width: 1199.98px) {
    #video-container:fullscreen .fullscreen-results-panel,
    #video-container:-webkit-full-screen .fullscreen-results-panel,
    body.fs-mode #video-container.app-fullscreen-fallback .fullscreen-results-panel {
        width: min(440px, 40vw) !important;
    }
}

@media (max-width: 991.98px) {
    #video-container:fullscreen .fullscreen-results-panel,
    #video-container:-webkit-full-screen .fullscreen-results-panel,
    body.fs-mode #video-container.app-fullscreen-fallback .fullscreen-results-panel {
        width: min(360px, 42vw) !important;
        max-height: calc(100vh - 135px) !important;
    }

    #events-list-desktop .vital-signs-event .metrics-vertical {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    #video-container:fullscreen #videoControls,
    #video-container:-webkit-full-screen #videoControls,
    body.fs-mode #video-container.app-fullscreen-fallback #videoControls {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto !important;
        row-gap: 6px !important;
        padding: 7px calc(8px + env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)) !important;
    }

    #video-container:fullscreen #snapshotBtn,
    #video-container:-webkit-full-screen #snapshotBtn,
    body.fs-mode #video-container.app-fullscreen-fallback #snapshotBtn {
        grid-column: 1 !important;
        grid-row: 1 !important;
        justify-self: start !important;
    }

    #video-container:fullscreen #status-wrapper,
    #video-container:-webkit-full-screen #status-wrapper,
    body.fs-mode #video-container.app-fullscreen-fallback #status-wrapper,
    body.fs-mode #video-container.app-fullscreen-fallback #videoControls .ms-auto {
        grid-column: 1 !important;
        grid-row: 1 !important;
        justify-self: end !important;
    }

    #video-container:fullscreen #buttons-slider-container,
    #video-container:-webkit-full-screen #buttons-slider-container,
    body.fs-mode #video-container.app-fullscreen-fallback #buttons-slider-container {
        grid-column: 1 !important;
        grid-row: 2 !important;
    }

    #video-container:fullscreen .fullscreen-results-panel,
    #video-container:-webkit-full-screen .fullscreen-results-panel,
    body.fs-mode #video-container.app-fullscreen-fallback .fullscreen-results-panel {
        left: calc(8px + env(safe-area-inset-left)) !important;
        right: calc(8px + env(safe-area-inset-right)) !important;
        top: auto !important;
        bottom: calc(96px + env(safe-area-inset-bottom)) !important;
        width: auto !important;
        max-height: 34vh !important;
    }

    #video-container:fullscreen #buttons-slider-container .slide-btn,
    #video-container:-webkit-full-screen #buttons-slider-container .slide-btn,
    body.fs-mode #video-container.app-fullscreen-fallback #buttons-slider-container .slide-btn {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        min-height: 24px !important;
        font-size: .72rem !important;
    }

}

@media (max-height: 500px) and (orientation: landscape) {
    #video-container:fullscreen #videoControls,
    #video-container:-webkit-full-screen #videoControls,
    body.fs-mode #video-container.app-fullscreen-fallback #videoControls {
        min-height: 54px !important;
        padding-top: 5px !important;
        padding-bottom: calc(6px + env(safe-area-inset-bottom)) !important;
    }

    #video-container:fullscreen .fullscreen-results-panel,
    #video-container:-webkit-full-screen .fullscreen-results-panel,
    body.fs-mode #video-container.app-fullscreen-fallback .fullscreen-results-panel {
        top: calc(48px + env(safe-area-inset-top)) !important;
        right: calc(8px + env(safe-area-inset-right)) !important;
        bottom: calc(64px + env(safe-area-inset-bottom)) !important;
        width: min(340px, 36vw) !important;
        max-height: none !important;
    }
}

/* ==================== FULLSCREEN LIVE RESULTS POSITION FIX ==================== */
/* Show Live Results only after Skin/Vital is activated inside fullscreen */
#video-container:fullscreen .fullscreen-results-panel,
#video-container:-webkit-full-screen .fullscreen-results-panel,
body.fs-mode #video-container.app-fullscreen-fallback .fullscreen-results-panel {
    display: none !important;
}

body.fs-mode.fs-results-visible #video-container:fullscreen .fullscreen-results-panel,
body.fs-mode.fs-results-visible #video-container:-webkit-full-screen .fullscreen-results-panel,
body.fs-mode.fs-results-visible #video-container.app-fullscreen-fallback .fullscreen-results-panel {
    display: flex !important;
}

/* Put Live Results in the opposite corner: top-left */
body.fs-mode.fs-results-visible #video-container:fullscreen .fullscreen-results-panel,
body.fs-mode.fs-results-visible #video-container:-webkit-full-screen .fullscreen-results-panel,
body.fs-mode.fs-results-visible #video-container.app-fullscreen-fallback .fullscreen-results-panel {
    position: absolute !important;
    top: calc(58px + env(safe-area-inset-top)) !important;
    left: calc(14px + env(safe-area-inset-left)) !important;
    right: auto !important;
    bottom: auto !important;

    width: 315px !important;
    max-width: calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)) !important;
    max-height: calc(100vh - 145px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;

    z-index: 2147483007 !important;
    flex-direction: column !important;
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(14px) !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.24) !important;
    overflow: hidden !important;
}

/* Smaller header */
.fullscreen-results-header {
    padding: 8px 10px !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    color: #0f1724 !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    background: linear-gradient(
        135deg,
        rgba(43, 110, 246, 0.08),
        rgba(16, 185, 129, 0.08)
    ) !important;
}

/* Scrollable body */
.fullscreen-results-body {
    padding: 8px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Keep result cards stacked under each other */
body.fs-mode.fs-results-visible #events-list-desktop {
    display: flex !important;
    flex-direction: column !important;
    gap: 7px !important;
    max-height: none !important;
    overflow: visible !important;
}

/* General result card size inside fullscreen */
body.fs-mode.fs-results-visible #events-list-desktop .event-item {
    margin-bottom: 0 !important;
    padding: 0.65rem !important;
    border-radius: 10px !important;
    font-size: 0.78rem !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: 0 4px 12px rgba(24, 39, 75, 0.08) !important;
}

/* Skin cards: same old style but smaller */
body.fs-mode.fs-results-visible #events-list-desktop .skin-issue-event {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0.65rem !important;
    background: rgba(43, 110, 246, 0.05) !important;
}

body.fs-mode.fs-results-visible #events-list-desktop .skin-issue-event .event-icon {
    width: 34px !important;
    height: 34px !important;
    font-size: 0.95rem !important;
}

body.fs-mode.fs-results-visible #events-list-desktop .skin-issue-event .event-title {
    font-size: 0.84rem !important;
    font-weight: 700 !important;
}

body.fs-mode.fs-results-visible #events-list-desktop .skin-issue-event .event-details {
    font-size: 0.72rem !important;
}

/* Vital main card compact */
body.fs-mode.fs-results-visible #events-list-desktop .vital-signs-event {
    padding: 0.65rem !important;
    border-left: 4px solid var(--success) !important;
    background: rgba(255, 255, 255, 0.96) !important;
}

/* Hide empty no-events placeholder inside fullscreen results */
body.fs-mode.fs-results-visible #events-list-desktop #no-recent-events {
    display: none !important;
}

/* Mobile portrait: keep it in top-left corner, compact */
@media (max-width: 576px) {
    body.fs-mode.fs-results-visible #video-container:fullscreen .fullscreen-results-panel,
    body.fs-mode.fs-results-visible #video-container:-webkit-full-screen .fullscreen-results-panel,
    body.fs-mode.fs-results-visible #video-container.app-fullscreen-fallback .fullscreen-results-panel {
        top: calc(54px + env(safe-area-inset-top)) !important;
        left: calc(8px + env(safe-area-inset-left)) !important;
        right: auto !important;
        bottom: auto !important;

        width: min(290px, calc(100vw - 16px)) !important;
        max-height: 38vh !important;
        border-radius: 12px !important;
    }

    .fullscreen-results-header {
        padding: 7px 9px !important;
        font-size: 0.74rem !important;
    }

    .fullscreen-results-body {
        padding: 7px !important;
    }

    body.fs-mode.fs-results-visible #events-list-desktop .event-item {
        padding: 0.55rem !important;
        font-size: 0.74rem !important;
    }

    body.fs-mode.fs-results-visible #events-list-desktop .skin-issue-event .event-icon {
        width: 30px !important;
        height: 30px !important;
    }

}

/* Mobile landscape */
@media (max-height: 500px) and (orientation: landscape) {
    body.fs-mode.fs-results-visible #video-container:fullscreen .fullscreen-results-panel,
    body.fs-mode.fs-results-visible #video-container:-webkit-full-screen .fullscreen-results-panel,
    body.fs-mode.fs-results-visible #video-container.app-fullscreen-fallback .fullscreen-results-panel {
        top: calc(46px + env(safe-area-inset-top)) !important;
        left: calc(8px + env(safe-area-inset-left)) !important;
        width: min(285px, 34vw) !important;
        max-height: calc(100vh - 112px) !important;
    }
}
