* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f5f7fb; color: #1a1a2e; display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: 260px;
    min-width: 260px;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    overflow-y: auto;
}
.logo { padding: 0 20px 20px; font-weight: bold; font-size: 18px; color: #60a5fa; }
.nav-item {
    display: flex; align-items: center; padding: 12px 20px; color: #cbd5e1; text-decoration: none; gap: 12px; cursor: pointer;
}
.nav-item:hover, .nav-item.active { background: #1e293b; color: white; border-left: 3px solid #f97316; }
.footer { margin-top: auto; padding: 20px; font-size: 12px; color: #64748b; }

.main { flex: 1; overflow-y: auto; padding: 24px; }
.section { display: none; }
.section.active { display: block; }

.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.stats-grid, .stats-row { display: flex; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.stat-card, .badge {
    background: white; padding: 16px 20px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.stat-card h3 { font-size: 28px; margin-bottom: 4px; }
.badge { padding: 6px 12px; border-radius: 20px; font-size: 13px; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.live { background: #dcfce7; color: #166534; margin-left: 10px; font-size: 12px; }

.card { background: white; padding: 20px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin: 16px 0; }
.table-container { background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #e2e8f0; }
th { background: #f8fafc; font-weight: 600; }

.btn-primary { background: #f97316; color: white; border: none; padding: 10px 18px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-primary:hover { background: #ea580c; }
button { background: #3b82f6; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }

.ai-watching {
    position: fixed;
    top: 16px;
    right: 24px;
    background: rgba(15, 23, 42, 0.9);
    color: #4ade80;
    padding: 8px 16px;
    border-radius: 30px;
    z-index: 100;
    font-size: 13px;
}

@media (max-width: 768px) {
    body { flex-direction: column; }
    .sidebar { width: 100%; min-width: 100%; height: auto; max-height: 200px; }
    .main { padding: 16px; }
    .ai-watching { top: 8px; right: 8px; font-size: 11px; padding: 6px 10px; }
    .stat-card { min-width: 140px; }
}
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid #22c55e;
}
.ai-pulse {
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1.4); opacity: 0.7; box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.ai-watching.error { color: #f87171; border-color: #ef4444; }
.ai-watching.error .ai-pulse { background: #ef4444; }
.ai-watching.healing { color: #fbbf24; border-color: #f59e0b; }
/* Mobile friendly */
@media (max-width: 768px) {
    body { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px 0;
    }
    .sidebar nav { display: flex; }
    .nav-item { padding: 10px 14px; white-space: nowrap; font-size: 13px; }
    .main { padding: 12px; }
    .header-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .stats-grid, .stats-row { flex-direction: column; }
    .card, .table-container { overflow-x: auto; }
    table { font-size: 13px; }
    .ai-watching { top: 8px; right: 8px; font-size: 12px; padding: 6px 10px; }
    .modal-content { width: 95%; margin: 10px; }
    input, textarea, select { font-size: 16px; } /* prevent zoom on iOS */
}

.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; z-index: 1000; }
.modal.show { display: flex; }
.modal-content { background: white; padding: 24px; border-radius: 12px; width: 500px; max-width: 90%; }
textarea, input, select { width: 100%; padding: 10px; margin: 8px 0; border: 1px solid #cbd5e1; border-radius: 6px; }
