/* ==========================================================================
   ATOM CCTV - SISTEMA DE VIDEOVIGILANCIA NVR
   Tema oscuro profesional enterprise (inspirado en NVR/VMS modernos)
   ========================================================================== */

:root {
    --bg-app: #060b16;
    --bg-topbar: #0a1222;
    --bg-panel: #0c1629;
    --bg-card: #101d35;
    --bg-card-hover: #152544;
    --bg-input: #081020;
    --border: #1b2c4c;
    --border-strong: #27406b;

    --text-primary: #eef4ff;
    --text-secondary: #90a4c7;
    --text-muted: #5d7399;

    --accent: #1d6ef5;
    --accent-hover: #3180ff;
    --accent-soft: rgba(29, 110, 245, 0.16);

    --green: #10b981;
    --green-soft: rgba(16, 185, 129, 0.15);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, 0.16);
    --amber: #f59e0b;
    --amber-soft: rgba(245, 158, 11, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
    --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    --font-mono: 'Consolas', 'Cascadia Code', ui-monospace, monospace;
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.45;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar oscura */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #213559; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #335084; }

.hidden { display: none !important; }

/* ==========================================================================
   LOGIN OVERLAY
   ========================================================================== */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: radial-gradient(circle at 25% 20%, #102347 0%, #050a14 68%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(13, 22, 41, 0.94);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.login-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.4);
}

.login-brand h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.6px;
}

.login-brand p {
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.login-hint {
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(29, 110, 245, 0.1);
    border: 1px solid rgba(29, 110, 245, 0.25);
    color: var(--text-secondary);
    font-size: 12px;
}

.login-hint code {
    color: #7cc0ff;
    font-family: var(--font-mono);
}

/* ==========================================================================
   APP SHELL & TOPBAR
   ========================================================================== */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.topbar {
    height: 54px;
    min-height: 54px;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    gap: 12px;
    z-index: 40;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #1d6ef5, #0284c7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(29, 110, 245, 0.35);
}

.brand-title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: #fff;
    line-height: 1.1;
}

.brand-sub {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.9px;
    color: #60a5fa;
    text-transform: uppercase;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.16s ease;
    white-space: nowrap;
}

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

.nav-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(29, 110, 245, 0.38);
}

.nav-badge {
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}

.db-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 8px;
    background: #0e1a30;
    border: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.db-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}

.db-pill.sqlite .dot {
    background: var(--amber);
    box-shadow: 0 0 8px var(--amber);
}

.icon-btn {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0e1a30;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    color: #fff;
    border-color: var(--border-strong);
    background: #152544;
}

.notif-dot {
    position: absolute;
    top: 5px;
    right: 6px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 6px;
    border-radius: 9px;
    background: #0f1c33;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.15s;
}

.user-pill:hover { background: #162848; }

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: #fff;
}

.user-meta {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.15;
}

.user-name { font-size: 12px; font-weight: 700; }
.user-role { font-size: 10px; color: var(--text-secondary); }

/* ==========================================================================
   BOTONES & FORMULARIOS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #13223e;
    color: var(--text-primary);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:hover { background: #1a2f55; border-color: var(--border-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(180deg, #2575fc, #165cd4);
    border-color: #2f80ff;
    color: #fff;
    box-shadow: 0 3px 12px rgba(29, 110, 245, 0.35);
}
.btn-primary:hover { background: linear-gradient(180deg, #3583ff, #1d6ef5); }

.btn-danger {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); color: #fff; }

.btn-success {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.45);
    color: #6ee7b7;
}
.btn-success:hover { background: rgba(16, 185, 129, 0.28); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: 6px; }
.btn-block { width: 100%; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.input, .select {
    width: 100%;
    padding: 9px 11px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.input:focus, .select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 110, 245, 0.18);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ==========================================================================
   VIEWS CONTAINER
   ========================================================================== */
.views-container {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.view-section {
    display: none;
    height: 100%;
    width: 100%;
}

.view-section.active {
    display: flex;
}

/* ==========================================================================
   VIEW 1: EN VIVO (LAYOUT 3 COLUMNAS + TIMELINE INFERIOR)
   ========================================================================== */
.live-layout {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
}

/* Sidebar Izquierda: Cámaras y Vistas */
.live-sidebar-left {
    width: 232px;
    min-width: 232px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

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

.mini-icon-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #0f1d36;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.mini-icon-btn:hover { color: #fff; border-color: var(--accent); }

.search-box {
    padding: 0 10px 10px;
}

.search-box .input {
    padding: 7px 10px;
    font-size: 12px;
}

.camera-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 10px;
}

.tree-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.tree-all.active { background: var(--accent); color: #fff; }
.tree-all:not(.active):hover { background: rgba(255, 255, 255, 0.05); }

.tree-folder {
    margin-bottom: 4px;
}

.tree-folder-head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.tree-folder-head:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.tree-folder-head.active { background: rgba(29, 110, 245, 0.18); color: #fff; }

.folder-icon { color: var(--amber); flex-shrink: 0; }

.tree-children {
    padding-left: 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-cam-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid transparent;
}
.tree-cam-item:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.tree-cam-item.selected {
    background: var(--accent-soft);
    border-color: rgba(29, 110, 245, 0.45);
    color: #fff;
}

.tree-cam-name {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}
.status-dot.offline {
    background: var(--red);
    opacity: 0.85;
}

/* Vistas (Layouts) abajo en sidebar izquierdo */
.views-box {
    border-top: 1px solid var(--border);
    padding: 10px 8px 12px;
}

.views-box-title {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 0 6px 8px;
    text-transform: uppercase;
}

.layout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    margin-bottom: 3px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}
.layout-btn:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.layout-btn.active {
    background: rgba(29, 110, 245, 0.22);
    border-color: rgba(29, 110, 245, 0.5);
    color: #fff;
    font-weight: 600;
}

/* Centro: Cuadrícula de Video + Timeline */
.live-center {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #040811;
}

.video-grid-wrap {
    flex: 1;
    min-height: 0;
    padding: 8px;
    overflow: hidden;
    display: flex;
}

.video-grid {
    flex: 1;
    display: grid;
    gap: 8px;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.video-grid.grid-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.video-grid.grid-2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
.video-grid.grid-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.video-grid.grid-6 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.video-grid.grid-9 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }

.cam-tile {
    position: relative;
    background: radial-gradient(circle at center, #0e1a30 0%, #070d1a 100%);
    border: 1.5px solid #182744;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    min-height: 0;
    min-width: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cam-tile.selected {
    border-color: #2575fc;
    box-shadow: 0 0 0 1px rgba(37, 117, 252, 0.55), inset 0 0 24px rgba(37, 117, 252, 0.12);
}

.cam-tile.motion-alert {
    border-color: var(--amber);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.55);
}

.cam-tile.empty-slot {
    border-style: dashed;
    border-color: #16243f;
    background: rgba(9, 16, 31, 0.55);
    cursor: default;
}

.cam-stage {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cam-canvas, .cam-video, .cam-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #02050b;
    display: block;
    transform-origin: center center;
    transition: transform 0.12s ease-out;
}

.cam-offline-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    gap: 8px;
    background: radial-gradient(circle at center, rgba(16, 30, 56, 0.88), rgba(6, 11, 22, 0.96));
    z-index: 4;
}

.cam-offline-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.08);
    border: 1.5px solid rgba(148, 163, 184, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.cam-offline-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #e2e8f0;
    text-transform: uppercase;
}

.cam-offline-sub {
    font-size: 11.5px;
    color: var(--text-secondary);
    max-width: 280px;
}

/* Overlays del tile de cámara */
.tile-top-bar {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    pointer-events: none;
    z-index: 6;
}

.tile-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 5px;
    background: rgba(4, 9, 19, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11.5px;
    font-weight: 700;
    color: #fff;
    max-width: 58%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-clock {
    padding: 3px 8px;
    border-radius: 5px;
    background: rgba(4, 9, 19, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--font-mono);
    font-size: 11px;
    color: #cbd5e1;
    white-space: nowrap;
}

.tile-bottom-bar {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    z-index: 6;
}

.tile-badges {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.badge-rec {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    border: 1px solid rgba(239, 68, 68, 0.45);
    background: rgba(127, 29, 29, 0.55);
    color: #fca5a5;
    cursor: pointer;
    transition: all 0.15s;
}

.badge-rec.recording {
    background: #dc2626;
    border-color: #f87171;
    color: #fff;
    animation: pulseRec 1.2s infinite;
}

@keyframes pulseRec {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.badge-tech {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    background: rgba(4, 9, 19, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
}

.badge-motion {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    background: rgba(245, 158, 11, 0.9);
    color: #111827;
}

.tile-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(4, 9, 19, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 3px;
}

.tile-act-btn {
    width: 26px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.14s;
}
.tile-act-btn:hover { background: rgba(29, 110, 245, 0.35); color: #fff; }
.tile-act-btn.active { background: var(--amber); color: #0b1120; }
.tile-act-btn.danger:hover { background: rgba(239, 68, 68, 0.45); color: #fff; }

/* Timeline inferior */
.timeline-panel {
    height: 146px;
    min-height: 146px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.timeline-toolbar {
    height: 44px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.timeline-date-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-date-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-family: var(--font-mono);
}

.timeline-time-pill {
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(29, 110, 245, 0.12);
    border: 1px solid rgba(29, 110, 245, 0.55);
    color: #60a5fa;
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 700;
}

.timeline-transport {
    display: flex;
    align-items: center;
    gap: 8px;
}

.transport-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #12213b;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.transport-btn:hover { background: #1c3259; }
.transport-btn.play-main {
    width: 34px;
    height: 34px;
    background: var(--accent);
    border-color: #3b82f6;
    color: #fff;
    box-shadow: 0 3px 12px rgba(29, 110, 245, 0.45);
}

.timeline-right-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-tracks-wrap {
    flex: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 12px 6px;
    user-select: none;
}

.timeline-hours {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    margin-bottom: 4px;
}

.timeline-ruler {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    padding: 0 2px;
}

.timeline-track-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    height: 26px;
    margin-bottom: 3px;
}

.timeline-track-name {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-track-bar {
    position: relative;
    height: 16px;
    border-radius: 4px;
    background: #081122;
    border: 1px solid #162440;
    cursor: pointer;
    overflow: hidden;
}

.timeline-seg {
    position: absolute;
    top: 1px;
    bottom: 1px;
    min-width: 5px;
    border-radius: 3px;
    background: linear-gradient(180deg, #2575fc, #1a56c4);
    cursor: pointer;
}
.timeline-seg.motion { background: linear-gradient(180deg, #f59e0b, #d97706); }
.timeline-seg.snapshot { background: #10b981; width: 4px !important; }

.timeline-ev-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #ef4444;
    z-index: 2;
}

.timeline-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #38bdf8;
    box-shadow: 0 0 8px #38bdf8;
    pointer-events: none;
    z-index: 5;
}

/* Sidebar Derecha: PTZ, Ajustes de Imagen, Eventos Recientes */
.live-sidebar-right {
    width: 256px;
    min-width: 256px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 12px;
    gap: 14px;
}

.panel-block {
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}
.panel-block:last-child { border-bottom: none; padding-bottom: 0; }

.panel-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.panel-block-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.7px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.panel-block-sub {
    font-size: 11px;
    color: #60a5fa;
    font-weight: 600;
    max-width: 115px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* PTZ D-Pad */
.ptz-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.ptz-dpad {
    position: relative;
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: radial-gradient(circle, #142341 0%, #091224 72%);
    border: 1.5px solid var(--border-strong);
    flex-shrink: 0;
}

.ptz-dir {
    position: absolute;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.14s;
}
.ptz-dir:hover { color: #fff; background: rgba(29, 110, 245, 0.3); }
.ptz-dir.up { top: 6px; left: 50%; transform: translateX(-50%); }
.ptz-dir.down { bottom: 6px; left: 50%; transform: translateX(-50%); }
.ptz-dir.left { left: 6px; top: 50%; transform: translateY(-50%); }
.ptz-dir.right { right: 6px; top: 50%; transform: translateY(-50%); }
.ptz-dir.center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    background: #132341;
    border: 1px solid var(--border-strong);
    color: #60a5fa;
    font-size: 10px;
    font-weight: 700;
}

.ptz-zoom-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.ptz-zoom-btn {
    width: 36px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: #101e38;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}
.ptz-zoom-btn:hover { background: var(--accent); border-color: var(--accent); }

.ptz-zoom-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.ptz-mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 10px;
}

.ptz-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0f1b33;
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
}
.ptz-mode-btn:hover { color: #fff; border-color: var(--border-strong); }
.ptz-mode-btn.active { background: var(--accent-soft); border-color: var(--accent); color: #7cc0ff; }

/* Sliders de imagen */
.slider-row {
    display: grid;
    grid-template-columns: 74px 1fr 32px;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 11.5px;
    color: var(--text-secondary);
}

.slider-row input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.slider-val {
    font-family: var(--font-mono);
    font-size: 11px;
    text-align: right;
    color: var(--text-primary);
}

/* Lista de eventos recientes en barra derecha */
.recent-events-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recent-ev-item {
    display: flex;
    gap: 8px;
    padding: 7px;
    border-radius: 8px;
    background: #0e1a30;
    border: 1px solid var(--border);
    cursor: pointer;
}
.recent-ev-item:hover { border-color: var(--border-strong); }

.recent-ev-thumb {
    width: 44px;
    height: 32px;
    border-radius: 5px;
    background: #060d1a;
    object-fit: cover;
    flex-shrink: 0;
}

.recent-ev-body { min-width: 0; flex: 1; }
.recent-ev-title { font-size: 11.5px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-ev-meta { font-size: 10.5px; color: var(--text-muted); }

/* ==========================================================================
   VISTAS DE PÁGINA COMPLETA (GRABACIONES, EVENTOS, DISPOSITIVOS, USUARIOS, AJUSTES)
   ========================================================================== */
.page-view {
    flex: 1;
    overflow-y: auto;
    padding: 20px 26px 32px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    color: #fff;
}

.page-subtitle {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

/* Tablas estilo NVR */
.table-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: #101d35;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(27, 44, 76, 0.55);
    vertical-align: middle;
    font-size: 12.5px;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(29, 110, 245, 0.05); }

.table-empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* Pills y estados */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
}

.pill-green { background: var(--green-soft); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }
.pill-red { background: var(--red-soft); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }
.pill-amber { background: var(--amber-soft); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.pill-blue { background: var(--accent-soft); color: #60a5fa; border: 1px solid rgba(29, 110, 245, 0.4); }

.thumb-preview {
    width: 68px;
    height: 40px;
    border-radius: 6px;
    background: #060d1c;
    border: 1px solid var(--border);
    object-fit: cover;
    display: block;
}

/* Grabaciones Grid */
.recordings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
    gap: 14px;
}

.rec-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, border-color 0.15s;
}
.rec-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }

.rec-thumb-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #050a14;
    overflow: hidden;
    cursor: pointer;
}

.rec-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rec-play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 20, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.rec-thumb-wrap:hover .rec-play-overlay { opacity: 1; background: rgba(5, 10, 20, 0.15); }

.rec-play-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(29, 110, 245, 0.92);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.rec-duration-tag {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.8);
    font-family: var(--font-mono);
    font-size: 11px;
    color: #fff;
}

.rec-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rec-title { font-weight: 700; font-size: 13px; color: #fff; }
.rec-meta { font-size: 11.5px; color: var(--text-secondary); display: flex; justify-content: space-between; }
.rec-actions { display: flex; gap: 6px; margin-top: 4px; }

/* Ajustes Grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 18px;
}

.settings-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.settings-card h3 {
    margin: 0 0 16px;
    font-size: 14.5px;
    font-weight: 700;
    color: #60a5fa;
}

.disk-bar-bg {
    height: 10px;
    border-radius: 99px;
    background: #172744;
    overflow: hidden;
    margin: 8px 0 6px;
}

.disk-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #1d6ef5, #38bdf8);
    border-radius: 99px;
    transition: width 0.3s ease;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ==========================================================================
   MODALES (VINCULAR TELÉFONO, AGREGAR CÁMARA, USUARIOS, REPRODUCTOR)
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(3, 7, 16, 0.78);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal-box {
    width: 100%;
    max-width: 760px;
    max-height: 92vh;
    background: #0d182d;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-box.modal-sm { max-width: 480px; }
.modal-box.modal-lg { max-width: 900px; }

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

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

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

/* Modal Vincular Teléfono */
.pair-grid {
    display: grid;
    grid-template-columns: 245px 1fr;
    gap: 22px;
    align-items: start;
}

.qr-card {
    background: #0a1223;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
}

.qr-frame {
    width: 210px;
    height: 210px;
    margin: 0 auto 10px;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-frame svg {
    width: 100%;
    height: 100%;
    display: block;
}

.qr-caption {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

.pair-url-row {
    display: flex;
    gap: 8px;
    margin: 8px 0 12px;
}

.pair-url-row .input {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #60a5fa;
}

.pair-steps {
    background: #091224;
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text-secondary);
}

.pair-steps strong { color: #fff; }
.pair-steps ol { margin: 6px 0 0; padding-left: 18px; }
.pair-steps li { margin-bottom: 4px; }

.pair-devices-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.pair-devices-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.pair-device-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    background: #091224;
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

/* Toast notifications */
.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
}

.toast {
    padding: 11px 14px;
    border-radius: 9px;
    background: #101e38;
    border: 1px solid var(--border-strong);
    color: #fff;
    font-size: 12.5px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.2s ease;
}

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

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

/* Responsive */
@media (max-width: 1180px) {
    .live-sidebar-right { width: 224px; min-width: 224px; }
    .live-sidebar-left { width: 200px; min-width: 200px; }
}

@media (max-width: 900px) {
    .live-sidebar-left, .live-sidebar-right { display: none; }
    .pair-grid { grid-template-columns: 1fr; }
    .brand-sub { display: none; }
}
