/* ============================
   OmniMedia Admin — Design System
   ============================ */

:root {
    --bg-primary: #080b10;
    --bg-secondary: #0d1117;
    --bg-card: #121820;
    --bg-card-hover: #171f2a;
    --bg-input: #0a0f16;

    --text-primary: #e8ece8;
    --text-secondary: #7a8a7a;
    --text-muted: #3d4d3d;

    --accent-blue: #10b981;
    --accent-blue-glow: rgba(16, 185, 129, 0.25);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.25);
    --accent-purple: #10b981;
    --accent-purple-glow: rgba(16, 185, 129, 0.25);
    --accent-orange: #10b981;
    --accent-orange-glow: rgba(16, 185, 129, 0.25);
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.25);

    --border-color: rgba(16, 185, 129, 0.08);
    --border-hover: rgba(16, 185, 129, 0.18);

    --sidebar-width: 240px;
    --topbar-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;

    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.1);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================
   Sidebar
   ============================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
    color: var(--accent-blue);
    filter: drop-shadow(0 0 8px var(--accent-blue-glow));
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #10b981, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.version-badge {
    font-size: 10px;
    padding: 2px 8px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-blue);
    border-radius: 12px;
    font-weight: 500;
}

.nav-menu {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

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

.nav-item.active {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-blue);
    box-shadow: inset 3px 0 0 var(--accent-blue);
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green-glow);
}

.status-dot.offline {
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red-glow);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ============================
   Main Content
   ============================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================
   Top Bar
   ============================ */
.topbar {
    height: var(--topbar-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-config {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================
   Pages
   ============================ */
.page {
    display: none;
    padding: 24px;
    flex: 1;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* ============================
   Stats Grid
   ============================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.blue {
    background: var(--accent-blue-glow);
}

.stat-icon.green {
    background: var(--accent-green-glow);
}

.stat-icon.purple {
    background: var(--accent-purple-glow);
}

.stat-icon.orange {
    background: var(--accent-orange-glow);
}

.stat-icon.cyan {
    background: rgba(127, 219, 255, 0.15);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* ============================
   Cards
   ============================ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.card-body {
    padding: 20px;
}

.mt {
    margin-top: 16px;
}

/* ============================
   Tables
   ============================ */
.info-table {
    width: 100%;
}

.info-table td {
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

.info-table td.label {
    color: var(--text-secondary);
    width: 120px;
}

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

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.data-table td {
    padding: 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}

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

.table-responsive {
    overflow-x: auto;
}

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

/* ============================
   Progress Bars
   ============================ */
.progress-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
}

.progress-header span:first-child {
    color: var(--text-secondary);
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.blue {
    background: linear-gradient(90deg, var(--accent-blue), #60a5fa);
}

.progress-fill.green {
    background: linear-gradient(90deg, var(--accent-green), #34d399);
}

.progress-fill.purple {
    background: linear-gradient(90deg, var(--accent-purple), #a78bfa);
}

.progress-fill.orange {
    background: linear-gradient(90deg, var(--accent-orange), #fbbf24);
}

/* ============================
   Forms & Buttons
   ============================ */
.input-field {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.input-field:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.input-field.input-sm {
    padding: 6px 10px;
    font-size: 12px;
    width: auto;
    min-width: 80px;
}

select.input-field {
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 4px 12px var(--accent-blue-glow);
}

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

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px var(--accent-red-glow);
}

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

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

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

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

.form-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

/* ============================
   Feature Grid (AI Page)
   ============================ */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.feature-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
}

.feature-item:hover {
    border-color: var(--accent-purple);
    box-shadow: 0 0 20px var(--accent-purple-glow);
    transform: translateY(-2px);
}

.feature-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 12px;
}

.feature-item h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.feature-item p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-ready {
    background: var(--accent-green-glow);
    color: var(--accent-green);
}

.badge-pending {
    background: rgba(255, 176, 46, 0.15);
    color: #ffb02e;
}

.badge-proto {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: color-mix(in srgb, var(--proto-color) 18%, transparent);
    color: var(--proto-color);
    border: 1px solid color-mix(in srgb, var(--proto-color) 30%, transparent);
}

/* ============================
   AI Analytics — Config Sections
   ============================ */
.config-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-top: 12px;
    overflow: hidden;
    transition: var(--transition);
}

.config-section:hover {
    border-color: var(--border-hover);
}

.config-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: var(--transition);
    user-select: none;
}

.config-section-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.config-section-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.config-section-header small {
    font-size: 11px;
    color: var(--text-muted);
}

.config-section-body {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.2s ease;
}

/* Dynamic form items (crosslines, zones) */
.dynamic-item {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.dynamic-item:last-child {
    border-bottom: none;
}

.dynamic-item .form-group {
    flex: 1;
    min-width: 0;
}

.dynamic-item .form-group label {
    font-size: 10px;
    margin-bottom: 4px;
}

.dynamic-item .input-field {
    padding: 6px 10px;
    font-size: 12px;
}

.btn-remove {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    white-space: nowrap;
    margin-bottom: 1px;
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Event Log */
.event-log {
    max-height: 300px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 11px;
    line-height: 1.6;
    padding: 12px 16px;
}

.event-log::-webkit-scrollbar {
    width: 6px;
}

.event-log::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.event-log-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-family: inherit;
    font-size: 13px;
}

.event-log-entry {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    gap: 8px;
}

.event-log-time {
    color: var(--text-muted);
    flex-shrink: 0;
}

.event-log-type {
    font-weight: 600;
    flex-shrink: 0;
    min-width: 80px;
}

.event-log-type.crossline {
    color: var(--accent-orange);
}

.event-log-type.crowding {
    color: var(--accent-red);
}

.event-log-type.detection {
    color: var(--accent-blue);
}

.event-log-type.info {
    color: var(--accent-green);
}

.event-log-msg {
    color: var(--text-secondary);
}

/* Pipeline status badges */
.pipeline-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
}

.pipeline-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.pipeline-status.running .dot {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green-glow);
}

.pipeline-status.stopped .dot {
    background: var(--text-muted);
}

.pipeline-status.running {
    color: var(--accent-green);
}

.pipeline-status.stopped {
    color: var(--text-muted);
}

/* Feature badges */
.badge-crossline {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

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

/* Auto-refresh toggle */
.auto-refresh-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.auto-refresh-label input[type="checkbox"] {
    display: none;
}

.auto-refresh-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.auto-refresh-dot.active {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green-glow);
    animation: pulse 1.5s infinite;
}

/* Event counter */
.event-counter {
    font-size: 11px;
    color: var(--text-muted);
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    font-weight: 500;
}

/* ============================
   Pipeline Builder
   ============================ */

/* Step indicator bar */
.pipeline-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 16px 0 24px;
    margin-bottom: 16px;
}

.pipeline-steps .step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.pipeline-steps .step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}

.pipeline-steps .step.active .step-num {
    background: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

.pipeline-steps .step.done .step-num {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}

.pipeline-steps .step-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pipeline-steps .step.active .step-label {
    color: var(--accent-purple);
}

.pipeline-steps .step.done .step-label {
    color: var(--accent-green);
}

.pipeline-steps .step-line {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0 8px;
    margin-bottom: 20px;
}

/* Step panels */
.step-panel {
    display: none;
}

.step-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.step-panel h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text-primary);
}

.step-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 16px;
}

.step-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Node selector grid */
.node-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.node-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    user-select: none;
}

.node-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
}

.node-card.selected {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.15);
}

.node-card input[type="radio"],
.node-card input[type="checkbox"] {
    display: none;
}

.node-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.node-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.node-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* BA config panels */
.ba-config {
    margin-top: 12px;
    padding: 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.ba-config h5 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 10px;
    color: var(--text-primary);
}

/* Btn large variant */
.btn-lg {
    padding: 12px 32px;
    font-size: 15px;
}

/* ============================
   Zone Drawer
   ============================ */
.zone-drawer {
    margin-top: 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.zone-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.zone-drawer-header h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.draw-toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
}

.draw-tool-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.draw-tool-btn.active {
    background: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
}

.draw-separator {
    color: rgba(255, 255, 255, 0.15);
    font-size: 14px;
}

.zone-canvas-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0a0a0a;
    overflow: hidden;
}

.zone-canvas-wrap video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.zone-canvas-wrap canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.zone-video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 8px;
    font-size: 13px;
    pointer-events: none;
}

.zone-video-placeholder span {
    font-size: 36px;
}

.zone-status-bar {
    display: flex;
    justify-content: space-between;
    padding: 6px 14px;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.drawn-items-list {
    padding: 8px 14px;
}

.drawn-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 12px;
}

.drawn-item:last-child {
    border-bottom: none;
}

.drawn-item-icon {
    font-size: 14px;
}

.drawn-item-label {
    flex: 1;
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 11px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* ============================
   Toast Notifications
   ============================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 3s forwards;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    max-width: 360px;
}

.toast-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.3);
}

.toast-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}

.toast-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.3);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(50px);
    }
}

/* ============================
   Stream Grid View
   ============================ */
.view-toggle {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 30px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.view-toggle-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.view-toggle-btn.active {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.12);
}

.streams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
}

.stream-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

.stream-card:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.12);
    transform: translateY(-2px);
}

.stream-card-video {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

.stream-card-video video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.stream-card-video .video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 12px;
    gap: 8px;
    background: linear-gradient(135deg, rgba(10, 14, 23, 0.95), rgba(26, 34, 51, 0.95));
}

.stream-card-video .video-placeholder span {
    font-size: 32px;
    opacity: 0.4;
}

.stream-card-video .live-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.stream-card-video .live-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.stream-card-video .stream-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stream-card:hover .stream-overlay {
    opacity: 1;
}

.stream-overlay-actions {
    display: flex;
    gap: 6px;
}

.stream-overlay-actions button {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.stream-overlay-actions button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.stream-card-info {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stream-card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.stream-card-title h4 {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stream-card-title .badge {
    flex-shrink: 0;
}

.stream-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.stream-card-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stream-card-dual {
    display: flex;
    gap: 2px;
    background: #000;
}

.stream-card-dual .stream-card-video--half {
    flex: 1;
    min-width: 0;
}

.stream-card-dual .stream-card-video--half .live-badge {
    font-size: 8px;
    padding: 2px 6px;
    top: 6px;
    left: 6px;
}

.stream-card-dual .stream-card-video--half .video-placeholder span {
    font-size: 22px;
}

.stream-card-dual .stream-card-video--half .video-placeholder {
    font-size: 10px;
}

.stream-card-protocols {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .api-config {
        display: none;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

/* ═══════════════════════════════════════════ */
/* Pipeline Flow Diagram — Hub & Spoke        */
/* ═══════════════════════════════════════════ */
.flow-hub {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    min-height: 200px;
    position: relative;
    padding: 20px 0;
}

/* ── Left: Input Sources ── */
.flow-inputs {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding-right: 0;
}

.flow-input-card {
    display: flex;
    align-items: center;
    gap: 0;
}

.flow-cam-box {
    background: var(--bg-card);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 170px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.flow-cam-box:hover {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.flow-cam-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: linear-gradient(135deg, #10b981, #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.flow-cam-info {
    display: flex;
    flex-direction: column;
}

.flow-cam-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.flow-cam-meta {
    font-size: 10px;
    color: var(--text-muted);
}

/* SVG Connectors overlay */
.flow-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.flow-svg .flow-line {
    stroke-dasharray: 6 4;
    animation: flowDash 1.5s linear infinite;
}

@keyframes flowDash {
    to {
        stroke-dashoffset: -10;
    }
}

/* ── Center: Server + AI below ── */
.flow-server-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    padding: 0 8px;
    gap: 0;
}

.flow-server-bar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    box-shadow: 0 0 28px rgba(16, 185, 129, 0.25);
    flex-shrink: 0;
}

.flow-server-bar .server-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.3));
}

.flow-server-bar .server-label {
    font-size: 7px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    writing-mode: horizontal-tb;
}

/* Vertical connector: server → AI */
.flow-vline {
    width: 2px;
    height: 28px;
    background: rgba(16, 185, 129, 0.3);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.flow-vline::after {
    content: '';
    position: absolute;
    left: 0;
    top: -50%;
    width: 100%;
    height: 50%;
    background: linear-gradient(180deg, transparent, rgba(16, 185, 129, 0.8), transparent);
    animation: flowPulseDown 2.5s infinite;
}

.flow-vline.inactive {
    background: rgba(107, 114, 128, 0.15);
}

.flow-vline.inactive::after {
    animation: none;
    background: transparent;
}

@keyframes flowPulseDown {
    0% {
        top: -50%;
    }

    100% {
        top: 100%;
    }
}

/* AI box below server */
.flow-ai-box {
    background: var(--bg-card);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
    flex-shrink: 0;
    min-width: 200px;
}

.flow-ai-box:hover {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.flow-ai-box.inactive {
    opacity: 0.4;
    border-color: rgba(107, 114, 128, 0.1);
}

.flow-ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.flow-ai-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.flow-ai-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.flow-ai-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
}

.flow-ai-meta {
    font-size: 9px;
    color: var(--text-muted);
}

.flow-ai-live-badge {
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    animation: pulse 1.5s infinite;
    flex-shrink: 0;
}

.flow-ai-count-badge {
    background: rgba(16, 185, 129, 0.85);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

.flow-ai-count-label {
    font-size: 8px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    flex-shrink: 0;
    margin-right: 4px;
}

/* Pipeline node chain */
.flow-ai-nodes {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(16, 185, 129, 0.04);
    border: 1px solid rgba(16, 185, 129, 0.08);
    border-radius: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.flow-ai-nodes::-webkit-scrollbar {
    display: none;
}

.flow-ai-node-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.12);
    border-radius: 5px;
    padding: 3px 6px;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.flow-ai-node-item:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.25);
}

.flow-ai-node-icon {
    font-size: 10px;
}

.flow-ai-node-name {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.flow-ai-node-meta {
    font-size: 8px;
    color: var(--text-muted);
    white-space: nowrap;
}

.flow-ai-node-arrow {
    font-size: 9px;
    color: rgba(16, 185, 129, 0.4);
    flex-shrink: 0;
}

/* AI Engine footer */
.flow-ai-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 2px;
}

.flow-ai-update-hint {
    font-size: 8px;
    color: rgba(16, 185, 129, 0.55);
    letter-spacing: 0.3px;
}

/* AI Output card accent */
.flow-out-ai {
    border-color: rgba(139, 92, 246, 0.2);
}

.flow-out-ai:hover {
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.15);
}

/* ── Right: Output Nodes ── */
.flow-outputs {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding-left: 0;
}

.flow-output-card {
    display: flex;
    align-items: center;
    gap: 0;
}


.flow-out-box {
    background: var(--bg-card);
    border: 1px solid rgba(16, 185, 129, 0.12);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 160px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.flow-out-box:hover {
    border-color: rgba(16, 185, 129, 0.35);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.1);
}

.flow-out-box.inactive {
    opacity: 0.4;
    border-color: rgba(107, 114, 128, 0.1);
}

.flow-out-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.flow-out-info {
    display: flex;
    flex-direction: column;
}

.flow-out-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
}

.flow-out-meta {
    font-size: 9px;
    color: var(--text-muted);
}

/* ── Summary bar below diagram ── */
.flow-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 10px 0 0;
    font-size: 11px;
    color: var(--text-secondary);
}

.flow-summary-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.flow-summary-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}

.flow-summary-dot.off {
    background: #4b5563;
}

@keyframes flowPulseR {
    0% {
        left: -50%;
    }

    100% {
        left: 100%;
    }
}:root {
  /* ── Color Palette ── */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.25);
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-pink: #ec4899;

  --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --gradient-accent: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gradient-warm: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --gradient-green: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);

  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-blue: 0 0 20px rgba(59, 130, 246, 0.15);
  --shadow-glow-green: 0 0 20px rgba(16, 185, 129, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Background noise ─────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(139, 92, 246, 0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ───────────────────────────────────────────── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Header ───────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  backdrop-filter: blur(16px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  width: 42px;
  height: 42px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-glow-blue);
}

.header-title {
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 6px 14px;
  background: var(--bg-glass);
  border-radius: 999px;
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.disconnected {
  background: var(--accent-red);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.refresh-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ── Summary Cards ────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  backdrop-filter: blur(12px);
}

.summary-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.summary-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.summary-card.blue::after { background: var(--gradient-primary); }
.summary-card.green::after { background: var(--gradient-green); }
.summary-card.orange::after { background: var(--gradient-warm); }
.summary-card.purple::after { background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink)); }

.card-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 8px;
}

.card-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.card-value.blue { color: var(--accent-blue); }
.card-value.green { color: var(--accent-green); }
.card-value.orange { color: var(--accent-orange); }
.card-value.purple { color: var(--accent-purple); }

.card-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Charts Grid ──────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  backdrop-filter: blur(12px);
  transition: border-color var(--transition-normal);
}

.chart-card:hover {
  border-color: var(--border-hover);
}

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

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-controls {
  display: flex;
  gap: 6px;
}

.chart-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}

.chart-btn:hover, .chart-btn.active {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.chart-container {
  position: relative;
  height: 280px;
}

/* ── Distribution Grid ────────────────────────────────── */
.distribution-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.donut-container {
  position: relative;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Topic Filter Bar ─────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.filter-select {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  min-width: 200px;
  transition: border-color var(--transition-fast);
  font-family: inherit;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.filter-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.filter-date {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
}

.filter-date:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* ── Events Table ─────────────────────────────────────── */
.events-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(12px);
  margin-bottom: 24px;
}

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

.events-title {
  font-size: 1rem;
  font-weight: 600;
}

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

.events-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-glass);
}

.events-table tbody tr {
  transition: background var(--transition-fast);
}

.events-table tbody tr:hover {
  background: var(--bg-glass-hover);
}

.events-table tbody td {
  padding: 12px 16px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

/* ── Event type badges ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.badge-crossline {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-crowding {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-intrusion {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-area_enter {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-area_exit {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.25);
}

.badge-unknown {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(100, 116, 139, 0.25);
}

/* ── Object class badges ──────────────────────────────── */
.class-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
}

.class-Person {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
}

.class-Vehicle {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-orange);
}

/* ── Topics List ──────────────────────────────────────── */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  transition: all var(--transition-normal);
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.topic-card:hover {
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-glow-blue);
  transform: translateY(-1px);
}

.topic-card.active {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.05);
}

.topic-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  word-break: break-all;
}

.topic-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.topic-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topic-count {
  color: var(--accent-blue);
  font-weight: 600;
}

/* ── Section titles ───────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .icon {
  font-size: 1.1rem;
}

/* ── Empty state ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.88rem;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ── Loading animation ────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

.loading {
  background: linear-gradient(90deg,
    var(--bg-glass) 0px,
    rgba(255,255,255,0.06) 40px,
    var(--bg-glass) 80px
  );
  background-size: 200px;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* ── Fade-in animation ────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

/* ── New event highlight ──────────────────────────────── */
@keyframes highlight-row {
  0% { background: rgba(59, 130, 246, 0.2); }
  100% { background: transparent; }
}

.event-new {
  animation: highlight-row 2s ease forwards;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1200px) {
  .charts-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-container { padding: 12px; }
  .summary-grid { grid-template-columns: 1fr; }
  .distribution-grid { grid-template-columns: 1fr; }
  .topics-grid { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; gap: 12px; }
  .filter-bar { flex-direction: column; align-items: stretch; }

  .events-table { font-size: 0.75rem; }
  .events-table thead th,
  .events-table tbody td { padding: 8px 10px; }
}

/* ── Scrollbar styling ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Live indicator ───────────────────────────────────── */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-red);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-red);
  border-radius: 50%;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

/* ── Footer ───────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.app-footer a {
  color: var(--accent-blue);
  text-decoration: none;
}

/* ============================
   Light Theme (White & Black)
   ============================ */
:root[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #f8fafc;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    
    /* Monochrome accents for B&W feel */
    --accent-blue: #334155;
    --accent-blue-glow: rgba(51, 65, 85, 0.15);
    --accent-green: #0f172a;
    --accent-green-glow: rgba(15, 23, 42, 0.15);
    --accent-purple: #475569;
    --accent-purple-glow: rgba(71, 85, 105, 0.15);
    --accent-orange: #64748b;
    --accent-orange-glow: rgba(100, 116, 139, 0.15);
}

:root[data-theme="light"] .stats-grid .stat-card {
    border: 1px solid var(--border-color);
}
:root[data-theme="light"] .card {
    border: 1px solid var(--border-color);
}
:root[data-theme="light"] .data-table th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}
:root[data-theme="light"] .data-table td {
    border-bottom: 1px solid var(--border-color);
}
:root[data-theme="light"] .input-field,
:root[data-theme="light"] .select-field {
    border: 1px solid var(--border-color);
}
