:root {
    --bg-body: #f8f4f9;
    --bg-sidebar: #6b7280;
    --bg-card: #ffffff;
    --bg-card-alt: #fdf2f8;
    --bg-input: #fce7f3;
    --border-color: #e5e7eb;
    --border-dark: #d1d5db;
    --text-primary: #1f2937;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --text-sidebar: #ffffff;
    --accent-green: #ec4899;
    --accent-green-light: #fce7f3;
    --accent-blue: #ec4899;
    --accent-blue-light: #fce7f3;
    --accent-purple: #d946ef;
    --accent-purple-light: #fae8ff;
    --accent-orange: #ec4899;
    --accent-orange-light: #fce7f3;
    --accent-red: #f43f5e;
    --accent-red-light: #ffe4e6;
    --accent-cyan: #ec4899;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 4px rgba(0,0,0,0.08);
    --radius: 4px;
    --sidebar-width: 180px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.4;
}

.app-container { display: flex; min-height: 100vh; }

/* Sidebar - compact */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header { padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.1); }

.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-purple));
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.logo-text { font-size: 16px; font-weight: 700; color: white; }

.sidebar-nav { flex: 1; padding: 8px; }
.nav-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 12px;
    margin-bottom: 2px;
    transition: background 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.1); }
.nav-item.active { background: var(--accent-green); color: white; }
.nav-icon { font-size: 14px; }

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 11px;
}
.connection-status { display: flex; align-items: center; gap: 6px; color: var(--text-sidebar); margin-bottom: 6px; }
.connection-dot { width: 6px; height: 6px; border-radius: 50%; background: #10b981; }
.logout-link { color: var(--text-light); text-decoration: none; font-size: 11px; }
.logout-link:hover { color: var(--accent-red); }

/* Main */
.main-content { flex: 1; margin-left: var(--sidebar-width); }

/* Top Bar */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 50;
}
.top-bar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 14px; font-weight: 600; color: white; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.last-update { font-size: 11px; color: var(--text-light); }
.controls { display: flex; gap: 6px; }

/* Status Badge */
.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px; font-weight: 500;
}
.status-badge.running { background: #d1fae5; color: #059669; }
.status-badge.stopped { background: var(--accent-red-light); color: var(--accent-red); }
.status-dot { width: 5px; height: 5px; border-radius: 50%; }
.status-badge.running .status-dot { background: #059669; }
.status-badge.stopped .status-dot { background: var(--accent-red); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 10px;
    border: none; border-radius: var(--radius);
    font-size: 11px; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
}
.btn-primary { background: var(--accent-green); color: white; }
.btn-primary:hover:not(:disabled) { background: #db2777; }
.btn-danger { background: var(--accent-red); color: white; }
.btn-danger:hover:not(:disabled) { background: #e11d48; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Dashboard */
.dashboard-content { padding: 10px; }

/* Stats Row - compact inline */
.stats-row {
    display: flex; gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px 12px;
    display: flex; align-items: center; gap: 8px;
    min-width: 120px;
    flex: 1;
}
.stat-icon { font-size: 16px; }
.stat-info { flex: 1; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.stat-card.accent-green .stat-value { color: var(--accent-green); }
.stat-card.accent-blue .stat-value { color: var(--accent-blue); }
.stat-card.accent-purple .stat-value { color: var(--accent-purple); }
.stat-card.accent-orange .stat-value { color: var(--accent-orange); }
.stat-card.accent-cyan .stat-value { color: var(--accent-cyan); }
.stat-trend { font-size: 10px; font-weight: 500; }
.stat-trend.up { color: #059669; }
.stat-trend.down { color: var(--accent-red); }

/* Dashboard Grid - tight */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 10px;
}

/* Panels */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card-alt);
}
.panel-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--text-primary);
}
.panel-icon { font-size: 12px; }
.panel-badge {
    background: var(--accent-blue);
    color: white;
    font-size: 10px; font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
}
.panel-content {
    padding: 8px;
    max-height: 300px;
    overflow-y: auto;
}
.panel-content::-webkit-scrollbar { width: 4px; }
.panel-content::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 2px; }

/* Panel positions */
.panel-chart { grid-column: 1; grid-row: 1; }
.panel-actions { grid-column: 2; grid-row: 1; }
.panel-feed { grid-column: 1; grid-row: 2; }
.panel-flowpass { grid-column: 2; grid-row: 2; }
.panel-users { grid-column: 1 / -1; grid-row: 3; }

/* Chart */
.chart-container { height: 180px; padding: 4px; }

/* Actions */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; }
.action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 4px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-primary);
}
.action-btn:hover { background: var(--bg-input); border-color: var(--accent-green); }
.action-icon { font-size: 16px; }
.action-label { font-size: 10px; font-weight: 500; }

.action-result {
    padding: 4px 6px;
    border-radius: var(--radius);
    font-size: 10px;
    margin-bottom: 6px;
    display: none;
}
.action-result.show { display: block; }
.action-result.success { background: var(--accent-green-light); color: var(--accent-green); }
.action-result.error { background: var(--accent-red-light); color: var(--accent-red); }
.action-result.loading { background: var(--bg-input); color: var(--text-muted); }

.sim-info { border-top: 1px solid var(--border-color); padding-top: 6px; }
.sim-info-row {
    display: flex; justify-content: space-between;
    padding: 2px 0;
    font-size: 10px; color: var(--text-muted);
}
.sim-info-value { font-weight: 600; color: var(--accent-cyan); }

/* Live indicator */
.live-indicator {
    width: 6px; height: 6px;
    background: var(--accent-red);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
    margin-left: 4px;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Activity Feed */
.activity-item {
    display: flex; gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    width: 24px; height: 24px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
}
.activity-icon.user { background: var(--accent-blue-light); }
.activity-icon.flow { background: var(--accent-purple-light); }
.activity-icon.operator { background: var(--accent-orange-light); }
.activity-icon.slot { background: var(--accent-cyan); color: white; }
.activity-icon.error { background: var(--accent-red-light); }
.activity-icon.success { background: var(--accent-green-light); }
.activity-content { flex: 1; min-width: 0; }
.activity-title {
    font-size: 11px; font-weight: 500; color: var(--text-primary);
    display: flex; align-items: center; gap: 4px;
}
.activity-tag {
    font-size: 9px; padding: 1px 4px;
    border-radius: 3px; font-weight: 600;
}
.activity-tag.success { background: #d1fae5; color: #059669; }
.activity-tag.failed { background: var(--accent-red-light); color: var(--accent-red); }
.activity-details { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-time { font-size: 9px; color: var(--text-light); }

/* FlowPass Panel */
.flowpass-status { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-muted); }
.fp-dot { width: 5px; height: 5px; border-radius: 50%; }
.fp-dot.online { background: #059669; }
.fp-dot.offline { background: var(--accent-red); }

.fp-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; }
.fp-stat {
    background: var(--bg-card-alt);
    border-radius: var(--radius);
    padding: 6px;
    text-align: center;
}
.fp-stat-value { font-size: 14px; font-weight: 700; color: var(--accent-cyan); }
.fp-stat-label { font-size: 9px; color: var(--text-muted); }

.fp-recent h4 { font-size: 9px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.fp-recent-list { display: flex; flex-direction: column; gap: 3px; }
.fp-recent-item {
    display: flex; align-items: center; gap: 4px;
    padding: 4px;
    background: var(--bg-card-alt);
    border-radius: var(--radius);
    font-size: 10px; color: var(--text-secondary);
}
.fp-recent-icon { font-size: 10px; }
.fp-recent-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-recent-empty { text-align: center; color: var(--text-muted); font-size: 10px; padding: 10px; }

/* Tabs */
.panel-tabs { display: flex; gap: 2px; }
.tab-btn {
    padding: 4px 8px;
    background: transparent; border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 10px; font-weight: 500;
    cursor: pointer;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-card-alt); }
.tab-btn.active { color: var(--accent-green); background: var(--accent-green-light); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Entity List */
.entity-list { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; }
.entity-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px;
    background: var(--bg-card-alt);
    border-radius: var(--radius);
}
.entity-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; color: white;
}
.entity-avatar.operator { background: linear-gradient(135deg, var(--accent-orange), var(--accent-red)); }
.entity-info { flex: 1; min-width: 0; }
.entity-name { font-size: 11px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entity-meta { font-size: 9px; color: var(--text-muted); display: flex; gap: 6px; }
.entity-stat { font-size: 10px; color: #059669; font-weight: 600; }

/* Empty State */
.empty-state { text-align: center; padding: 16px 8px; color: var(--text-muted); }
.empty-state.small { padding: 10px; }
.empty-state-icon { font-size: 20px; margin-bottom: 4px; opacity: 0.5; }
.empty-state-text { font-size: 10px; }

/* Select */
.select-small {
    padding: 4px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 10px;
}

/* Toast */
.toast-container {
    position: fixed; bottom: 12px; right: 12px;
    z-index: 1000;
    display: flex; flex-direction: column; gap: 6px;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px 12px;
    display: flex; align-items: center; gap: 8px;
    box-shadow: var(--shadow-md);
    font-size: 12px;
}
.toast.success { border-left: 3px solid #059669; }
.toast.error { border-left: 3px solid var(--accent-red); }

/* Panel highlight */
.panel.highlight { box-shadow: 0 0 0 2px var(--accent-green); }

/* Responsive */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .panel-chart, .panel-actions, .panel-feed, .panel-flowpass, .panel-users { grid-column: 1; grid-row: auto; }
}
@media (max-width: 768px) {
    .sidebar { width: 50px; }
    .sidebar-header .logo-text, .sidebar-nav span:not(.nav-icon), .sidebar-footer .connection-text { display: none; }
    .main-content { margin-left: 50px; }
    .nav-item { justify-content: center; padding: 10px; }
    .stats-row { flex-direction: column; }
}
