/* ==========================================================================
   CSS VARIABLES & GLOBAL RESET
   ========================================================================== */
:root {
    --bg-darker: #080c14;
    --bg-main: #0e1420;
    --bg-card: rgba(20, 28, 45, 0.6);
    --bg-card-hover: rgba(30, 41, 67, 0.8);
    --border-light: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(59, 130, 246, 0.5);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.35);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.3);
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.3);
    --accent-yellow: #f59e0b;
    
    --sidebar-width: 260px;
    --font-outfit: 'Outfit', 'Inter', sans-serif;
    --font-inter: 'Inter', sans-serif;
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-glow: 0 0 15px var(--accent-blue-glow);
}

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

body {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    font-family: var(--font-inter);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Glassmorphism class */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid var(--border-light);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Helpers */
.hidden {
    display: none !important;
}

/* ==========================================================================
   SCREENS & LAYOUT
   ========================================================================== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
#login-screen {
    background: radial-gradient(circle at center, var(--bg-main) 0%, var(--bg-darker) 100%);
    justify-content: center;
    align-items: center;
}

.login-box {
    width: 420px;
    padding: 40px;
    border-radius: 20px;
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo-icon {
    font-size: 3rem;
    display: inline-block;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px var(--accent-blue-glow));
}

.login-header h2 {
    font-family: var(--font-outfit);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, #9ca3af 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control, input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    color: #fff;
    font-family: var(--font-inter);
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.form-control:focus, input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, input[type="date"]:focus, select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.form-control.input-error, input[type="password"].input-error {
    border-color: var(--accent-red) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3) !important;
}

.error-msg {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--accent-red);
    color: #fca5a5;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    text-align: center;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    font-family: var(--font-inter);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-block {
    display: flex;
    width: 100%;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.primary-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.danger-btn {
    background: linear-gradient(135deg, var(--accent-red) 0%, #b91c1c 100%);
    color: #fff;
}

.danger-btn:hover {
    filter: brightness(1.1);
}

.text-btn {
    background: transparent;
    color: var(--accent-blue);
    padding: 6px 12px;
}
.text-btn:hover {
    text-decoration: underline;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-header .logo-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 8px var(--accent-blue-glow));
}

.sidebar-header .logo-text {
    font-family: var(--font-outfit);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #9ca3af 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: 10px;
    transition: var(--transition-fast);
}

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

.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border-left: 3px solid var(--accent-blue);
    border-radius: 4px 10px 10px 4px;
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.08);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logout-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 0.85rem;
    padding: 8px 16px;
}

.logout-btn:hover {
    background: var(--accent-red);
    color: #fff;
    box-shadow: 0 0 10px var(--accent-red-glow);
}

/* ==========================================================================
   MAIN CONTENT PANELS
   ========================================================================== */
.main-content {
    flex: 1;
    height: 100vh;
    position: relative;
    background-color: var(--bg-main);
}

.view-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    overflow-y: auto;
}

.view-panel.active {
    opacity: 1;
    pointer-events: auto;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 15px;
}

.view-header h1 {
    font-family: var(--font-outfit);
    font-size: 1.8rem;
    font-weight: 700;
}

/* ==========================================================================
   LIVE VIEW PANEL
   ========================================================================== */
.live-layout {
    display: flex;
    gap: 20px;
    flex: 1;
    height: calc(100vh - 120px);
    overflow: hidden;
}

/* Camera tree sidebar */
.camera-tree {
    width: 280px;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow: hidden;
}

.camera-tree-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 4px;
}

.camera-tree h3 {
    font-size: 1.1rem;
    font-family: var(--font-outfit);
}

/* PTZ Controls Section */
.ptz-controls-section {
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.3s;
}

.ptz-controls-section.disabled {
    opacity: 0.25;
    pointer-events: none;
}

.ptz-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    width: 100%;
}

.ptz-joystick {
    position: relative;
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: grid;
    grid-template-areas: 
        ". up ."
        "left center right"
        ". down .";
    grid-template-columns: 36px 36px 36px;
    grid-template-rows: 36px 36px 36px;
    gap: 4px;
    justify-content: center;
    align-content: center;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6);
}

.ptz-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    user-select: none;
}

.ptz-btn:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.ptz-btn:active {
    transform: scale(0.9);
}

.ptz-up { grid-area: up; }
.ptz-left { grid-area: left; }
.ptz-right { grid-area: right; }
.ptz-down { grid-area: down; }

.ptz-center {
    grid-area: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: bold;
    user-select: none;
}

.ptz-zoom {
    display: flex;
    width: 100%;
    gap: 8px;
    justify-content: center;
}

.ptz-zoom-btn {
    flex: 1;
    padding: 6px 0;
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.ptz-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-blue);
}

.ptz-zoom-btn:active {
    transform: scale(0.95);
}

.tree-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nvr-group {
    margin-bottom: 10px;
}

.nvr-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.camera-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-top: 4px;
}

.camera-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.camera-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.cam-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.cam-indicator.online {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green-glow);
}

/* Layout Controls */
.grid-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-controls .control-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.grid-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-fast);
}

.grid-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.grid-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

/* Video Grid layout */
.video-grid {
    flex: 1;
    display: grid;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 10px;
    overflow: hidden;
}

.grid-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.grid-9 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; }
.grid-16 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }
.grid-30 { grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(5, 1fr); }

/* Grid Cell / Player Window */
.grid-cell {
    background: #05080e;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
}

.grid-cell.selected {
    border-color: var(--accent-blue);
    box-shadow: inset 0 0 0 1px var(--accent-blue);
}

.grid-cell video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Video Cell overlay controls */
.cell-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
    z-index: 2;
}

.cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    pointer-events: auto;
}

.cell-title {
    background: rgba(0,0,0,0.65);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.05);
}

.cell-actions {
    display: flex;
    gap: 4px;
}

.cell-btn {
    background: rgba(0,0,0,0.65);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.05);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    backdrop-filter: blur(4px);
    transition: var(--transition-fast);
}

.cell-btn:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.cell-btn.close-btn:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.cell-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    pointer-events: auto;
}

.cell-status-label {
    background: rgba(0,0,0,0.65);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cell-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green-glow);
}

.cell-format-controls {
    display: flex;
    gap: 6px;
    background: rgba(0,0,0,0.65);
    padding: 2px 6px;
    border-radius: 6px;
}

.cell-format-controls select, .cell-format-controls label {
    font-size: 0.75rem;
    padding: 2px 4px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.cell-format-controls select:focus {
    box-shadow: none;
}

.cell-format-controls label {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Spinner and placeholder in cells */
.cell-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.cell-placeholder .icon {
    font-size: 2.2rem;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--accent-blue);
}

.grid-cell .loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    pointer-events: none;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s linear infinite;
}

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

/* ==========================================================================
   PLAYBACK PANEL (ARCHIVE)
   ========================================================================== */
.playback-layout {
    display: flex;
    gap: 20px;
    flex: 1;
    height: calc(100vh - 120px);
    overflow: hidden;
}

.playback-controls-sidebar {
    width: 300px;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
}

.recordings-list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.recordings-list-container h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 6px;
}

.recordings-list {
    list-style: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.recording-item-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-fast);
}

.recording-item-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
}

.recording-item-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.recording-item-btn .rec-time {
    font-weight: 600;
}

.recording-item-btn .rec-size {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.recording-item-btn.active .rec-size {
    color: rgba(255,255,255,0.8);
}

.list-placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 20px 10px;
}

.playback-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow: hidden;
}

.player-container {
    flex: 1;
    background: #000;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(14, 20, 32, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
    z-index: 5;
}

.playback-speed-controls {
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
}

.speed-btns {
    display: flex;
    gap: 4px;
}

.speed-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.speed-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.speed-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

/* Timeline Components */
.timeline-container {
    padding: 15px 20px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.timeline-bar-wrapper {
    position: relative;
    padding-top: 15px;
}

.timeline-hours {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-bottom: 6px;
}

.timeline-bar {
    height: 32px;
    background: rgba(0,0,0,0.4);
    border-radius: 6px;
    border: 1px solid var(--border-light);
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.timeline-segment {
    position: absolute;
    height: 100%;
    background: rgba(59, 130, 246, 0.4);
    border-left: 1px solid rgba(59, 130, 246, 0.6);
    border-right: 1px solid rgba(59, 130, 246, 0.6);
    transition: background 0.2s ease;
}

.timeline-segment:hover {
    background: rgba(59, 130, 246, 0.6);
}

.timeline-segment.active {
    background: rgba(59, 130, 246, 0.8);
}

.timeline-cursor {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: var(--accent-red);
    box-shadow: 0 0 6px var(--accent-red);
    z-index: 10;
    pointer-events: none;
    transition: left 0.1s linear;
}

/* ==========================================================================
   DEVICES & USERS PANELS
   ========================================================================== */
.nvr-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.nvr-card {
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: var(--transition-normal);
}

.nvr-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-focus);
}

.nvr-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.nvr-card-info h2 {
    font-family: var(--font-outfit);
    font-size: 1.3rem;
    font-weight: 600;
}

.nvr-card-info .nvr-host {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-family: monospace;
}

.nvr-badge {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
}

.nvr-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nvr-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.nvr-stat-val {
    color: var(--text-primary);
    font-weight: 500;
}

.nvr-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* Tables */
.users-table-container {
    border-radius: 16px;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 16px 20px;
}

.data-table th {
    background: rgba(0,0,0,0.2);
    font-family: var(--font-outfit);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.data-table td {
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.data-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

.role-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-badge.admin {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.role-badge.operator {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.role-badge.viewer {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 8, 14, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    width: 640px;
    max-height: 90vh;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlide {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    font-family: var(--font-outfit);
    font-size: 1.4rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.form-row {
    display: flex;
    gap: 16px;
}

.col-6 { width: 50%; }
.col-8 { width: 66.66%; }
.col-4 { width: 33.33%; }
.col-3 { width: 25%; }

.hint-text {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 4px;
}

.modal-actions-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.status-indicator {
    font-size: 0.85rem;
}
.status-indicator.success { color: var(--accent-green); }
.status-indicator.error { color: var(--accent-red); }
.status-indicator.loading { color: var(--accent-blue); }

.channels-section {
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
    margin-top: 10px;
}

.channels-section h3 {
    font-family: var(--font-outfit);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.channels-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    margin-bottom: 10px;
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 20px;
}

.channel-form-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.channel-form-row input[type="text"] {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.channel-form-row input.ch-num { width: 50px; text-align: center; }
.channel-form-row input.ch-name { flex: 1; }
.channel-form-row input.ch-path { width: 140px; }

.channel-form-row label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-light);
    padding: 8px 10px;
    border-radius: 8px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
    margin-top: 20px;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    min-width: 280px;
    padding: 16px 20px;
    border-radius: 10px;
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastIn {
    from { transform: translateX(100%) translateY(0); opacity: 0; }
    to { transform: translateX(0) translateY(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--accent-green); }
.toast.error { border-left: 4px solid var(--accent-red); }
.toast.info { border-left: 4px solid var(--accent-blue); }

/* ==========================================================================
   NETWORK SCANNER PANEL
   ========================================================================== */
.scanner-layout {
    display: flex;
    gap: 20px;
    flex: 1;
    height: calc(100vh - 120px);
    overflow: hidden;
}

.scanner-controls-sidebar {
    width: 320px;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.protocol-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.15);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.scan-action-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scan-progress-container {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-bar-wrapper {
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-blue);
    box-shadow: 0 0 8px var(--accent-blue);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

.scanner-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.scan-results-container {
    flex: 1;
    border-radius: 16px;
    overflow-y: auto;
}

.table-placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.table-placeholder td {
    padding: 40px !important;
}

.badge-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 4px;
}

.badge-tag.onvif {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-tag.dahua {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.badge-tag.hikvision {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-tag.xm {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.badge-tag.rtsp {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}
