@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #f8f9fa;
    --bg-surface: #ffffff;
    --border-color: #dadce0;
    --primary: #1a73e8; /* Google Blue */
    --primary-hover: #1557b0;
    --primary-light: rgba(26, 115, 232, 0.08);
    --accent-red: #ea4335;   /* Google Red */
    --accent-green: #34a853; /* Google Green */
    --accent-yellow: #fbbc05;/* Google Yellow */
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --shadow-main: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
    --shadow-hover: 0 2px 6px 0 rgba(60, 64, 67, 0.3), 0 8px 12px 6px rgba(60, 64, 67, 0.15);
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Header */
header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.1), 0 2px 6px 2px rgba(60,64,67,0.05);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(26, 115, 232, 0.3);
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.logo-text {
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.logo-accent {
    color: var(--primary);
    font-weight: 700;
}

/* Navigation Header */
.header-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.6rem 1.25rem;
    border-radius: 100px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: var(--transition);
}

.nav-link:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* Stats */
.stats-container {
    display: flex;
    gap: 1rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.6rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 110px;
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.05);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 390px;
    gap: 2rem;
    padding: 2rem;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.dashboard-full-width {
    grid-template-columns: 1fr !important;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.glass-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 24px; /* Large friendly Nest roundings */
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.1), 0 1px 3px 1px rgba(60,64,67,0.05);
    overflow: hidden;
    padding: 1.5rem;
    transition: var(--transition);
}

.glass-card:hover {
    box-shadow: 0 1px 3px 0 rgba(60,64,67,0.2), 0 4px 8px 3px rgba(60,64,67,0.1);
}

/* Streams section */
.streams-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title {
    font-size: 1.35rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
}

.streams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.camera-player-card {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #e8eaed;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.1), 0 2px 6px 2px rgba(60,64,67,0.05);
    transition: var(--transition);
}

.camera-player-card:hover {
    box-shadow: var(--shadow-main);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.stream-video {
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
}

.stream-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    pointer-events: none;
    z-index: 10;
}

.camera-badge {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 0.4rem 0.8rem;
    border-radius: 100px; /* Rounded pill badge */
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid rgba(0,0,0,0.06);
    color: var(--text-primary);
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    display: inline-block;
}

.status-dot.active {
    background: var(--accent-green);
}

.status-dot.monitoring {
    background: var(--primary);
}

.status-dot.recording {
    background: var(--accent-red);
}

.status-dot.motion.recording {
    animation: pulse-red 1.5s infinite;
}

.status-dot.motion.monitoring {
    animation: pulse-blue 1.5s infinite;
}

@keyframes pulse-red {
    0% { transform: scale(0.95); opacity: 0.6; box-shadow: 0 0 0 0 rgba(234, 67, 53, 0.7); }
    70% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 0 6px rgba(234, 67, 53, 0); }
    100% { transform: scale(0.95); opacity: 0.6; box-shadow: 0 0 0 0 rgba(234, 67, 53, 0); }
}

@keyframes pulse-blue {
    0% { transform: scale(0.95); opacity: 0.6; box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.7); }
    70% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 0 6px rgba(26, 115, 232, 0); }
    100% { transform: scale(0.95); opacity: 0.6; box-shadow: 0 0 0 0 rgba(26, 115, 232, 0); }
}


.stream-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.stream-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    padding: 0.4rem 0.8rem;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: var(--transition);
}

.stream-btn:hover {
    background: var(--bg-surface);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-widget {
    padding: 1.5rem;
}

.widget-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    background: var(--bg-surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 100px; /* Google Pill Button */
    padding: 0.8rem 1.5rem;
    font-weight: 500;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
}

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--primary);
}

.btn-secondary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* Camera items in Active Feeds */
.camera-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.camera-item {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.camera-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.camera-item-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.camera-item-mode {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.05);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.camera-item-url {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.camera-item-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Material Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #bdc1c6;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.delete-btn:hover {
    background: rgba(234, 67, 53, 0.1);
    color: var(--accent-red);
}

/* Recordings section */
.recordings-section {
    padding: 0 2rem 3rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.recordings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.recording-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(60,64,67,0.05);
}

.recording-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 1px 3px 0 rgba(60,64,67,0.15), 0 3px 6px 1px rgba(60,64,67,0.1);
    border-color: var(--primary);
}

.recording-thumb {
    aspect-ratio: 16/9;
    background: #e8eaed;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.recording-thumb::after {
    content: "";
    width: 44px;
    height: 44px;
    background: rgba(26, 115, 232, 0.9);
    border-radius: 50%;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.recording-card:hover .recording-thumb::after {
    opacity: 1;
}

.recording-thumb svg {
    width: 28px;
    height: 28px;
    fill: var(--text-secondary);
    z-index: 1;
}

.recording-card:hover .recording-thumb svg {
    fill: white;
}

.recording-info {
    font-size: 0.8rem;
}

.recording-time {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.recording-details {
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

/* Playback Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(32, 33, 36, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    width: 90%;
    max-width: 850px;
    overflow: hidden;
    box-shadow: var(--shadow-main);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 500;
}

.close-modal-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: var(--transition);
}

.close-modal-btn:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.modal-body {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
}

.modal-body video {
    width: 100%;
    height: 100%;
}

/* Console Logs Log widget */
.log-console {
    background: #202124;
    border-radius: 12px;
    height: 140px;
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    padding: 0.8rem;
    color: #a8dab5;
    overflow-y: auto;
    white-space: pre-wrap;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

/* Google Nest Timeline Playback CSS */
.timeline-container-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    height: 480px;
}

@media (max-width: 900px) {
    .timeline-container-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .timeline-video-screen {
        aspect-ratio: 16/9;
        height: auto;
        min-height: 240px;
    }
    .timeline-scrubber-wrapper {
        height: 320px;
    }
}

.timeline-video-screen {
    position: relative;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-video-viewport {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
    will-change: transform;
}

.timeline-video-screen video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.timeline-video-screen img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 2;
}

.timeline-video-screen iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 3;
    pointer-events: none;
}

.timeline-video-time-overlay {
    display: none;
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(32, 33, 36, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 1rem;
    border-radius: 100px;
    border: 1px solid rgba(255,255,255,0.1);
    pointer-events: none;
    z-index: 10;
}

.timeline-scrubber-wrapper {
    position: relative;
    height: 100%;
    border-radius: 20px;
    background: #f1f3f4;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.timeline-center-playhead {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    z-index: 100;
    pointer-events: none;
}

.playhead-line {
    height: 2px;
    background: var(--accent-red);
    width: 100%;
    box-shadow: 0 0 4px rgba(234, 67, 53, 0.5);
}

.playhead-time-badge {
    position: absolute;
    left: 50%;
    top: -28px;
    transform: translateX(-50%);
    background: var(--accent-red);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    white-space: nowrap;
}

/* History Mode color toggles (turns playhead marker blue) */
.timeline-center-playhead.history-mode .playhead-line {
    background: var(--primary) !important;
    box-shadow: 0 0 4px rgba(26, 115, 232, 0.5) !important;
}

.timeline-center-playhead.history-mode .playhead-time-badge {
    background: var(--primary) !important;
}

.timeline-scroll-track {
    height: 100%;
    overflow-y: scroll;
    position: relative;
    padding: 240px 0; /* half of 480px wrapper height so 0:00/23:59 can center */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

body.grabbing, body.grabbing * {
    cursor: grabbing !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.timeline-ruler {
    position: relative;
    width: 100%;
}

.timeline-hour-mark {
    position: absolute;
    left: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: calc(100% - 1.5rem);
    pointer-events: none;
}

.timeline-hour-line {
    flex-grow: 1;
    height: 1px;
    background: #dadce0;
}

.timeline-highlight-bar {
    position: absolute;
    left: 80px;
    right: 1.25rem;
    background: rgba(26, 115, 232, 0.15);
    border-left: 4px solid var(--primary);
    border-radius: 4px;
    cursor: default;
    pointer-events: none;
    transition: var(--transition);
    z-index: 5;
}

.timeline-highlight-bar.motion-mode {
    background: rgba(234, 67, 53, 0.15);
    border-left-color: var(--accent-red);
}

/* Mobile Responsiveness Overrides */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1.25rem;
        align-items: stretch;
        padding: 1rem;
    }
    .logo-container {
        justify-content: center;
    }
    .header-nav {
        justify-content: center;
        flex-wrap: wrap;
        margin-top: 0.25rem;
        margin-bottom: 0.25rem;
    }
    .stats-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .stat-card {
        min-width: 0;
        padding: 0.5rem 0.75rem;
        align-items: center;
        text-align: center;
    }
    .stat-label {
        font-size: 0.7rem;
    }
    .stat-value {
        font-size: 0.95rem;
    }
}

@media (max-width: 500px) {
    .streams-grid {
        grid-template-columns: 1fr;
    }
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    .section-header div {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }
    .section-header select, 
    .section-header button {
        flex-grow: 1;
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }
}

/* Timeline Custom Controls Overlay */
.timeline-custom-controls {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(32, 33, 36, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.6rem;
    border-radius: 100px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: opacity 0.2s ease-in-out;
}

.timeline-custom-controls.hidden-controls {
    opacity: 0;
    pointer-events: none;
}

.timeline-custom-controls .ctrl-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease-in-out, transform 0.1s;
}

.timeline-custom-controls .ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.timeline-custom-controls .ctrl-btn:active {
    transform: scale(0.95);
}

.timeline-custom-controls .play-pause-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--primary);
    box-shadow: 0 2px 4px rgba(26, 115, 232, 0.3);
}

.timeline-custom-controls .play-pause-btn:hover {
    background: #1557b0;
}

.timeline-custom-controls .ctrl-btn svg {
    width: 14px;
    height: 14px;
    fill: #ffffff;
}

/* Bottom Navigation Bar for Mobile */
.bottom-nav {
    display: none; /* Hidden on desktop */
}

/* Mobile Compatibility Enhancements */
@media (max-width: 768px) {
    body {
        padding-bottom: 74px; /* Space for bottom nav */
    }

    header {
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem !important;
        gap: 1rem;
    }

    .logo-container {
        justify-content: flex-start !important;
    }

    .logo-text {
        font-size: 1.15rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .logo-icon svg {
        width: 18px;
        height: 18px;
    }

    .header-nav {
        display: none !important; /* Hide top nav links on mobile */
    }

    /* Edge-to-edge scrollable stats on mobile */
    .stats-container {
        display: flex !important;
        grid-template-columns: none !important;
        gap: 0.5rem !important;
        overflow-x: auto;
        white-space: nowrap;
        max-width: 60%;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .stats-container::-webkit-scrollbar {
        display: none;
    }

    .stat-card {
        flex: 0 0 auto;
        min-width: 85px !important;
        padding: 0.4rem 0.6rem !important;
        align-items: center;
        text-align: center;
        border-radius: 8px;
    }

    .stat-label {
        font-size: 0.65rem;
        margin-bottom: 0;
    }

    .stat-value {
        font-size: 0.85rem;
    }

    /* Reduce paddings for grids on mobile to fit the screen */
    .dashboard-grid {
        padding: 0.75rem !important;
        gap: 1rem !important;
    }

    .recordings-section {
        padding: 0 0.75rem 2rem 0.75rem !important;
    }

    /* Mobile layout for monitors grid */
    .streams-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Bottom Nav design */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: var(--bg-surface);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .bottom-nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 0.75rem;
        font-weight: 500;
        gap: 0.2rem;
        flex: 1;
        height: 100%;
        transition: var(--transition);
    }

    .bottom-nav-link svg {
        width: 22px;
        height: 22px;
        fill: currentColor;
        transition: var(--transition);
    }

    .bottom-nav-link.active {
        color: var(--primary);
        font-weight: 600;
    }

    .bottom-nav-link:active {
        transform: scale(0.95);
    }
}

/* Extra small mobile adjustments */
@media (max-width: 480px) {
    /* Event history compact view */
    .recordings-grid {
        grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)) !important;
        gap: 0.75rem !important;
        margin-top: 1rem !important;
    }

    .recording-card {
        padding: 0.5rem !important;
        border-radius: 12px !important;
    }

    .recording-thumb {
        border-radius: 8px !important;
        margin-bottom: 0.4rem !important;
    }

    .recording-time {
        font-size: 0.75rem !important;
    }

    .recording-details {
        font-size: 0.68rem !important;
    }

    /* Camera items inside manager */
    .camera-item {
        padding: 0.75rem !important;
        border-radius: 12px !important;
    }

    .camera-item-name {
        font-size: 0.85rem !important;
    }

    .camera-item-url {
        max-width: 140px !important;
    }
}

/* Fix timeline select header on mobile */
@media (max-width: 500px) {
    .timeline-portal-card .section-header div {
        flex-wrap: nowrap !important;
    }
    .timeline-portal-card .section-header select {
        width: auto !important;
        flex-grow: 1 !important;
    }
    .timeline-portal-card .section-header button {
        width: 44px !important;
        flex-grow: 0 !important;
    }
}

/* Click overlay for camera streams */
.camera-click-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    cursor: pointer;
}

/* Fixed Viewport Timeline Page for Fullscreen Desktop & Mobile Feeling */
body.page-timeline {
    height: 100vh;
    height: -webkit-fill-available;
    overflow: hidden;
}

body.page-timeline main.recordings-section {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    overflow: hidden;
    min-height: 0;
    height: calc(100vh - 81px); /* header is ~81px */
}

body.page-timeline .timeline-portal-card {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0 !important;
    padding: 1.5rem !important;
    overflow: hidden;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    min-height: 0;
}

body.page-timeline .timeline-portal-card > .section-header {
    flex: 0 0 auto;
}

body.page-timeline .timeline-container-layout {
    flex: 1 1 0;
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: 1fr;  /* single row constrained to available height */
    height: 100%;
    min-height: 0;
    overflow: hidden;
    gap: 1.5rem;
}

body.page-timeline .timeline-video-screen {
    min-height: 0;
    overflow: hidden;
    height: 100%;
}

body.page-timeline .timeline-scrubber-wrapper {
    min-height: 0;
    overflow: hidden;
    height: 100%;
}

/* Mobile info bar - hidden on desktop */
.timeline-mobile-info-bar {
    display: none;
}

@media (max-width: 768px) {
    /* Hide the page header and section header on the timeline page for mobile */
    body.page-timeline {
        padding-bottom: 0 !important; /* override generic mobile padding */
    }

    body.page-timeline > header {
        display: none !important;
    }

    body.page-timeline main.recordings-section {
        padding: 0 !important;
        height: calc(100vh - 64px - env(safe-area-inset-bottom)); /* full viewport minus bottom nav */
    }

    body.page-timeline .timeline-portal-card {
        padding: 0 !important;
        border-radius: 0 !important;
    }

    body.page-timeline .timeline-portal-card > .section-header {
        display: none !important;
    }

    body.page-timeline .timeline-container-layout {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    /* Video: edge-to-edge at the top */
    body.page-timeline .timeline-video-screen {
        flex: 0 0 auto;
        height: auto;
        aspect-ratio: 16 / 9;
        min-height: 0;
        max-height: 45vh;
        border-radius: 0;
    }

    /* Mobile info bar: visible between video and timeline */
    body.page-timeline .timeline-mobile-info-bar {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: space-between;
        padding: 0.6rem 1rem;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-color);
        gap: 0.75rem;
    }

    .timeline-mobile-info-left {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
        min-width: 0;
        flex: 1;
    }

    .timeline-mobile-cam-name {
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .timeline-mobile-info-bar .timeline-status-bar {
        max-width: 140px;
    }

    .timeline-mobile-info-right {
        display: flex;
        gap: 0.35rem;
        flex-shrink: 0;
    }

    .timeline-mobile-zoom-btn {
        width: auto !important;
        padding: 0.35rem 0.75rem !important;
        border-radius: 100px !important;
        margin-bottom: 0 !important;
        font-size: 0.8rem !important;
        min-height: 0 !important;
    }

    /* Timeline scrubber: fills remaining space */
    body.page-timeline .timeline-scrubber-wrapper {
        flex: 1 1 0;
        min-height: 0;
        overflow: hidden;
        height: auto;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    /* Hide scrollbar of timeline scroll track to make it cleaner on touch screens */
    body.page-timeline .timeline-scroll-track::-webkit-scrollbar {
        display: none;
    }
    body.page-timeline .timeline-scroll-track {
        scrollbar-width: none;
    }
}

/* Timeline Status/Loading Bar Styles */
.timeline-title-container {
    display: flex;
    flex-direction: column;
}

.timeline-status-bar {
    height: 4px;
    width: 100%;
    max-width: 200px;
    background-color: #e8eaed; /* light grey track */
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    margin-top: 0.15rem;
    transition: background-color 0.3s ease;
}

.timeline-status-bar .status-indicator {
    width: 0%;
    height: 100%;
    background-color: transparent;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 2px;
    transition: background-color 0.3s ease, width 0.3s ease, left 0.3s ease;
}

/* State 1: Live (Steady Red) */
.timeline-status-bar.state-live {
    background-color: #fce8e6; /* light red background track */
}
.timeline-status-bar.state-live .status-indicator {
    width: 100%;
    left: 0;
    background-color: #d93025; /* steady red */
    animation: none;
}

/* State 2: Live Loading (Bouncing Red) */
.timeline-status-bar.state-live-loading {
    background-color: #fce8e6;
}
.timeline-status-bar.state-live-loading .status-indicator {
    width: 30%;
    background-color: #d93025; /* bouncing red */
    animation: status-bounce 0.8s infinite ease-in-out;
}

/* State 3: Playback (Steady Blue) */
.timeline-status-bar.state-playback {
    background-color: #e8f0fe; /* light blue background track */
}
.timeline-status-bar.state-playback .status-indicator {
    width: 100%;
    left: 0;
    background-color: #1a73e8; /* steady blue */
    animation: none;
}

/* State 4: Playback Loading (Bouncing Blue) */
.timeline-status-bar.state-playback-loading {
    background-color: #e8f0fe;
}
.timeline-status-bar.state-playback-loading .status-indicator {
    width: 30%;
    background-color: #1a73e8; /* bouncing blue */
    animation: status-bounce 0.8s infinite ease-in-out;
}

/* State 5: Scrubbing (Pulse Blue) */
.timeline-status-bar.state-scrubbing {
    background-color: #e8f0fe;
}
.timeline-status-bar.state-scrubbing .status-indicator {
    width: 100%;
    left: 0;
    background-color: #1a73e8; /* pulse blue */
    animation: status-pulse 1.2s infinite ease-in-out;
}

@keyframes status-bounce {
    0% { left: 0%; }
    50% { left: 70%; }
    100% { left: 0%; }
}

@keyframes status-pulse {
    0% { opacity: 0.35; }
    50% { opacity: 1; }
    100% { opacity: 0.35; }
}

/* Timeline Mute Button Overlay */
.timeline-mute-btn {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(32, 33, 36, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: background 0.15s ease-in-out, transform 0.1s, opacity 0.2s;
    padding: 0;
}

.timeline-mute-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.timeline-mute-btn:active {
    transform: scale(0.95);
}

.timeline-mute-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Settings Page Revamp Styling */
.settings-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    padding: 2rem;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    align-items: start;
}

@media (max-width: 900px) {
    .settings-layout {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1.5rem;
    }
}

.settings-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.settings-nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: translateX(4px);
}

.settings-nav-item.active {
    background: rgba(26, 115, 232, 0.15);
    border-color: rgba(26, 115, 232, 0.3);
    color: var(--primary);
    font-weight: 600;
}

.settings-nav-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin: 1.5rem 1.25rem 0.5rem;
    font-weight: 700;
}

/* Sub-items for cameras */
.settings-nav-sub-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem 0.65rem 2.25rem;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.settings-nav-sub-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    transform: translateX(4px);
}

.settings-nav-sub-item.active {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: 600;
}

.settings-nav-sub-item .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5f6368; /* idle */
}
.settings-nav-sub-item .status-indicator.recording { background: var(--error); }
.settings-nav-sub-item .status-indicator.monitoring { background: var(--warning); }
.settings-nav-sub-item .status-indicator.connecting { background: var(--primary); }
.settings-nav-sub-item .status-indicator.idle { background: #5f6368; }

.settings-content-card {
    min-height: 500px;
    animation: fadeIn 0.3s ease;
}

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

.settings-section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.settings-section-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Beautiful custom slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-value {
    font-weight: 600;
    color: var(--primary);
    min-width: 2.5rem;
    text-align: right;
}

.range-slider {
    flex: 1;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-main);
    outline: none;
    transition: background 450ms ease-in;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(26, 115, 232, 0.4);
    transition: transform 0.1s;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Diagonal status dots for list */
.badge-recording-preference {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

/* Diagnostics widgets */
.diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.diag-card {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
}

.diag-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.diag-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}
