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

/* ── Vision Management Platform — Premium Light Theme ── */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #eef2f6;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #1653AB;
    --accent-hover: #103d7c;
    --accent-light: #eff6ff;
    --accent-glow: rgba(22, 83, 171, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.09);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-w: 280px;
    --sidebar-collapsed-w: 50px;
    --sidebar-bg: linear-gradient(90deg, #3D62B8 0%, #3353A3 55%, #2B4891 100%);
    --sidebar-text: #FFFFFF;
    --sidebar-muted: #FFFFFF;
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-border: #E6E7EB;
    --sidebar-active: #5684E4;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

/* ─── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ─── Premium Modern Login ─── */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #ffffff; 
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background: #ffffff;
    width: 100%;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Left side branding area */
.login-branding {
    flex: 1.1;
    background: linear-gradient(135deg, #3b5bdb 0%, #2b45b9 100%);
    padding: 80px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    border-radius: 0;
    margin: 0;
}

.branding-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.cognecto-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.logo-text {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -1px;
    font-family: 'Inter', sans-serif;
}

.branding-title {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
    margin: 0;
}

.branding-subtitle {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.75);
    margin: 0;
    max-width: 380px;
}

.feature-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 24px;
    margin-top: auto;
}

.feature-text h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.feature-text p {
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.feature-dots {
    display: flex;
    gap: 6px;
    margin-top: 16px;
}

.feature-dots .dot {
    width: 24px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.feature-dots .dot.active {
    background: white;
}

/* Right side form area */
.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 120px;
}

.form-wrapper {
    width: 100%;
    max-width: 340px;
}

.form-title {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.form-subtitle {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 32px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group input {
    width: 100%;
    padding: 14px 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus {
    background: white;
    border-color: #3b5bdb;
    box-shadow: 0 0 0 4px rgba(59, 91, 219, 0.15);
}

.form-actions {
    text-align: right;
    margin-bottom: 24px;
}

.forgot-link {
    font-size: 12px;
    color: #64748b;
    text-decoration: none;
}

.btn-signin {
    width: 100%;
    padding: 14px;
    background: #3b5bdb;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-signin:hover {
    background: #2b45b9;
}

.divider {
    text-align: center;
    margin: 24px 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e2e8f0;
}

.divider span {
    position: relative;
    background: white;
    padding: 0 12px;
    font-size: 12px;
    color: #94a3b8;
}

.register-text {
    text-align: center;
    font-size: 13px;
    color: #64748b;
}

.register-text a {
    color: #3b5bdb;
    text-decoration: none;
    font-weight: 600;
}

.error-text {
    color: #ef4444;
    font-size: 12px;
    text-align: center;
    margin-top: 16px;
}

/* ─── Forms ─────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
}

/* ─── Buttons ──────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-accent {
    background: var(--accent);
    color: white;
    font-size: 12px;
    padding: 5px 12px;
}

.btn-accent:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 11px;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 14px;
}

/* ─── Layout ────────────────────────────────────── */
.main-layout {
    display: flex;
    height: 100vh;
    background: var(--bg-secondary);
    overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 10;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    color: var(--sidebar-text);
    font-family: 'Inter', sans-serif;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
    min-width: var(--sidebar-collapsed-w);
    cursor: pointer;
}

.sidebar.collapsed * {
    pointer-events: none;
}

.sidebar.collapsed .sidebar-toggle,
.sidebar.collapsed .logout-minimal,
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-item-link,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .sidebar-header {
    pointer-events: auto;
}

.sidebar-header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    min-height: 60px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
}

.brand-icon {
    color: white;
    font-size: 16px;
    transition: var(--transition);
}

.brand-text {
    font-size: 15px;
    font-weight: 500;
    color: white;
    letter-spacing: -0.3px;
    flex: 1;
    transition: var(--transition);
}

.sidebar-toggle {
    background: var(--sidebar-hover);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: var(--transition);
    font-size: 13px;
}

.sidebar-toggle:hover {
    background: #3a3a3c;
    color: white;
    border-color: var(--accent);
}

/* Collapsed states for internal elements */
.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-search input,
.sidebar.collapsed .user-identity span,
.sidebar.collapsed .sidebar-header h3 span,
.sidebar.collapsed .btn-accent,
.sidebar.collapsed .tree-container,
.sidebar.collapsed .stats-overview,
.sidebar.collapsed .brand-icon {
    display: none !important;
}

.sidebar.collapsed .sidebar-header-main {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .sidebar-brand {
    display: flex !important;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-toggle {
    display: none !important;
}

.sidebar.collapsed #toggle-icon {
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .profile-row {
    padding-left: 0;
    padding-right: 0;
    justify-content: center;
    border: none !important;
    background: transparent !important;
    width: 100%;
    display: flex;
}

.sidebar.collapsed .search-box {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    background: transparent;
    border-radius: 12px;
    border: none;
    margin: 0 auto;
}

.sidebar.collapsed .search-box i {
    margin-right: 0;
    color: #a1a1aa;
    font-size: 16px;
}

.sidebar.collapsed .profile-row {
    padding: 12px 0;
    background: transparent !important;
    border: none !important;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 20px;
    align-items: center;
    justify-content: center;
}

.sidebar.collapsed .logout-minimal {
    font-size: 18px;
    background: transparent;
    color: var(--sidebar-muted);
}

.sidebar.collapsed .logout-minimal:hover {
    color: var(--danger);
}

.sidebar.collapsed .sidebar-header {
    border: none;
}

.sidebar.collapsed .sidebar-header h3 {
    margin: 0;
}

.sidebar.collapsed .sidebar-header i {
    font-size: 18px;
    color: var(--sidebar-muted);
}

.sidebar.collapsed .user-identity i {
    font-size: 20px;
    color: var(--sidebar-muted);
}

.sidebar-nav-main {
    padding: 12px 14px 4px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar.collapsed .sidebar-nav-main {
    padding: 12px 0 4px 0 !important;
}

.sidebar-search {
    padding: 8px 14px 12px 14px;
    background: transparent;
    transition: var(--transition);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--sidebar-hover);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--accent);
    background: #3a3a3c;
}

.search-box i {
    color: var(--sidebar-muted);
    font-size: 12px;
}

.search-box input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: white;
    width: 100%;
    outline: none;
    font-family: inherit;
}

.search-box input::placeholder {
    color: var(--sidebar-muted);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 16px 8px 16px;
    transition: var(--transition);
}

.sidebar-header.clickable:hover {
    background: var(--sidebar-hover);
}

.sidebar-header h3 {
    font-size: 11px;
    font-weight: 500;
    color: white;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.8;
}

.sidebar-header h3 i {
    font-size: 14px;
    color: white;
}

.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background: transparent;
}

.table-actions {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
}

.table-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.table-actions div {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    justify-content: center;
}

th.text-right {
    text-align: right !important;
    white-space: nowrap;
}

/* ─── Video Modal Specialties ─── */
.video-modal-content {
    width: 80%;
    max-width: 1000px;
    padding: 0 !important;
    overflow: hidden;
    background: #000;
}

.video-preview-player {
    width: 100%;
    height: auto;
    display: block;
    background: #000;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.modal-header h2 {
    color: var(--text-primary);
    font-weight: 500;
}

.modal-overlay {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

/* ─── Tree ──────────────────────────────────────── */
.tree-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 24px 12px;
    text-align: center;
    line-height: 1.6;
}

.tree-node {
    margin-left: 0;
}

.tree-node .tree-node {
    margin-left: 18px;
    border-left: none;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
    user-select: none;
    color: var(--sidebar-muted);
}

.tree-item:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
}

.tree-item.selected {
    background: var(--sidebar-active);
    color: #ffffff;
    font-weight: 600;
    border-radius: 16px;
    box-shadow: inset 0 0 0 1px #7EA1EA;
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #FFFFFF;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-icon {
    color: white;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.tree-item.selected .tree-icon {
    color: white;
}

.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-badge {
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.tree-badge.active {
    background: #d1fae5;
    color: #065f46;
}

.tree-badge.offline {
    background: #fee2e2;
    color: #991b1b;
}

.tree-badge.processed {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.tree-badge.raw {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.tree-children {
    display: none;
    margin-top: 2px;
}

.tree-children.expanded {
    display: block;
}

/* ─── Sidebar Footer ────────────────────────────── */
/* ─── Sidebar Footer ─── */
.sidebar-footer {
    padding: 8px 12px 12px 12px;
    background: transparent;
    margin-top: auto;
}

.sidebar-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: #FFFFFF;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.sidebar-item-link:hover {
    background: var(--sidebar-hover);
}

.sidebar-item-link.active {
    background: var(--sidebar-active);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sidebar-item-link i, .sidebar-svg-icon {
    width: 20px;
    height: 18px;
    text-align: center;
    color: #FFFFFF !important;
}

.sidebar-svg-icon {
    width: 20px;
    height: 18px;
    text-align: center;
    color: #FFFFFF !important;
}

/* ─── Collapsed Sidebar Adjustments ─── */
.sidebar.collapsed .sidebar-item-link {
    padding: 10px 0;
    justify-content: center;
}

.sidebar.collapsed .sidebar-item-link span {
    display: none !important;
}

.sidebar.collapsed .sidebar-divider {
    margin: 8px 10px !important;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08); 
    margin: 12px 16px; 
    opacity: 0.5;
}

.sidebar.collapsed .sidebar-divider {
    margin: 8px 10px !important;
}

.sidebar.collapsed .sidebar-footer {
    padding: 12px 0;
}

.sidebar.collapsed .sidebar-item-link {
    width: 38px;
    height: 38px;
    margin: 4px auto;
    padding: 0;
    border-radius: 12px;
    justify-content: center;
}

.sidebar.collapsed .sidebar-item-link span {
    display: none !important;
}

.user-identity {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.user-identity i {
    font-size: 18px;
    color: white;
}

.logout-minimal {
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 14px;
}

.logout-minimal:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* ─── Main Content ──────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ─── Top Navigation (Tab Bar) ──────────────────── */
.top-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background: white;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
    flex-shrink: 0;
}

.breadcrumb-area {
    flex-shrink: 0;
    min-width: 140px;
}

.breadcrumb-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

/* ─── Main Tab Bar ──────────────────────────────── */
.main-tab-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    padding: 0;
    flex: 1;
    justify-content: flex-start;
    margin-left: 20px;
}

.main-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.main-tab.active {
    background: #eff6ff;
    color: #2563eb;
    box-shadow: none;
}

.main-tab.active i {
    color: #2563eb;
}

.main-tab i {
    font-size: 13px;
}

.tab-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.main-tab.tab-action {
    color: var(--text-muted);
}

.main-tab.tab-action:hover {
    background: #fee2e2;
    color: var(--danger);
}

.grid-layout-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.grid-layout-selector label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ─── Header Shortcuts ─── */
.header-shortcut-btn {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.header-shortcut-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--accent);
}

/* ─── User Profile Nav ─── */
.user-profile-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    background: #fff;
    position: relative;
    user-select: none;
}

.user-profile-nav:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.user-profile-nav i.avatar {
    font-size: 18px;
    color: #475569;
}

.user-profile-nav span {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.user-profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 200px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    z-index: 2000;
    padding: 8px;
    display: none;
    text-align: left;
}

.user-profile-dropdown.active {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.dropdown-item.danger {
    color: #ef4444;
}

.dropdown-item.danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 8px 0;
}

.grid-layout-selector select {
    padding: 6px 36px 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    transition: var(--transition);
    min-width: 90px;
}

.grid-layout-selector select:hover {
    border-color: #cbd5e1;
}

.grid-layout-selector select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* ─── Tab Content ───────────────────────────────── */
.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ─── Camera Grid ───────────────────────────────── */
.camera-grid {
    flex: 1;
    display: grid;
    gap: 24px;
    padding: 24px;
    overflow-y: auto;
    background: #f1f5f9;
}

.camera-grid.grid-1 {
    grid-template-columns: 1fr;
}

.camera-grid.grid-2 {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: min-content;
}

.camera-grid.grid-3 {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: min-content;
}

.camera-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: min-content;
}

.grid-cell {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s, box-shadow 0.2s;
    background-clip: padding-box;
    height: 100%;
}

.grid-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.grid-cell-video-container {
    background: #000;
    position: relative;
    aspect-ratio: 16/9;
    width: 100%;
    overflow: hidden;
    border-bottom: 1px solid #f1f5f9;
}

.grid-cell-header {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 2;
}

.grid-cell-top-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.ai-badge {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(8px);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.ai-badge i {
    font-size: 10px;
    color: #60a5fa;
}

.grid-cell-footer {
    background: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    /* Shaved another 5% for maximum visibility */
}

.footer-icon-circle {
    width: 32px;
    height: 32px;
    background: #f0fdf4;
    color: #22c55e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.footer-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.footer-name {
    font-size: 13px;
    font-weight: 500;
    color: #0f172a;
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.footer-sub {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.footer-refresh {
    width: 28px;
    height: 28px;
    background: #eff6ff;
    color: #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 10px;
}

.footer-refresh:hover {
    background: #3b82f6;
    color: white;
    transform: rotate(180deg);
}

.grid-cell-live {
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.recording-dot {
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 5px #ef4444;
}

.grid-cell video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Using contain to ensure the whole feed is visible without distortion or cropping */
    background: #000;
    display: block;
}

.grid-cell-empty {
    width: 100%;
    height: 100%;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    gap: 16px;
}

.grid-cell-empty i {
    font-size: 48px;
    color: #94a3b8;
    opacity: 0.8;
}

.grid-cell-empty span {
    font-size: 16px;
    font-weight: 600;
    color: #94a3b8;
}

.grid-cell-empty span {
    font-size: 12px;
    font-weight: 500;
}

.grid-cell-alert {
    position: absolute;
    top: 40px;
    right: 12px;
    z-index: 3;
    background: var(--danger);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 0 15px var(--danger);
    animation: alertPulse 1s infinite;
}

.grid-cell.has-alert {
    border: 3px solid var(--danger) !important;
    animation: cellBorderPulse 1s infinite;
}

@keyframes alertPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes cellBorderPulse {
    0% {
        border-color: var(--danger);
        box-shadow: 0 0 5px var(--danger);
    }

    50% {
        border-color: #ff0000;
        box-shadow: 0 0 20px var(--danger);
    }

    100% {
        border-color: var(--danger);
        box-shadow: 0 0 5px var(--danger);
    }
}

/* ─── Analytics / Detail Panel ──────────────────── */
.detail-panel {
    padding: 32px;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 14px;
    padding: 60px 0;
    text-align: center;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.detail-header h2 {
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.detail-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.detail-card label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.detail-card .value {
    font-size: 18px;
    font-weight: 600;
    margin-top: 6px;
    color: var(--text-primary);
}

/* ─── Setup Tab ─────────────────────────────────── */
.setup-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.setup-subtab-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 24px;
    background: white;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.setup-subtab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 400;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}

.setup-subtab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.setup-subtab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

.setup-subtab i {
    font-size: 13px;
}

.setup-section {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    padding: 0; /* Removing padding to allow tables to scroll correctly */
    gap: 0;
    min-height: 0;
}

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

.setup-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    margin-bottom: 8px;
    padding-bottom: 8px;
}

.setup-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
    border-left: 3px solid var(--accent);
    padding-left: 16px;
    margin-left: -16px;
}

.setup-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    padding-left: 16px;
}

.alert-stats-row {
    display: flex;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background: #f8fafc;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.stat-pill:hover {
    border-color: var(--accent);
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.stat-pill i {
    opacity: 0.8;
}

.stat-pill b {
    color: var(--text-primary);
    font-weight: 600;
    margin-left: 2px;
}

.setup-table-wrapper {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: white;
}

.setup-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.setup-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.setup-table th {
    text-align: left;
    padding: 14px 16px;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.setup-table th i {
    margin-right: 8px;
    color: var(--accent);
    opacity: 0.8;
    font-size: 12px;
}

.setup-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    vertical-align: middle;
    transition: background 0.2s ease;
}

.setup-table tr:hover td {
    background: rgba(22, 83, 171, 0.02);
    color: var(--text-primary);
}

.setup-table tr:last-child td {
    border-bottom: none;
}

.table-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

.table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

.table-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.status-pill.active {
    background: #d1fae5;
    color: #065f46;
}

.status-pill.offline {
    background: #fee2e2;
    color: #991b1b;
}

.status-pill.online {
    background: #d1fae5;
    color: #065f46;
}

.status-pill.unknown {
    background: #fef9c3;
    color: #854d0e;
}

.td-mono {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── AI Config Tab ─────────────────────────────── */
.config-container {
    display: flex;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

.config-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.config-nav-item {
    padding: 10px 14px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.config-nav-item.active {
    background: var(--accent);
    color: white;
}

.config-nav-item i {
    width: 16px;
    text-align: center;
}

.config-content {
    flex: 1;
    background: white;
    overflow-y: auto;
}

.config-section {
    display: none;
}

.config-section.active {
    display: block;
}

/* ─── Detail Table ──────────────────────────────── */
.detail-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.message-cell {
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    color: var(--text-secondary);
}

.detail-table th {
    text-align: left;
    padding: 11px 14px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.detail-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.detail-table tr:last-child td {
    border-bottom: none;
}

.detail-table tr:hover td {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ─── Modal ─────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    width: 520px;
    max-height: 90vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modalAppear 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(12px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: #fee2e2;
    color: var(--danger);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 70vh;
}

/* ─── AI Models Extension ───────────────────────── */
.setup-tabs-inner {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 6px;
    display: flex;
    gap: 4px;
}

.setup-tabs-inner .setup-subtab {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    border-bottom: none;
    margin-bottom: 0;
}

.setup-tabs-inner .setup-subtab.active {
    background: white;
    box-shadow: var(--shadow);
    color: var(--accent);
}

.badge {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-outline {
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.text-right {
    text-align: right;
}

/* ─── AI Models Flex Fix ───────────────────────── */
.aim-tab-section {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.aim-tab-section.active {
    display: flex;
}

.badge-accent {
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
}

.severity-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.severity-tag.critical {
    background: #450a0a;
    color: #fecaca;
}

.severity-tag.high {
    background: #fee2e2;
    color: #991b1b;
}

.severity-tag.medium {
    background: #fef3c7;
    color: #92400e;
}

.severity-tag.low {
    background: #dcfce7;
    color: #166534;
}


/* ─── Advanced Archive Viewer ──────────────────── */
.archive-viewer {
    background: white;
    border-radius: var(--radius-xl);
    width: 95vw;
    height: 90vh;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: modalAppear 0.3s ease-out;
}

.av-header {
    background: #fff;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.av-title-group h2 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.av-title-group p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 2px 0 0 0;
}

.av-header-actions {
    display: flex;
    gap: 8px;
}

.av-header-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
}

.av-header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.av-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Columns */
.av-col-left {
    width: 320px; /* Slightly wider for better alert readability */
    border-right: 1px solid var(--border);
    padding: 0; /* Removing padding to allow internal sections to manage it */
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
}

.av-col-mid {
    width: 140px;
    border-right: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.av-col-main {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fafafa;
}

.av-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.av-section-header i {
    color: var(--accent);
}

/* Calendar */
.av-calendar-nav {
    display: flex;
    align-items: center;
    gap: 4px; /* Tighter gap */
}

.av-calendar-nav span {
    font-size: 14px;
    font-weight: 700;
    min-width: 100px;
    text-align: center;
    color: var(--text-primary);
}

.av-calendar-nav button {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.av-calendar-nav button:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.av-calendar-nav button i {
    font-size: 12px;
}

.av-icon-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.av-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

.av-icon-btn i {
    font-size: 14px;
}

.av-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 20px;
    padding: 0 4px;
    /* Added padding */
}

.av-day-name {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0;
    font-weight: 500;
}

.av-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    background: #f8fafc;
    border: 1px solid transparent;
}

.av-day:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.av-day.other-month {
    opacity: 0.1;
    cursor: default;
    pointer-events: none;
}

.av-day.selected {
    background: var(--accent);
    color: white;
    font-weight: 600;
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(22, 83, 171, 0.3);
    border-color: var(--accent);
}

/* Day Status Dots */
.av-day .dot-pos {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.av-day.has-video::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--success);
}

.av-day.has-alert::before {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 4px var(--danger);
}

.av-legend {
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    border-top: 1px solid var(--border);
    background: #fcfcfc;
}

.av-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.av-legend-item .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.av-legend-item .dot.available {
    background: var(--success);
}

.av-legend-item .dot.no-data {
    background: #e2e8f0;
}

.av-legend-item .dot.alert {
    background: var(--danger);
}

.av-selected-info {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.av-selected-info label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.av-selected-info p {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
}

/* Archive Slots */
.av-slot-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    padding: 2px;
}

.av-slot-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    transition: var(--transition);
    flex-shrink: 0;
}

.av-slot-row.active {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 2px 8px rgba(22, 83, 171, 0.1);
}

.av-slot-time {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.av-slot-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.av-action-btn {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: var(--transition);
}

.av-action-btn.raw {
    color: #3b82f6;
}

.av-action-btn.proc {
    color: #10b981;
}

.av-action-btn:hover {
    border-color: var(--accent);
    transform: scale(1.1);
}

.av-action-btn.active {
    color: white;
    border-color: transparent;
}

.av-action-btn.raw.active {
    background: #3b82f6;
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.3);
}

.av-action-btn.proc.active {
    background: #10b981;
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.3);
}


.av-type-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.av-type-badge.processed {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.av-type-badge.raw {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.av-empty-msg {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 20px;
    font-style: italic;
}

/* Player Main Area */
.av-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.av-player-header h3 {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

.av-player-wrapper {
    flex: 1;
    background: #000;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.av-video-element {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.av-player-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

.av-player-placeholder .placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* Timezone Selector */
.tz-selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tz-selector-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

#global-timezone {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    width: 160px;
    outline: none;
    transition: var(--transition);
}

#global-timezone:focus {
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Controls */
.av-controls {
    background: #fff;
    padding-top: 20px;
    flex-shrink: 0;
}

.av-progress-group {
    margin-bottom: 16px;
}

.av-time-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.av-progress-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.av-seekbar {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.av-seekbar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
}

.av-control-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.av-footer-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.av-play-btn {
    background: var(--accent-light);
    color: var(--accent);
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.av-play-btn:hover {
    background: var(--accent);
    color: white;
}

.av-speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.av-speed-control select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f8fafc;
    font-weight: 500;
}

.av-footer-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.av-mute-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
}

.current-frame-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.current-frame-box label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.current-frame-box span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace;
}

.av-day-alerts {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.av-alert-item {
    position: relative;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.av-alert-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-color: var(--accent);
}

.av-alert-time {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
}

.av-alert-msg {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.av-alert-type {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    background: transparent;
    padding: 0;
    border-radius: 0;
    width: auto;
}


.alert-image-frame {
    box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.5) !important;
    animation: modalAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.alert-details-row span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.alert-details-row i {
    color: var(--accent);
    opacity: 0.8;
}

.btn-av-alert-img {
    background: white !important;
    border-radius: 50% !important;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.btn-av-alert-img:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light) !important;
    transform: scale(1.1);
}

#alert-image-el {
    transition: transform 0.3s ease;
}

.alert-image-container:hover #alert-image-el {
    transform: scale(1.02);
}

#alert-image-el {
    transition: transform 0.3s ease;
}

.alert-image-container:hover #alert-image-el {
    transform: scale(1.02);
}
/* --- Pagination Premium Styles ------------------ */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    border-top: 1px solid #f1f5f9;
    background: white;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.pagination-range {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pag-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 10px;
}

.pag-btn:hover:not(:disabled) {
    color: #1e293b;
    background: #f1f5f9;
}

.pag-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.pag-status {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    margin: 0 12px;
}

/* ─── Column Filtering & Nice Table Styles ─────── */
.table-container {
    padding: 0;
    margin: 0;
    flex: 1;
    overflow: auto;
}

.nice-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.nice-table th {
    text-align: left;
    padding: 12px 16px;
    background: white;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top: 1px solid #e2e8f0;
    border-bottom: 2px solid #f1f5f9;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.nice-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #f8fafc;
    font-size: 13px;
    font-weight: 400;
    color: #1e293b;
    vertical-align: middle;
}

.time-label {
    font-weight: 400;
    color: #475569;
    white-space: nowrap;
}

.camera-label {
    font-weight: 400;
    color: #1e293b;
    white-space: nowrap;
}

.event-label {
    font-weight: 400;
    color: #334155;
    font-size: 13px;
}

.message-label {
    font-weight: 400;
    color: #64748b;
    font-size: 13px;
    max-width: 250px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-row {
    background: white;
}

.filter-row th {
    padding: 0px 12px 10px 12px !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

.filter-input {
    width: 100%;
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #475569;
    transition: all 0.2s ease;
    outline: none;
    font-weight: 400;
}

.filter-input::placeholder {
    color: #94a3b8;
    opacity: 0.6;
}

.filter-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
    background: white;
}

/* --- Category Tag Styles ----------------------- */
.category-tag {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    background: #f1f5f9;
    color: #475569;
}

.category-tag.safety, 
.category-tag.safety-violation {
    background: #dcfce7;
    color: #166534;
}
