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

html {
    width: 100%;
    overflow-x: hidden;
}

@media (max-width: 767px) {
    html {
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
    }
}

/* =========================================================
   DESKTOP UI (FINAL OVERRIDES - keep at END OF FILE)
   Applies to Desktop/Tablet only. Mobile (<=767px) untouched.
   ========================================================= */
@media (min-width: 768px) {
    :root {
        --c-primary: #6A5AE0;
        --c-secondary: #3B82F6;
        --c-success: #22C55E;
        --c-danger: #EF4444;
        --c-bg-1: #f5f7ff;
        --c-bg-2: #f2f6ff;
        --c-card: rgba(255, 255, 255, 0.88);
        --c-border: rgba(20, 23, 39, 0.10);
        --shadow-1: 0 10px 30px rgba(20, 23, 39, 0.10);
        --shadow-2: 0 18px 50px rgba(20, 23, 39, 0.16);
        --r-12: 12px;
        --r-16: 16px;
    }

    body {
        background: linear-gradient(135deg, var(--c-bg-1), var(--c-bg-2)) !important;
        padding: 18px !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .app-container {
        max-width: 1600px;
        width: 100%;
        height: calc(100vh - 36px);
        min-height: 720px;
        border-radius: 14px;
        overflow: hidden;
        background: white;
    }

    /* Header */
    .title-bar {
        height: 56px !important;
        padding: 10px 16px !important;
        background: linear-gradient(90deg, #6A5AE0 0%, #3B82F6 55%, #2EC5FF 100%) !important;
        box-shadow: 0 8px 24px rgba(25, 30, 60, 0.18) !important;
    }

    /* Main content */
    .main-content {
        padding: 18px 18px 0 18px !important;
        background: linear-gradient(135deg, #ffffff 0%, #fbfdff 55%, #ffffff 100%) !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        min-height: 0 !important;
    }

    .desktop-grid {
        display: grid !important;
        grid-template-columns: 420px 1fr !important;
        gap: 18px !important;
        align-items: start !important;
        width: 100% !important;
        flex: 1 !important;
        min-height: 0 !important;
    }

    .desktop-left {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        min-width: 0 !important;
    }

    .desktop-right {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        min-width: 0 !important;
        gap: 12px !important;
    }

    /* Status cards: STOP old absolute layout */
    .status-indicators {
        position: static !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 14px !important;
        pointer-events: auto !important;
        z-index: auto !important;
    }

    .status-item {
        border-radius: var(--r-16) !important;
        border: 1px solid var(--c-border) !important;
        background: var(--c-card) !important;
        box-shadow: var(--shadow-1) !important;
        padding: 16px 16px !important;
        color: #13162a !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }

    /* Hide extra type card – shown in header pills */
    #machine-type { display: none !important; }
    
    /* Hide redundant header pills (Mode, Type, Machine ID) in desktop */
    .title-center,
    #headerMachinePill {
        display: none !important;
    }

    .status-card-text {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 0;
    }
    .status-card-title {
        font-size: 13px;
        font-weight: 800;
        color: rgba(17, 24, 39, 0.70);
        letter-spacing: 0.2px;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .status-card-value {
        font-size: 22px;
        font-weight: 900;
        color: #0f172a;
        line-height: 1.05;
    }

    /* Live Capture: STOP old absolute positioning */
    .capture-preview-container {
        position: static !important;
        left: auto !important;
        top: auto !important;
        right: auto !important;
        transform: none !important;
        width: 100% !important;
        border: 1px solid var(--c-border) !important;
        border-radius: var(--r-16) !important;
        background: rgba(255, 255, 255, 0.92) !important;
        box-shadow: var(--shadow-1) !important;
        padding: 14px !important;
        z-index: auto !important;
        margin-top: 6px !important;
    }

    .capture-preview-header {
        font-size: 18px !important;
        font-weight: 900 !important;
        color: #13162a !important;
        text-align: left !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        margin-bottom: 6px !important;
    }
    .capture-preview-header::after {
        content: "⋯";
        color: rgba(17, 24, 39, 0.45);
        font-size: 18px;
        line-height: 1;
    }
    #capturePreviewCanvas {
        height: 200px !important;
        border-radius: 14px !important;
    }

    /* Thumbnail: STOP old absolute positioning */
    .thumbnail-container {
        position: static !important;
        left: auto !important;
        bottom: auto !important;
        width: 100% !important;
        margin-top: 14px !important;
        z-index: auto !important;
    }
    .thumbnail-frame {
        width: 100% !important;
        height: 220px !important;
        border-radius: var(--r-16) !important;
    }

    /* Camera: square 4:3 with grid overlay */
    .video-container {
        width: min(920px, 100%) !important;
        height: 770px !important; /* Adjust this value to match Live Capture section height */
        margin: 0 !important;
        position: relative !important;
        display: flex !important;
        align-items: stretch !important;
        justify-content: center !important;
    }
    .circular-frame {
        width: min(920px, 100%) !important;
        height: 770px !important; /* Adjust this value to match Live Capture section height */
        border-radius: var(--r-16) !important;
        overflow: hidden !important;
        border: 1px solid var(--c-border) !important;
        box-shadow: var(--shadow-2) !important;
        background: linear-gradient(180deg, #f7f9ff, #f3f6ff) !important;
    }
    .circular-frame::before {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        z-index: 6;
        opacity: 0.20;
        background-image:
            linear-gradient(to right, rgba(255, 255, 255, 0.35) 1px, transparent 1px),
            linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
        background-size: calc(100% / 4) calc(100% / 4);
        mix-blend-mode: overlay;
    }
    #videoElement { border-radius: 0 !important; }
    #canvasElement { border-radius: 0 !important; }

    /* Bottom action bar */
    .desktop-action-bar {
        position: fixed !important;
        left: 18px !important;
        right: 18px !important;
        bottom: 18px !important;
        height: 92px !important;
        border-radius: 16px !important;
        max-width: 1600px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        z-index: 200 !important;
    }
    .main-content { padding-bottom: 130px !important; }

    /* Kill legacy absolute controls positioning */
    .controls {
        position: static !important;
        left: auto !important;
        bottom: auto !important;
        transform: none !important;
        margin: 0 !important;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f0f0;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    margin: 0;
}

/* =========================================================
   Desktop Redesign (DESKTOP ONLY)
   - Do NOT affect Mobile View
   ========================================================= */
@media (min-width: 768px) {
    :root {
        --c-primary: #6A5AE0;
        --c-secondary: #3B82F6;
        --c-success: #22C55E;
        --c-danger: #EF4444;
        --c-bg-1: #f5f7ff;
        --c-bg-2: #f2f6ff;
        --c-card: rgba(255, 255, 255, 0.85);
        --c-border: rgba(20, 23, 39, 0.08);
        --shadow-1: 0 10px 30px rgba(20, 23, 39, 0.10);
        --shadow-2: 0 18px 50px rgba(20, 23, 39, 0.16);
        --r-12: 12px;
        --r-16: 16px;
    }

    body {
        background: linear-gradient(135deg, var(--c-bg-1), var(--c-bg-2));
        padding: 18px;
    }

    .app-container {
        border-radius: 14px;
        overflow: hidden;
        background: white;
    }

    /* Header */
    .title-bar {
        height: 56px;
        padding: 10px 16px;
        background: linear-gradient(90deg, #6A5AE0 0%, #3B82F6 55%, #2EC5FF 100%);
        box-shadow: 0 8px 24px rgba(25, 30, 60, 0.18);
        -webkit-app-region: drag;
        gap: 12px;
    }

    .title-left,
    .title-center,
    .title-right {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
    }

    .title-left {
        flex: 1 1 auto;
        min-width: 220px;
    }

    .title-center {
        flex: 0 0 auto;
        justify-content: center;
        gap: 8px;
    }

    .title-right {
        flex: 1 1 auto;
        justify-content: flex-end;
        gap: 10px;
    }

    .app-logo {
        width: 28px;
        height: 28px;
        border-radius: 10px;
        background:
            radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.35) 45%, rgba(255, 255, 255, 0.0) 70%),
            linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.08));
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
        border: 1px solid rgba(255, 255, 255, 0.35);
    }

    .title-text {
        font-size: 15px;
        font-weight: 700;
        letter-spacing: 0.2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-pill {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 10px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.18);
        border: 1px solid rgba(255, 255, 255, 0.26);
        color: rgba(255, 255, 255, 0.98);
        font-weight: 700;
        font-size: 12px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        user-select: none;
    }

    .header-pill-strong {
        background: rgba(255, 255, 255, 0.24);
    }

    .header-icon-btn {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, 0.26);
        background: rgba(255, 255, 255, 0.18);
        color: white;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        line-height: 1;
        -webkit-app-region: no-drag;
        transition: transform 200ms ease, background 200ms ease;
    }

    .header-icon-btn:hover {
        background: rgba(255, 255, 255, 0.26);
        transform: translateY(-1px);
    }

    .window-controls {
        -webkit-app-region: no-drag;
    }

    /* Main layout: 2-column grid + sticky bottom action bar */
    .main-content {
        padding: 18px 18px 0 18px;
        background: linear-gradient(135deg, #ffffff 0%, #fbfdff 55%, #ffffff 100%);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .desktop-grid {
        display: grid;
        grid-template-columns: 420px 1fr;
        gap: 18px;
        align-items: stretch;
        flex: 1;
        min-height: 0;
    }

    .desktop-left {
        display: flex;
        flex-direction: column;
        gap: 14px;
        min-width: 0;
    }

    .desktop-right {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: center;
        justify-content: flex-start;
        align-self: stretch;
        height: 100%;
    }
    
    /* Ensure video container fills the right column height */
    .desktop-right .video-container {
        flex: 1 1 auto;
        min-height: 0;
    }

    /* Status: convert to pastel cards */
    .status-indicators {
        position: static;
        padding: 0;
        gap: 14px;
        pointer-events: auto;
        display: grid;
        grid-template-columns: 1fr 1fr;
        margin-bottom: 18px; /* push panels down so they never overlap cards */
    }

    .status-item {
        border-radius: var(--r-16);
        border: 1px solid var(--c-border);
        background: var(--c-card);
        box-shadow: var(--shadow-1);
        padding: 16px 16px;
        color: #13162a;
        display: flex;
        align-items: center;
        gap: 10px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        cursor: default;
    }

    /* Hide the legacy "Type" card on desktop (shown in header instead) */
    #machine-type {
        display: none;
    }

    .status-card-text {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 0;
    }

    .status-card-title {
        font-size: 13px;
        font-weight: 800;
        color: rgba(17, 24, 39, 0.70);
        letter-spacing: 0.2px;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .status-card-value {
        font-size: 22px;
        font-weight: 900;
        color: #0f172a;
        line-height: 1.05;
    }

    /* Icons for cards (pure CSS, no DOM changes) */
    #mode-status::before {
        content: "Ⓜ";
        width: 30px;
        height: 30px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(106, 90, 224, 0.16);
        color: var(--c-primary);
        font-weight: 900;
        flex: 0 0 auto;
    }

    #faces-status::before {
        content: "👥";
        width: 30px;
        height: 30px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(59, 130, 246, 0.16);
        color: var(--c-secondary);
        flex: 0 0 auto;
    }

    #machine-status::before {
        content: "🆔";
        width: 30px;
        height: 30px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(20, 23, 39, 0.06);
        color: #111827;
        flex: 0 0 auto;
    }

    #machine-type::before {
        content: "🔐";
        width: 30px;
        height: 30px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(59, 130, 246, 0.14);
        color: var(--c-secondary);
        flex: 0 0 auto;
    }

    #liveness-status::before {
        content: "🛡️";
        width: 30px;
        height: 30px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(34, 197, 94, 0.14);
        color: var(--c-success);
        flex: 0 0 auto;
    }

    .status-item:hover {
        transform: translateY(-1px);
        box-shadow: var(--shadow-2);
    }

    /* Live capture card */
    .capture-preview-container {
        position: static !important;
        width: 100%;
        border: 1px solid var(--c-border);
        border-radius: var(--r-16);
        background: rgba(255, 255, 255, 0.92);
        box-shadow: var(--shadow-1);
        padding: 14px;
        left: auto;
        top: auto;
        right: auto;
        transform: none;
        margin-top: 2px;
    }

    .capture-preview-header {
        font-size: 18px;
        font-weight: 900;
        color: #13162a;
        text-align: left;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 6px;
    }

    .capture-preview-header::after {
        content: "⋯";
        color: rgba(17, 24, 39, 0.45);
        font-size: 18px;
        line-height: 1;
    }

    #capturePreviewCanvas {
        height: 140px;
        border-radius: 14px;
        border: 1px solid rgba(20, 23, 39, 0.10);
        background: linear-gradient(180deg, #f7f9ff, #f3f6ff);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    }

    /* Thumbnail card - positioned at bottom-left, parallel layout */
    .thumbnail-container {
        position: static !important;
        left: auto !important;
        bottom: auto !important;
        width: 100%;
        max-width: 100%;
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        flex-wrap: wrap !important;
        gap: 8px;
        margin-top: 2px; /* Further reduced spacing to bring it up and prevent scrolling */
    }
    
    /* Add "Last Capture" label to thumbnail container on desktop - spans full width */
    .thumbnail-container::before {
        content: "Last Capture";
        font-size: 18px;
        font-weight: 900;
        color: #13162a;
        text-align: left;
        width: 100%;
        margin-bottom: 4px;
        display: block;
        order: -1;
    }
    
    /* For REGISTER mode, change "Last Capture" to "Prior Registrations" */
    body.register-mode .thumbnail-container::before {
        content: "Prior Registrations";
    }
    
    /* On desktop, show thumbnail-frame only - hide thumbnail-status (response box) */
    .thumbnail-container .thumbnail-frame {
        flex-shrink: 0;
        width: 30px;
        height: 30px;
        order: 1;
    }
    
    .thumbnail-container .thumbnail-status {
        display: none !important; /* Hide response box on desktop - now shown in camera overlay */
    }
    
    /* Ensure buttons stay below on new line */
    .thumbnail-container .prior-registrations-btn,
    .thumbnail-container .upload-image-btn {
        order: 10;
        width: 100%;
    }

    .thumbnail-frame {
        width: 30px;
        height: 30px;
        flex-shrink: 0;
        border-radius: var(--r-16);
        border: 1px solid var(--c-border);
        box-shadow: var(--shadow-1);
    }

    .thumbnail-status {
        flex: 1;
        min-width: 0;
        max-width: none;
        min-width: 200px;
        max-width: 220px;
        max-height: 180px;
        border-radius: var(--r-16);
        font-size: 13px;
        padding: 10px 12px;
        line-height: 1.4;
        overflow-y: auto;
    }

    /* Camera: square container with grid overlay (keep IDs/layers intact) */
    .video-container {
        width: min(920px, 100%);
        height: 550px; /* Adjust this value to match Live Capture section height */
        margin: 0;
        display: flex;
        align-items: stretch;
        justify-content: center;
    }

    .circular-frame {
        width: min(920px, 100%);
        height: 550px; /* Adjust this value to match Live Capture section height */
        border-radius: var(--r-16) !important;
        overflow: hidden !important;
        border: 1px solid var(--c-border) !important;
        box-shadow: var(--shadow-2) !important;
        background: linear-gradient(180deg, #f7f9ff, #f3f6ff) !important;
        position: relative;
    }

    /* Grid overlay on camera */
    .circular-frame::before {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        z-index: 6;
        opacity: 0.20;
        background-image:
            linear-gradient(to right, rgba(255, 255, 255, 0.35) 1px, transparent 1px),
            linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
        background-size: calc(100% / 4) calc(100% / 4);
        mix-blend-mode: overlay;
    }

    #videoElement,
    #canvasElement {
        border-radius: 0 !important;
    }

    /* Glass overlay chips */
    .camera-glass-overlay {
        position: absolute;
        left: 14px;
        right: 14px;
        top: 14px;
        bottom: auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        pointer-events: none;
        z-index: 18;
    }

    .camera-status-chip,
    .camera-live-chip {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        border-radius: 999px;
        background: rgba(20, 23, 39, 0.35);
        border: 1px solid rgba(255, 255, 255, 0.18);
        color: rgba(255, 255, 255, 0.98);
        font-weight: 800;
        letter-spacing: 0.2px;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
    }
    
    /* Make Live Camera chip shorter */
    .camera-live-chip {
        padding: 8px 10px;
        font-size: 13px;
    }

    .camera-status-chip {
        background: rgba(239, 68, 68, 0.38);
    }

    .camera-status-chip.detected {
        background: rgba(34, 197, 94, 0.38);
    }

    .camera-live-chip {
        background: rgba(20, 23, 39, 0.35);
    }

    .live-dot {
        width: 10px;
        height: 10px;
        border-radius: 999px;
        background: var(--c-success);
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.18);
        animation: livePulse 1.4s ease-in-out infinite;
    }

    @keyframes livePulse {
        0%, 100% { transform: scale(1); opacity: 1; }
        50% { transform: scale(1.15); opacity: 0.85; }
    }

    /* Bottom action bar (fixed to bottom on desktop) */
    .desktop-action-bar {
        position: fixed;
        left: 18px;
        right: 18px;
        bottom: 18px;
        margin-top: 0;
        height: 92px;
        display: grid;
        grid-template-columns: 220px 1fr 260px;
        align-items: center;
        gap: 14px;
        padding: 14px 16px;
        background: rgba(255, 255, 255, 0.92);
        border: 1px solid var(--c-border);
        border-radius: 16px;
        box-shadow: 0 18px 50px rgba(20, 23, 39, 0.14);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 200;
        max-width: 1600px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Hide results panel on desktop by default (show results in thumbnail-status like mobile) */
    .results-panel {
        display: none !important;
    }
    
    /* Override .visible class on desktop - only show with .visible-desktop */
    .results-panel.visible {
        display: none !important;
    }
    
    /* Show results panel when toggled via Alt+V */
    .results-panel.visible-desktop {
        display: flex !important;
    }
    
    /* Ensure main content can't be hidden behind the fixed action bar - reduced to prevent scrolling */
    .main-content {
        padding-bottom: 110px;
    }

    .desktop-action-status {
        font-weight: 800;
        color: #111827;
        font-size: 14px;
        padding: 10px 12px;
        border-radius: var(--r-12);
        background: rgba(34, 197, 94, 0.10);
        border: 1px solid rgba(34, 197, 94, 0.18);
    }

    .desktop-action-hint {
        justify-self: end;
        color: rgba(17, 24, 39, 0.60);
        font-weight: 700;
        font-size: 12px;
        white-space: nowrap;
    }

    /* Controls become big colored buttons on desktop */
    .controls {
        position: static !important;
        left: auto !important;
        bottom: auto !important;
        transform: none !important;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 14px;
        margin: 0;
    }

    .control-item {
        flex-direction: column;
        gap: 6px;
        transform: none !important;
    }

    .key {
        color: rgba(17, 24, 39, 0.55);
        font-weight: 800;
        font-size: 12px;
    }

    .action {
        min-width: 140px;
        padding: 12px 18px;
        border-radius: 14px;
        font-size: 18px;
        font-weight: 900;
        color: white;
        border: none;
        box-shadow: 0 10px 20px rgba(20, 23, 39, 0.12);
        transition: transform 220ms ease, box-shadow 220ms ease, filter 220ms ease;
        user-select: none;
    }

    .action:hover {
        transform: translateY(-2px);
        box-shadow: 0 14px 26px rgba(20, 23, 39, 0.18);
        filter: brightness(1.02);
    }

    .action:active {
        transform: translateY(0);
        box-shadow: 0 10px 18px rgba(20, 23, 39, 0.14);
        filter: brightness(0.98);
    }

    /* semantic colors - ensure these override any general .action rules */
    .action-manual { 
        background: var(--c-primary) !important;
        border: none !important;
    }
    .action-manual:hover {
        background: var(--c-primary) !important;
        filter: brightness(1.1);
    }
    .action-auto { 
        background: var(--c-secondary) !important;
        border: none !important;
        color: white !important;
    }
    .action-auto:hover {
        background: var(--c-secondary) !important;
        color: white !important;
        filter: brightness(1.1);
    }
    .action-capture { 
        background: var(--c-success) !important;
        border: none !important;
        color: white !important;
    }
    .action-capture:hover {
        background: var(--c-success) !important;
        color: white !important;
        filter: brightness(1.1);
    }
    .action-stop { 
        background: var(--c-danger) !important;
        border: none !important;
        color: white !important;
    }
    .action-stop:hover {
        background: var(--c-danger) !important;
        color: white !important;
        filter: brightness(1.1);
    }

    /* Hide legacy desktop floating positioning artifacts */
    .video-container .capture-preview-container {
        position: static !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
    }
}

@media (max-width: 767px) {
    body {
        padding: 0;
        margin: 0;
        justify-content: flex-start;
        align-items: flex-start;
        width: 100vw;
        overflow-x: hidden;
    }
}

@media (max-width: 1024px) {
    body {
        padding: 0;
        overflow-y: hidden;
        height: 100vh;
        align-items: flex-start;
    }
}

.app-container {
    width: 100%;
    height: 100%;
    min-height: 96vh;
    background: white;
    display: flex;
    flex-direction: column;
    max-width: 1600px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

@media (max-width: 1024px) {
    .app-container {
        min-height: 100vh;
        height: 100vh;
        max-width: 100vw;
        width: 100vw;
        box-shadow: none;
        margin: 0;
        padding: 0;
    }
}

@media (max-width: 767px) {
    .app-container {
        max-width: 100vw;
        width: 100vw;
        margin: 0;
        padding: 0;
    }
}

/* Title Bar */
.title-bar {
    background: #2c3e50;
    color: white;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 40px;
    -webkit-app-region: drag;
    user-select: none;
}

.title-text {
    font-size: 14px;
    font-weight: 500;
}

.window-controls {
    display: flex;
    gap: 8px;
    -webkit-app-region: no-drag;
}

.control-btn {
    width: 30px;
    height: 24px;
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.close:hover {
    background: #e74c3c;
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: clamp(16px, 2vw, 32px);
    background: white;
    width: 100%;
    margin: 0 auto;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .main-content {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

/* Status Indicators */
.status-indicators {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 30px;
    z-index: 10;
    pointer-events: none;
}

.status-item {
    color: black;
    font-size: 16px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 16px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

/* Desktop: Enhanced status items */
@media (min-width: 768px) {
    .status-item {
        font-size: 15px;
        padding: 7px 18px;
        border-radius: 8px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    }
    
    .status-item:hover {
        background: rgba(255, 255, 255, 1);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

.status-item.liveness-item {
    min-width: 170px;
    text-align: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.status-item.liveness-item.active {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.status-item.liveness-item.ok {
    background: rgba(40, 167, 69, 0.18);
    color: #155724;
}

.status-item.liveness-item.warn {
    background: rgba(220, 53, 69, 0.15);
    color: #842029;
}

.expecting-person {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: #d4edda;
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 12px 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.expecting-person-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.expecting-label {
    color: #155724;
}

.expecting-name {
    color: #155724;
    font-weight: 700;
}

/* Video Container */
.video-container {
    position: relative;
    width: min(600px, 82vw);
    height: min(600px, 82vw);
    max-width: 90vw;
    max-height: 90vw;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

/* Desktop: Improved video container */
@media (min-width: 768px) {
    .video-container {
        position: relative;
        width: min(650px, 85vw);
        height: min(650px, 85vw);
        max-width: 90vw;
        max-height: 90vw;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 30px;
    }
    
    .circular-frame {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        box-shadow: 0 6px 30px rgba(0, 0, 0, 0.15);
        border: 4px solid #e0e0e0;
        transition: border-color 0.3s ease, box-shadow 0.3s ease;
    }
    
    .circular-frame:hover {
        border-color: #00aa00;
        box-shadow: 0 8px 35px rgba(0, 170, 0, 0.2);
    }
    
    #videoElement {
        border-radius: 50%;
    }
    
    /* Position Live Capture outside the circle on the left */
    /* Allow overflow visible on circular-frame so capture-preview can escape */
    /* Keep video/canvas circular using border-radius directly */
    .video-container .circular-frame {
        overflow: visible;
    }
    
    .video-container .circular-frame #videoElement,
    .video-container .circular-frame #canvasElement {
        border-radius: 50%;
        overflow: hidden;
    }
    
    .video-container .capture-preview-container {
        position: absolute;
        top: 50%;
        left: -250px;
        right: auto;
        transform: translateY(-50%);
        width: 220px;
        padding: 14px;
        border-radius: 14px;
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
        z-index: 1000;
    }
}

.circular-frame {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    border: 3px solid #e0e0e0;
    background: #f5f5f5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Submitting Overlay for Mobile */
.submitting-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.6), transparent);
    padding: 20px;
    display: none;
    z-index: 19; /* Lower than result overlay (20) so results show on top */
    border-radius: 0;
    align-items: center;
    justify-content: center;
}

.submitting-overlay.visible {
    display: flex;
}

.submitting-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.submitting-spinner {
    font-size: 32px;
    animation: pulse 1.5s ease-in-out infinite;
}

.submitting-text {
    color: white;
    font-size: clamp(16px, 4.5vw, 20px);
    font-weight: 600;
    text-align: center;
}

/* Mobile responsive adjustments for submitting overlay */
@media (max-width: 767px) {
    .submitting-overlay {
        padding: clamp(16px, 5vw, 24px);
    }
    
    .submitting-spinner {
        font-size: clamp(28px, 8vw, 36px);
    }
    
    .submitting-content {
        gap: clamp(10px, 3vw, 14px);
    }
}

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

/* Desktop: Hide submitting overlay */
@media (min-width: 768px) {
    .submitting-overlay {
        display: none !important;
    }
}

/* Result Overlay for Mobile */
.result-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.6), transparent);
    padding: 16px 12px 12px 12px;
    display: none;
    z-index: 20;
    border-radius: 0;
}

.result-overlay.visible {
    display: block;
}

/* Desktop: Show result overlay with same styling as mobile */
@media (min-width: 768px) {
    .result-overlay {
        padding: 14px 10px 10px 10px;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7), transparent);
        transition: background 0.3s ease;
    }
    
    .result-overlay.visible {
        display: block;
    }
    
    /* Success cases (green) - IN and other successful statuses */
    .result-overlay.success {
        background: linear-gradient(to top, rgba(0, 170, 0, 0.85), rgba(0, 170, 0, 0.65), transparent);
    }
    
    /* OUT cases (blue) */
    .result-overlay.out {
        background: linear-gradient(to top, rgba(0, 123, 255, 0.85), rgba(0, 123, 255, 0.65), transparent);
    }
    
    /* Rejected/Failed cases (red) */
    .result-overlay.rejected {
        background: linear-gradient(to top, rgba(231, 76, 60, 0.85), rgba(231, 76, 60, 0.65), transparent);
    }
    
    /* Last person details (yellow) - shown after results hide */
    .result-overlay.last-person {
        background: linear-gradient(to top, rgba(255, 193, 7, 0.85), rgba(255, 193, 7, 0.65), transparent);
    }
    
    .result-overlay-content {
        font-size: 13px;
        line-height: 1.4;
    }
    
    .result-overlay-content .result-name {
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 6px;
    }
    
    .result-overlay-content .result-name .result-icon {
        font-size: 20px;
        margin-right: 6px;
    }
    
    .result-overlay-content .result-details {
        font-size: 12px;
        gap: 8px;
        margin-top: 4px;
        flex-wrap: wrap;
    }
    
    .result-overlay-content .result-detail-item {
        font-size: 12px;
        white-space: nowrap;
    }
    
    .result-overlay-content .result-time {
        font-size: 11px;
        margin-top: 6px;
        opacity: 0.9;
    }
}

.result-overlay-content {
    color: white;
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
}

.result-overlay-content .result-name {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-overlay-content .result-name .result-icon {
    font-size: 20px;
}

.result-overlay-content .result-details {
    font-size: 13px;
    opacity: 0.95;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 6px;
}

.result-overlay-content .result-detail-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.result-overlay-content .result-time {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 4px;
    font-style: italic;
}

#videoElement {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror effect */
    background: #f5f5f5; /* Light grey background when no video stream - never dark */
}

#canvasElement {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.face-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.face-bracket {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #00ff00;
    pointer-events: none;
}

.face-bracket.top-left {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
}

.face-bracket.top-right {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
}

.face-bracket.bottom-left {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
}

.face-bracket.bottom-right {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
}

/* Live Capture Preview */
.capture-preview-container {
    position: absolute;
    top: 140px;
    left: clamp(20px, 26vw, 420px);
    right: auto;
    width: 200px;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid #00aa00;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 950;
    transition: opacity 0.2s ease;
}

/* Desktop: Live Capture positioned on left outside the circle with improved styling */
@media (min-width: 768px) {
    .capture-preview-container {
        /* Positioned relative to video-container in the desktop media query above */
    }
    
    .capture-preview-header {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    #capturePreviewCanvas {
        height: 160px;
        border-radius: 10px;
    }
    
    .capture-preview-note {
        font-size: 13px;
        margin-top: 6px;
    }
    
    /* Hide result overlay on desktop - use thumbnail status instead */
    .result-overlay {
        display: none;
    }
}

.capture-preview-container.disabled {
    opacity: 0.4;
    border-style: dashed;
}

.capture-preview-container.showing-image {
    opacity: 1;
}

.capture-preview-header {
    font-size: 15px;
    font-weight: 600;
    color: #1b5e20;
    text-align: center;
}

#capturePreviewCanvas {
    width: 100%;
    height: 150px;
    border-radius: 10px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    object-fit: cover;
    transform: scaleX(-1);
}

.capture-preview-note {
    font-size: 12px;
    text-align: center;
    color: #555;
}

/* Thumbnail Container */
.thumbnail-container {
    position: absolute;
    bottom: 80px;
    left: 30px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Desktop: Improved thumbnail container */
@media (min-width: 768px) {
    .thumbnail-container {
        position: static !important;
        bottom: auto !important;
        left: auto !important;
        z-index: auto !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        flex-wrap: wrap !important;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        margin-top: 2px;
    }
    
    /* Add "Last Capture" label to thumbnail container on desktop - spans full width */
    .thumbnail-container::before {
        content: "Last Capture";
        font-size: 18px;
        font-weight: 900;
        color: #13162a;
        text-align: left;
        width: 100%;
        margin-bottom: 4px;
        display: block;
        order: -1;
    }
    
    /* For REGISTER mode, change "Last Capture" to "Prior Registrations" */
    body.register-mode .thumbnail-container::before {
        content: "Prior Registrations";
    }
    
    /* Thumbnail frame only - hide status (response box) on desktop */
    .thumbnail-container .thumbnail-frame {
        flex-shrink: 0;
        width: 30px;
        height: 30px;
        order: 1;
    }
    
    .thumbnail-container .thumbnail-status {
        display: none !important; /* Hide response box on desktop - now shown in camera overlay */
    }
    
    /* Ensure buttons stay below on new line */
    .thumbnail-container .prior-registrations-btn,
    .thumbnail-container .upload-image-btn {
        order: 10;
        width: 100%;
    }
    
    .thumbnail-frame {
        width: 30px;
        height: 30px;
        flex-shrink: 0;
        border-radius: 12px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
        transition: transform 0.3s ease;
    }
    
    .thumbnail-frame:hover {
        transform: scale(1.05);
    }
    
    .thumbnail-status {
        flex: 1;
        min-width: 200px;
        max-width: 220px;
        max-height: 180px;
        min-height: auto;
        padding: 10px 12px;
        border-radius: 10px;
        font-size: 13px;
        line-height: 1.4;
        overflow-y: auto;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

.thumbnail-status {
    width: 150px;
    min-height: 60px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    gap: 4px;
}

.thumbnail-status.visible {
    display: flex;
}

.thumbnail-status.success {
    background: #d4edda;
    border: 2px solid #28a745;
    color: #155724;
}

.thumbnail-status.out {
    background: #d1ecf1;
    border: 2px solid #007bff;
    color: #004085;
}

.thumbnail-status.rejected {
    background: #f8d7da;
    border: 2px solid #dc3545;
    color: #721c24;
}

.thumbnail-status .status-icon {
    font-size: 18px;
    font-weight: bold;
    margin-right: 6px;
}

    .thumbnail-status .status-name {
        font-weight: 600;
        font-size: 15px;
        margin-bottom: 3px;
    }
    
    .thumbnail-status .status-details {
        font-size: 13px;
        opacity: 0.9;
    }
    
    .thumbnail-status .status-time {
        font-size: 12px;
        margin-top: 4px;
        opacity: 0.8;
        font-style: italic;
    }

/* Prior Registrations Button for REGISTER mode */
.prior-registrations-btn {
    width: 150px;
    padding: 12px 16px;
    background: #007bff;
    color: white;
    border: 2px solid #007bff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.prior-registrations-btn:hover {
    background: #0056b3;
    border-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.prior-registrations-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.2);
}

.prior-registrations-btn .prior-icon {
    font-size: 24px;
}

.prior-registrations-btn .prior-text {
    font-size: 13px;
}

/* Desktop: Improved prior registrations button */
@media (min-width: 768px) {
    .prior-registrations-btn {
        width: 160px;
        padding: 14px 18px;
        font-size: 15px;
        border-radius: 10px;
    }
    
    .prior-registrations-btn .prior-icon {
        font-size: 28px;
    }
    
    .prior-registrations-btn .prior-text {
        font-size: 14px;
    }
}

/* Upload Image Button for REGISTER mode */
.upload-image-btn {
    width: 150px;
    padding: 12px 16px;
    background: #00aa00;
    color: white;
    border: 2px solid #00aa00;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.upload-image-btn:hover {
    background: #008800;
    border-color: #008800;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 170, 0, 0.3);
}

.upload-image-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 170, 0, 0.2);
}

.upload-image-btn .upload-icon {
    font-size: 24px;
}

.upload-image-btn .upload-text {
    font-size: 13px;
}

/* Desktop: Improved upload button */
@media (min-width: 768px) {
    .upload-image-btn {
        width: 160px;
        padding: 14px 18px;
        font-size: 15px;
        border-radius: 10px;
    }
    
    .upload-image-btn .upload-icon {
        font-size: 28px;
    }
    
    .upload-image-btn .upload-text {
        font-size: 14px;
    }
}

.thumbnail-frame {
    width: 150px;
    height: 150px;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 2px solid #e0e0e0;
    background: #f5f5f5;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#thumbnailCanvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

#thumbnailMarkers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.checkmark {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 25px;
    height: 25px;
    background: #00ff00;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.checkmark.visible {
    display: flex;
}

/* Controls */
.controls {
    position: absolute;
    bottom: 20px;
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
}

/* Desktop: Controls in single row with improved styling */
@media (min-width: 768px) {
    .controls {
        position: absolute;
        bottom: 30px;
        display: flex;
        flex-direction: row;
        gap: 25px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .control-item {
        transition: transform 0.2s ease;
    }
    
    .control-item:hover {
        transform: translateY(-2px);
    }
    
    .action {
        padding: 10px 24px;
        font-size: 20px;
        min-width: 100px;
        transition: all 0.3s ease;
    }
    
    .action:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 170, 0, 0.3);
    }
    
    .action.active {
        box-shadow: 0 4px 16px rgba(0, 170, 0, 0.4);
    }
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: transform 0.2s;
}

.control-item:hover {
    transform: scale(1.1);
}

.key {
    color: #00aa00;
    font-size: 14px;
    font-weight: 600;
}

.action {
    color: #00aa00;
    font-size: 18px;
    font-weight: 600;
    padding: 5px 15px;
    border: 2px solid #00aa00;
    border-radius: 5px;
    background: white;
    transition: all 0.2s;
}

.action:hover {
    background: #00aa00;
    color: white;
}

.action.active {
    background: #00aa00;
    color: white;
}

/* Machine Number Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 300px;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.modal-content input:focus {
    outline: none;
    border-color: #00aa00;
}

.modal-btn {
    background: #00aa00;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-btn:hover {
    background: #008800;
}

.modal-btn-secondary {
    background: #6c757d;
    margin-left: 10px;
}

.modal-btn-secondary:hover {
    background: #5a6268;
}

.modal-buttons {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    padding-left: 15px;
    flex-wrap: wrap;
}

.modal-btn-add {
    background: #ff9800;
    color: white;
}

.modal-btn-add:hover {
    background: #e68900;
}

.modal-subtitle {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    text-align: center;
}

.cardno-status {
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 5px;
    font-weight: 600;
    text-align: center;
    display: none;
}

.cardno-status.visible {
    display: block;
}

.cardno-status.expecting {
    background: #d4edda;
    border: 2px solid #28a745;
    color: #155724;
}

.cardno-error {
    color: #dc3545;
    font-size: 14px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    display: none;
}

.cardno-error.visible {
    display: block;
}

/* Machine Form Styles */
.machine-form-container {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-group .required {
    color: #dc3545;
}

.form-group input,
.form-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
}

.form-group input[readonly] {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.form-help {
    font-size: 12px;
    color: #666;
    margin-top: 3px;
}

.existing-machines-section {
    margin-top: 20px;
    padding: 15px;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}

.existing-machines-section h3 {
    margin-bottom: 15px;
    color: #333;
}

#existingMachinesTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#existingMachinesTable thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

#existingMachinesTable th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

#existingMachinesTable td {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
}

#existingMachinesTable tbody tr {
    transition: background 0.2s;
}

#existingMachinesTable tbody tr:hover {
    background: #f1f3f5;
}

#existingMachinesTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

#existingMachinesTable tbody tr:nth-child(even):hover {
    background: #f1f3f5;
}

.existing-machines-section .table-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
}

.modal-btn-small {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-btn-small:hover {
    background: #0056b3;
}

.modal-content-large {
    min-width: 700px;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: #1e3a8a;
    color: white;
    padding: 15px;
    margin: -30px -30px 20px -30px;
    border-radius: 10px 10px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: white;
}

.search-container {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-container label {
    font-weight: 500;
    color: #333;
}

.search-container input {
    flex: 1;
    margin-bottom: 0;
}

.table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 20px;
    max-height: 400px;
}

#machineTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#machineTable thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

#machineTable th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

#machineTable td {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
}

#machineTable tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

#machineTable tbody tr:hover {
    background: #f1f3f5;
}

#machineTable tbody tr.selected {
    background: #e3f2fd;
}

#machineTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

#machineTable tbody tr:nth-child(even):hover,
#machineTable tbody tr:nth-child(even).selected {
    background: #e3f2fd;
}

/* Expand button for MACHINELIST */
.expand-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.expand-btn:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.expand-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.expand-btn.expanded {
    background: #dc3545;
}

.expand-btn.expanded:hover {
    background: #c82333;
}

.expand-btn.has-deptfilter {
    background: #28a745;
}

.expand-btn.has-deptfilter:hover {
    background: #218838;
    transform: scale(1.1);
}

.expand-btn.has-deptfilter.expanded {
    background: #dc3545;
}

.expand-btn.has-deptfilter.expanded:hover {
    background: #c82333;
}

/* MACHINELIST details row */
.machinelist-details-row {
    background: #f8f9fa !important;
}

.machinelist-details-row td {
    padding: 0 !important;
    border-top: 2px solid #dee2e6;
}

.machinelist-container {
    padding: 15px;
    background: white;
}

.machinelist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.machinelist-table thead {
    background: #e9ecef;
}

.machinelist-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    font-size: 12px;
}

.machinelist-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #e9ecef;
    color: #333;
}

.machinelist-table tbody tr:hover {
    background: #f1f3f5;
}

.machinelist-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

/* Time input fields in MACHINELIST table */
.machinelist-table .time-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    font-family: inherit;
}

.machinelist-table .time-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* MACHINELIST modal table */
#machinelistTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#machinelistTable thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

#machinelistTable th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

#machinelistTable td {
    padding: 8px 12px;
    border-bottom: 1px solid #e9ecef;
}

#machinelistTable tbody tr:hover {
    background: #f1f3f5;
}

#machinelistTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

/* Delete button in MACHINELIST table */
.delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.delete-btn:hover {
    background: #c82333;
}

.delete-btn:active {
    background: #bd2130;
}

/* Add Employee to MACHINELIST modal table */
#addEmployeeMachinelistTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#addEmployeeMachinelistTable thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

#addEmployeeMachinelistTable th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

#addEmployeeMachinelistTable td {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
}

#addEmployeeMachinelistTable tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

#addEmployeeMachinelistTable tbody tr:hover {
    background: #f1f3f5;
}

#addEmployeeMachinelistTable tbody tr.selected {
    background: #e3f2fd;
}

#addEmployeeMachinelistTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

#addEmployeeMachinelistTable tbody tr:nth-child(even):hover,
#addEmployeeMachinelistTable tbody tr:nth-child(even).selected {
    background: #e3f2fd;
}

/* Employee Table - Same styling as Machine Table */
#employeeTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#employeeTable thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

#employeeTable th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

#employeeTable td {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
}

#employeeTable tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

#employeeTable tbody tr:hover {
    background: #f1f3f5;
}

#employeeTable tbody tr.selected {
    background: #e3f2fd;
    font-weight: 600;
}

#employeeTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

#employeeTable tbody tr:nth-child(even):hover,
#employeeTable tbody tr:nth-child(even).selected {
    background: #e3f2fd;
}

#employeeTable .loading,
#employeeTable .error {
    text-align: center;
    padding: 20px;
    color: #666;
}

#employeeTable .error {
    color: #e74c3c;
}

/* Results Panel */
.results-panel {
    position: fixed;
    top: 40px;
    right: 20px;
    width: clamp(320px, 25vw, 400px);
    max-height: calc(100vh - 100px);
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none !important;
    overflow: hidden;
}

.results-panel.visible {
    display: flex !important;
    flex-direction: column;
}

.results-header {
    background: #2c3e50;
    color: white;
    padding: 12px;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
    text-align: center;
}

.results-content {
    padding: 15px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.no-results {
    text-align: center;
    color: #999;
    padding: 20px;
}

.result-item {
    padding: 12px;
    margin-bottom: 10px;
    background: #f5f5f5;
    border-radius: 5px;
    border-left: 4px solid #00aa00;
}

.result-item.success {
    border-left-color: #00aa00;
}

.result-item.rejected {
    border-left-color: #e74c3c;
}

.result-item.warning {
    border-left-color: #f39c12;
}

.result-item .result-title {
    font-weight: 600;
    margin-bottom: 5px;
    color: #2c3e50;
}

.result-item .result-detail {
    font-size: 13px;
    color: #666;
    margin: 2px 0;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.result-item .result-detail:first-of-type {
    margin-top: 8px;
}

.result-item.success .result-detail {
    color: #2c3e50;
}

.result-item.rejected .result-detail {
    color: #c0392b;
}

.result-item.warning .result-detail {
    color: #d68910;
}

.result-item .result-time {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

/* Responsive adjustments */
@media (max-width: 1280px) {
    body {
        align-items: flex-start;
    }
    .app-container {
        min-height: 100vh;
    }
    .status-indicators {
        padding: 0 16px;
    }
    .capture-preview-container {
        left: clamp(10px, 8vw, 220px);
        right: auto;
    }
}

/* Tablet and Mobile - Single Column Layout */
@media (max-width: 1024px) {
    .results-panel {
        position: static !important;
        right: auto !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 20px auto 0 auto !important;
    }
    .main-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    .capture-preview-container {
        position: static !important;
        right: auto !important;
        top: auto !important;
    }
    .thumbnail-container {
        position: static !important;
        left: auto !important;
        bottom: auto !important;
    }
}

@media (max-width: 1024px) {
    body {
        padding: 0;
        overflow-y: auto;
        height: 100vh;
    }
    .app-container {
        min-height: 100vh;
        height: 100vh;
        display: flex;
        flex-direction: column;
        overflow: visible;
    }
    .main-content {
        padding: 5px 4px;
        padding-top: 45px;
        overflow-y: auto;
        overflow-x: hidden;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        justify-content: flex-start;
        min-height: 0;
        max-height: calc(100vh - 40px);
        box-sizing: border-box;
    }
    .results-header {
        display: none !important;
    }
    .status-indicators {
        position: static;
        justify-content: center;
        margin-bottom: 4px;
        gap: 4px;
        flex-wrap: wrap;
        padding: 0 4px;
    }
    .status-item {
        font-size: 11px;
        padding: 3px 6px;
    }
    /* Only apply these video-container styles if NOT on mobile (767px) */
    @media (min-width: 768px) {
        .video-container {
            width: min(45vw, 220px);
            height: min(45vw, 220px);
            margin-bottom: 5px;
        }
    }
    .capture-preview-container {
        position: static !important;
        width: 150px;
        margin: 0 auto 5px auto;
        padding: 5px;
        right: auto;
        top: auto;
    }
    .capture-preview-header {
        font-size: 11px;
    }
    #capturePreviewCanvas {
        height: 80px;
    }
    .capture-preview-note {
        font-size: 9px;
    }
    .thumbnail-container {
        position: static !important;
        flex-direction: column;
        align-items: center;
        margin: 0 auto 5px auto;
        gap: 3px;
        left: auto;
        bottom: auto;
    }
    .thumbnail-frame {
        width: 70px;
        height: 70px;
    }
    .thumbnail-status {
        width: 100px;
        font-size: 10px;
        padding: 4px 6px;
    }
    .controls {
        position: static;
        margin-top: 5px;
        margin-bottom: 5px;
        gap: 10px;
    }
    .control-item {
        gap: 2px;
    }
    .key {
        font-size: 10px;
    }
    .action {
        font-size: 12px;
        padding: 3px 10px;
    }
    .results-panel {
        display: none !important;
    }
    .results-header {
        display: none !important;
    }
    .results-content {
        max-height: calc(100vh - 330px);
        padding: 6px;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .result-item {
        display: none !important;
    }
    .result-item .result-title {
        font-size: 12px;
        margin-bottom: 3px;
    }
    .result-item .result-detail {
        font-size: 10px;
    }
    .expecting-person {
        position: static;
        transform: none;
        margin: 4px auto;
        padding: 5px 12px;
        font-size: 12px;
    }
}

/* Mobile Layout (max-width: 767px) - Optimized Layout */
@media (max-width: 767px) {
    /* Hide redundant header pills (Mode, Type, Machine ID) in mobile */
    .title-center,
    #headerMachinePill {
        display: none !important;
    }
    
    /* Ensure camera status chip is visible in mobile - positioned at top to avoid being hidden */
    .camera-glass-overlay {
        display: flex !important;
        position: absolute !important;
        left: 14px !important;
        right: 14px !important;
        top: 14px !important;
        bottom: auto !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 10px !important;
        pointer-events: none !important;
        z-index: 18 !important;
    }
    
    .camera-status-chip,
    .camera-live-chip {
        display: inline-flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 10px 12px !important;
        border-radius: 999px !important;
        background: rgba(20, 23, 39, 0.35) !important;
        border: 1px solid rgba(255, 255, 255, 0.18) !important;
        color: rgba(255, 255, 255, 0.98) !important;
        font-weight: 800 !important;
        letter-spacing: 0.2px !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18) !important;
    }
    
    .camera-status-chip {
        background: rgba(239, 68, 68, 0.38) !important;
    }
    
    .camera-status-chip.detected {
        background: rgba(34, 197, 94, 0.38) !important;
    }
    
    .camera-live-chip {
        background: rgba(20, 23, 39, 0.35) !important;
    }
    
    html, body {
        overflow-x: hidden !important;
        overflow-y: hidden !important;
        height: 100vh;
        width: 100vw;
        max-width: 100vw;
        position: fixed;
    }
    
    .app-container {
        min-height: 100vh;
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        width: 100vw;
        max-width: 100vw;
        margin: 0;
        padding: 0;
        box-shadow: none;
        position: relative;
    }
    
    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
        padding: 0;
        padding-top: 40px;
        position: relative;
        width: 100vw;
        max-width: 100vw;
        margin: 0;
        left: 0;
        right: 0;
        align-items: stretch !important;
        box-sizing: border-box;
    }
    
    /* Status indicators - compact at top */
    .status-indicators {
        position: absolute;
        top: 2px;
        left: 0;
        right: 0;
        z-index: 100;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 3px;
        padding: 2px 4px;
        pointer-events: none;
    }
    
    .status-item {
        font-size: 9px;
        padding: 2px 5px;
    }
    
    /* Ensure liveness item stays on same line in mobile */
    .status-item.liveness-item {
        flex-shrink: 0;
        white-space: nowrap;
        min-width: fit-content;
    }
    
    /* Expecting person - keep at top */
    .expecting-person {
        position: absolute;
        top: 30px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 100;
        margin: 0;
        padding: 4px 10px;
        font-size: 10px;
    }
    
    /* Camera Section: Extended upwards to cover space left by Live Capture */
    .video-container {
        flex: 0 0 75% !important; /* Extended from 69% to 75% to cover top space */
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        min-height: 0;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
        position: relative;
        box-sizing: border-box;
        overflow: hidden;
        left: 0 !important;
        right: 0 !important;
        align-items: stretch !important;
        justify-content: stretch !important;
    }
    
    /* Remove circular frame on mobile - make it full width corner to corner */
    .video-container .circular-frame {
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        max-height: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        box-shadow: none !important;
        display: block;
        overflow: hidden;
        background: #f5f5f5; /* Light background - never dark */
        position: relative;
    }
    
    .video-container #videoElement {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border-radius: 0 !important;
        background: #f5f5f5; /* Light background - never dark */
        display: block;
        position: absolute;
        top: 0;
        left: 0;
    }
    
    .video-container #canvasElement {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        position: absolute;
        top: 0;
        left: 0;
    }
    
    /* Live Capture - floating overlay INSIDE camera area, bottom right, above green/yellow response band */
    /* Position it fixed at bottom-right INSIDE the video-container, well above the result-overlay (response band) */
    /* Video-container is 75% of viewport, response band is at bottom of video-container */
    /* Position it above the response band: bottom = space below video (25vh) + response band height (~100px) + extra margin (~80px) */
    .capture-preview-container {
        position: fixed !important;
        top: auto !important;
        left: auto !important;
        bottom: calc(25vh + 200px) !important; /* Position well above response band: 25vh (space below video) + ~100px (band height) + ~100px (margin above band) */
        right: 12px !important;
        width: 140px !important;
        padding: 8px !important;
        margin: 0 !important;
        border-radius: 8px;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        background: rgba(255, 255, 255, 0.95) !important;
        border: 2px solid #00aa00 !important;
        box-sizing: border-box;
        z-index: 25 !important; /* Below result-overlay (z-index 20) but above video */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        transform: none !important;
    }
    
    /* Hide live capture after result is shown */
    .capture-preview-container.hidden-after-result {
        display: none !important;
    }
    
    /* Hide header and note text in mobile view */
    .capture-preview-header {
        display: none !important;
    }
    
    /* Make canvas larger to fill the whitespace */
    #capturePreviewCanvas {
        width: 100%;
        height: 140px !important; /* Increased from 90px to use whitespace */
        border-radius: 6px;
        background: #f5f5f5;
        border: 1px solid #e0e0e0;
    }
    
    /* Hide note text in mobile view */
    .capture-preview-note {
        display: none !important;
    }
    
    /* Hide thumbnail container on mobile - we show results in overlay */
    .thumbnail-container {
        display: none !important;
    }
    
    /* Result Overlay - shown on camera bottom */
    .result-overlay {
        display: block;
        padding: 14px 10px 10px 10px;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7), transparent);
        transition: background 0.3s ease;
    }
    
    /* Success cases (green) - IN and other successful statuses */
    .result-overlay.success {
        background: linear-gradient(to top, rgba(0, 170, 0, 0.85), rgba(0, 170, 0, 0.65), transparent);
    }
    
    /* OUT cases (blue) */
    .result-overlay.out {
        background: linear-gradient(to top, rgba(0, 123, 255, 0.85), rgba(0, 123, 255, 0.65), transparent);
    }
    
    /* Rejected/Failed cases (red) */
    .result-overlay.rejected {
        background: linear-gradient(to top, rgba(231, 76, 60, 0.85), rgba(231, 76, 60, 0.65), transparent);
    }
    
    /* Last person details (yellow) - shown after results hide */
    .result-overlay.last-person {
        background: linear-gradient(to top, rgba(255, 193, 7, 0.85), rgba(255, 193, 7, 0.65), transparent);
    }
    
    .result-overlay-content {
        font-size: 13px;
        line-height: 1.4;
    }
    
    .result-overlay-content .result-name {
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 6px;
    }
    
    .result-overlay-content .result-name .result-icon {
        font-size: 20px;
        margin-right: 6px;
    }
    
    .result-overlay-content .result-details {
        font-size: 12px;
        gap: 8px;
        margin-top: 4px;
        flex-wrap: wrap;
    }
    
    .result-overlay-content .result-detail-item {
        font-size: 12px;
        white-space: nowrap;
    }
    
    .result-overlay-content .result-time {
        font-size: 11px;
        margin-top: 6px;
        opacity: 0.9;
    }
    
    /* Buttons Section: Larger buttons to fill remaining space - no vacant area */
    .controls {
        flex: 1 1 31% !important; /* Use flex: 1 to fill all available space */
        position: static;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        gap: clamp(12px, 3.5vw, 16px);
        width: 100%;
        margin: 0;
        padding: clamp(16px, 5vw, 24px);
        padding-bottom: max(clamp(16px, 5vw, 24px), env(safe-area-inset-bottom));
        background: #f8f9fa;
        border-top: 2px solid #e0e0e0;
        box-sizing: border-box;
        min-height: 0;
        align-content: stretch;
    }
    
    .control-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: clamp(6px, 1.5vw, 8px);
        min-width: 0;
        padding: 0;
        height: 100%;
    }
    
    .key {
        font-size: 11px;
        color: #666;
        font-weight: 500;
    }
    
    .action {
        font-size: clamp(18px, 5vw, 24px);
        font-weight: 700;
        padding: clamp(14px, 4vw, 20px) clamp(18px, 5vw, 24px);
        width: 100%;
        max-width: none;
        text-align: center;
        border: none;
        border-radius: 12px;
        color: white;
        transition: all 0.2s ease;
        min-height: clamp(56px, 16vw, 70px);
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    
    /* Mobile button colors matching desktop */
    .action-manual {
        background: #6A5AE0 !important;
    }
    
    .action-auto {
        background: #3B82F6 !important;
    }
    
    .action-capture {
        background: #22C55E !important;
    }
    
    .action-stop {
        background: #EF4444 !important;
    }
    
    .action:hover,
    .action:active {
        transform: scale(0.97);
        filter: brightness(1.1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .action.active {
        filter: brightness(1.15);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    }
    
    /* Reorder buttons in mobile view: Manual, Capture, Auto, Stop */
    .control-item:nth-child(1) {
        order: 1; /* Manual */
    }
    
    .control-item:nth-child(2) {
        order: 3; /* Auto - moved to bottom-left */
    }
    
    .control-item:nth-child(3) {
        order: 2; /* Capture - moved to top-right */
    }
    
    .control-item:nth-child(4) {
        order: 4; /* Stop */
    }
    
    /* Hide results panel on mobile */
    .results-panel {
        display: none !important;
    }
    
    .results-header {
        display: none !important;
    }
    
    .result-item {
        display: none !important;
    }
}

/* Keep existing 768px+ styles for desktop (unchanged) */
@media (min-width: 768px) {
    /* Desktop layout remains exactly as before - no changes */
}

@media (max-width: 576px) {
    body {
        overflow-y: auto;
        height: 100vh;
    }
    .app-container {
        border-radius: 0;
        box-shadow: none;
        min-height: 100vh;
        height: 100vh;
        overflow: visible;
    }
    .title-bar {
        flex-direction: row;
        height: 32px;
        gap: 3px;
        padding: 5px 8px;
    }
    .title-text {
        font-size: 11px;
    }
    .main-content {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        padding: 3px 0;
        padding-top: 35px;
        overflow-y: auto;
        overflow-x: hidden;
        flex: 1;
        min-height: 0;
        max-height: calc(100vh - 32px);
        box-sizing: border-box;
    }
    .results-header {
        display: none !important;
    }
    .status-indicators {
        gap: 2px;
        margin-bottom: 3px;
        padding: 0 2px;
    }
    .status-item {
        font-size: 9px;
        padding: 2px 4px;
    }
    .video-container {
        width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .capture-preview-container {
        position: static !important;
        width: 120px;
        max-width: 90%;
        margin: 0 auto 3px auto;
        padding: 3px;
    }
    /* Hide header and note text in mobile view */
    .capture-preview-header {
        display: none !important;
    }
    /* Make canvas larger to fill the whitespace */
    #capturePreviewCanvas {
        height: 140px !important; /* Increased to use whitespace */
    }
    /* Hide note text in mobile view */
    .capture-preview-note {
        display: none !important;
    }
    .thumbnail-container {
        position: static !important;
        flex-direction: column;
        align-items: center;
        margin: 0 auto 3px auto;
        gap: 2px;
    }
    .thumbnail-frame {
        width: 50px;
        height: 50px;
    }
    .thumbnail-status {
        width: 80px;
        font-size: 8px;
        padding: 2px 4px;
    }
    
    /* Override: Live Capture positioned bottom-right INSIDE video-container, above green band for mobile */
    .capture-preview-container {
        position: fixed !important;
        bottom: calc(25vh + 200px) !important; /* Position well above response band */
        right: 12px !important;
        top: auto !important;
        left: auto !important;
        width: 140px !important;
        margin: 0 !important;
        padding: 8px !important;
        z-index: 25 !important;
        transform: none !important;
    }
    
    .results-panel {
        display: none !important;
    }
    .results-header {
        display: none !important;
    }
    .results-content {
        max-height: calc(100vh - 240px);
        padding: 4px;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .result-item {
        display: none !important;
    }
    .result-item .result-title {
        font-size: 10px;
        margin-bottom: 2px;
    }
    .result-item .result-detail {
        font-size: 8px;
    }
    .controls {
        position: static;
        flex-wrap: wrap;
        gap: 6px;
        margin: 3px auto;
    }
    .control-item {
        gap: 1px;
    }
    .key {
        font-size: 8px;
    }
    .action {
        font-size: 14px;
        padding: 2px 6px;
    }
    .expecting-person {
        position: static;
        transform: none;
        margin: 2px auto;
        padding: 3px 8px;
        font-size: 10px;
    }
}

/* Registration Modal Styles */
/* Employee row styling is handled by #employeeTable styles above */

.registration-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 5px;
}

.prior-registrations-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 5px;
}

.reg-info-item {
    display: flex;
    gap: 10px;
    font-size: 16px;
}

.reg-info-item strong {
    min-width: 80px;
}

.prior-images-section {
    margin-bottom: 20px;
}

.prior-images-section h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.prior-images-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 5px;
}

.prior-image-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.prior-image-item img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid #ddd;
}

.image-label {
    font-size: 12px;
    color: #666;
}

.delete-image-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #ff4444;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s, transform 0.2s;
}

.delete-image-btn:hover {
    background-color: #cc0000;
    transform: scale(1.1);
}

.delete-image-btn:active {
    transform: scale(0.95);
}

.current-capture-section {
    margin-bottom: 20px;
}

.current-capture-section h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.capture-options {
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.option-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.option-tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

.option-tab:hover {
    background: #e9ecef;
    color: #333;
}

.option-tab.active {
    background: white;
    color: #2c3e50;
    border-bottom-color: #2c3e50;
    font-weight: 600;
}

.option-content {
    padding: 15px;
    background: white;
}

.option-content.hidden {
    display: none;
}

.current-capture-image {
    display: flex;
    justify-content: center;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 5px;
}

.current-capture-image img {
    max-width: 300px;
    max-height: 300px;
    border-radius: 5px;
    border: 2px solid #ddd;
}

.upload-section {
    text-align: center;
}

.upload-section .modal-btn {
    margin-bottom: 15px;
}

.upload-button-section {
    margin-top: 15px;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    background: #f9f9f9;
    border-radius: 5px;
}

.upload-button-section p {
    margin: 10px 0;
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.upload-button-section .modal-btn {
    margin-top: 10px;
    min-width: 200px;
    font-size: 16px;
    padding: 12px 24px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}

.upload-button-section .modal-btn:hover {
    background: #218838;
}

.upload-preview {
    margin-top: 15px;
    text-align: center;
}

.upload-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 5px;
    border: 2px solid #ddd;
}

.upload-section {
    margin-bottom: 20px;
}

.upload-preview {
    margin-top: 10px;
    text-align: center;
}

.employee-details-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.employee-details-section label {
    font-weight: 600;
    margin-bottom: 5px;
}

.employee-details-section input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.modal-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.loading, .error, .no-images {
    text-align: center;
    padding: 20px;
    color: #666;
}

.error {
    color: #e74c3c;
}

/* Mobile responsive styles for registration modals */
@media (max-width: 767px) {
    .registration-info {
        padding: 10px;
        gap: 8px;
    }
    
    .reg-info-item {
        font-size: 14px;
    }
    
    .reg-info-item strong {
        min-width: 60px;
    }
    
    .prior-images-container {
        max-height: 200px;
        gap: 10px;
    }
    
    .prior-image-item img {
        width: 80px;
        height: 80px;
    }
    
    .current-capture-image img {
        max-width: 100%;
        max-height: 250px;
    }
    
    .employee-details-section input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .modal-content-large {
        min-width: auto;
        max-width: 95vw;
        width: 95vw;
        max-height: 90vh;
        overflow-y: auto;
        padding: 15px;
    }
    
    /* Machine selection modal - mobile optimizations */
    #machineModal .modal-content-large {
        display: flex;
        flex-direction: column;
        height: auto;
        max-height: 85vh;
    }
    
    /* Table container - allow scrolling on mobile */
    #machineModal .table-container {
        max-height: 60vh;
        overflow-y: auto;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        position: relative;
    }
    
    /* Ensure table can scroll horizontally if needed */
    #machineTable {
        min-width: 100%;
        width: max-content;
        table-layout: auto;
    }
    
    /* Optimize column widths for mobile */
    #machineTable th:first-child,
    #machineTable td:first-child {
        min-width: 50px;
        max-width: 60px;
    }
    
    #machineTable th:nth-child(2),
    #machineTable td:nth-child(2) {
        min-width: 100px;
    }
    
    #machineTable th:nth-child(3),
    #machineTable td:nth-child(3) {
        min-width: 120px;
    }
    
    #machineTable th:nth-child(4),
    #machineTable td:nth-child(4) {
        min-width: 90px;
    }
    
    #machineTable th:nth-child(5),
    #machineTable td:nth-child(5) {
        min-width: 80px;
    }
    
    /* Make sure the + button column is always visible and sticky */
    #machineTable th:last-child,
    #machineTable td:last-child {
        position: sticky;
        right: 0;
        background: white;
        z-index: 5;
        padding: 8px 10px;
        min-width: 60px;
        width: 60px;
        text-align: center;
    }
    
    #machineTable thead th:last-child {
        background: #f8f9fa;
        z-index: 15;
    }
    
    #machineTable tbody tr.selected td:last-child {
        background: #e3f2fd;
    }
    
    #machineTable tbody tr:nth-child(even) td:last-child {
        background: #f8f9fa;
    }
    
    #machineTable tbody tr:nth-child(even).selected td:last-child {
        background: #e3f2fd;
    }
    
    #machineTable th,
    #machineTable td {
        padding: 8px 6px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    /* Adjust expand button size for mobile */
    .expand-btn {
        width: 32px;
        height: 32px;
        font-size: 20px;
        flex-shrink: 0;
    }
    
    .search-container {
        flex-wrap: wrap;
    }
    
    .search-container input {
        min-width: 0;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .modal-buttons {
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 10px;
    }
    
    .modal-buttons button {
        flex: 1;
        min-width: 120px;
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .modal-buttons {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .modal-buttons button {
        min-width: 100px;
    }
}



