/* OPTIMAL ENSEMBLE — Dashboard */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg: #08090a;
    --bg-panel: #0f1011;
    --bg-surface: #191a1b;
    --bg-elevated: #1f2022;
    --text: #f7f8f8;
    --text-secondary: #d0d6e0;
    --text-tertiary: #8a8f98;
    --text-muted: #62666d;
    --red: #c0392b;
    --red-dark: #8b1a2b;
    --red-glow: rgba(192,57,59,0.3);
    --blue: #3b82f6;
    --green: #10b981;
    --purple: #8b5cf6;
    --yellow: #f59e0b;
    --border: rgba(255,255,255,0.08);
    --border-subtle: rgba(255,255,255,0.05);
    --radius: 8px;
    --radius-card: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv01', 'ss03';
}

/* ====== SIDEBAR ====== */
.sidebar {
    width: 240px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
}
.sidebar-brand {
    padding: 20px 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 1.5rem; }
.brand-text { display: flex; flex-direction: column; }
.brand-name {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 3px;
    color: var(--text);
}
.brand-sub {
    font-size: 0.6rem;
    letter-spacing: 4px;
    color: var(--red);
    text-transform: uppercase;
}
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    padding: 0 8px;
    margin-bottom: 8px;
    display: block;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
}
.nav-item i { width: 18px; font-size: 0.9rem; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-item.active {
    color: var(--text);
    background: rgba(192,57,59,0.15);
    border: 1px solid rgba(192,57,59,0.2);
}
.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--red); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.8rem; font-weight: 600; }
.user-status { font-size: 0.65rem; color: var(--green); }

/* ====== MAIN ====== */
.main-content { flex: 1; padding: 0; overflow-y: auto; }

/* ====== TOPBAR ====== */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px; border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky; top: 0; z-index: 50;
}
.topbar-left { flex: 1; max-width: 480px; }
.search-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px 12px;
}
.search-box input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text); font-size: 0.85rem; font-family: var(--font);
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box i { color: var(--text-muted); font-size: 0.85rem; }
.search-kbd {
    font-family: var(--mono); font-size: 0.65rem;
    color: var(--text-muted); background: var(--bg-surface);
    padding: 2px 6px; border-radius: 4px;
}
.topbar-right { display: flex; gap: 8px; }
.topbar-btn {
    background: none; border: 1px solid var(--border);
    color: var(--text-tertiary); width: 36px; height: 36px;
    border-radius: var(--radius); cursor: pointer; position: relative;
    transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.topbar-btn:hover { color: var(--text); border-color: var(--text-muted); }
.notif-dot {
    position: absolute; top: 8px; right: 8px;
    width: 6px; height: 6px; border-radius: 50%; background: var(--red);
}

/* ====== PAGE HEADER ====== */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 24px 24px 0; flex-wrap: wrap; gap: 16px;
}
.page-title {
    font-size: 1.5rem; font-weight: 600; letter-spacing: -0.3px;
    color: var(--text); margin-bottom: 4px;
}
.page-subtitle { font-size: 0.85rem; color: var(--text-tertiary); }
.page-header-right { display: flex; gap: 8px; }

/* ====== BUTTONS ====== */
.btn {
    padding: 10px 18px; border-radius: var(--radius); font-size: 0.85rem;
    font-weight: 600; cursor: pointer; border: none; font-family: var(--font);
    display: flex; align-items: center; gap: 8px; transition: all 0.15s;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary {
    background: rgba(255,255,255,0.04); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* ====== STATS ROW ====== */
.stats-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
    padding: 24px;
}
.stat-card {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius-card); padding: 20px;
    display: flex; align-items: center; gap: 16px; position: relative;
}
.stat-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
    flex-shrink: 0;
}
.stat-icon-blue { background: rgba(59,130,246,0.15); color: #3b82f6; }
.stat-icon-green { background: rgba(16,185,129,0.15); color: #10b981; }
.stat-icon-yellow { background: rgba(245,158,11,0.15); color: #f59e0b; }
.stat-icon-red { background: rgba(239,68,68,0.15); color: #ef4444; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.72rem; color: var(--text-tertiary); margin-top: 2px; }
.stat-change {
    position: absolute; top: 12px; right: 12px;
    font-size: 0.65rem; font-weight: 600; padding: 2px 8px;
    border-radius: 20px; display: flex; align-items: center; gap: 3px;
}
.stat-change.up { color: var(--green); background: rgba(16,185,129,0.1); }
.stat-change.down { color: var(--red); background: rgba(239,68,68,0.1); }

/* ====== DASHBOARD GRID ====== */
.dashboard-grid {
    display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px;
    padding: 0 24px 16px;
}

/* ====== CARDS ====== */
.card {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius-card); overflow: hidden;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h2 {
    font-size: 0.9rem; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--text-secondary);
}
.card-header h2 i { color: var(--red); font-size: 0.85rem; }
.card-actions { display: flex; align-items: center; gap: 8px; }
.card-badge {
    font-size: 0.6rem; text-transform: uppercase; letter-spacing: 1px;
    padding: 3px 10px; border-radius: 20px; background: rgba(16,185,129,0.15); color: var(--green); font-weight: 600;
}
.card-btn {
    background: none; border: 1px solid var(--border); color: var(--text-muted);
    width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 0.75rem;
    transition: all 0.15s;
}
.card-btn:hover { color: var(--text); border-color: var(--text-muted); }
.card-link { font-size: 0.8rem; color: var(--red); text-decoration: none; font-weight: 500; }
.card-link:hover { text-decoration: underline; }

/* ====== NETWORK GRAPH ====== */
.network-body { padding: 12px; }
.network-graph { width: 100%; height: auto; display: block; }
.network-legend {
    display: flex; gap: 16px; padding: 8px 4px; flex-wrap: wrap;
}
.legend-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.7rem; color: var(--text-tertiary);
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ====== AGENTS LIST ====== */
.agents-list { padding: 8px; }
.agent-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border-radius: var(--radius);
    transition: background 0.15s; cursor: pointer;
}
.agent-item:hover { background: rgba(255,255,255,0.03); }
.agent-status {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-active { background: var(--green); box-shadow: 0 0 6px rgba(16,185,129,0.4); }
.status-warn { background: var(--yellow); box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.status-error { background: var(--red); box-shadow: 0 0 6px rgba(192,57,59,0.4); }
.agent-avatar {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0;
}
.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 0.8rem; font-weight: 600; display: block; }
.agent-desc { font-size: 0.7rem; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-metric { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }

/* ====== ACTIVITY ====== */
.activity-card { margin: 0 24px 24px; }
.activity-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; font-size: 0.8rem; flex-shrink: 0;
}
.activity-content { flex: 1; }
.activity-text { font-size: 0.82rem; color: var(--text-secondary); display: block; }
.activity-text strong { color: var(--text); }
.activity-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; display: block; }

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-brand .brand-text, .nav-item span, .nav-section-title, .sidebar-user .user-info { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .nav-item i { margin: 0; }
    .sidebar-brand { justify-content: center; }
    .brand-icon { margin: 0; }
    .stats-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
}
@media (max-width: 480px) {
    .main-content { padding: 0 0 80px; }
    .topbar { padding: 10px 12px; }
    .page-header { padding: 16px 12px 0; }
    .stats-row { padding: 12px; gap: 10px; }
    .dashboard-grid { padding: 0 12px 12px; }
    .activity-card { margin: 0 12px 12px; }
}