:root {
    --primary: #06B6D4;
    --primary-hover: #0891B2;
    --accent: #22C55E;
    --accent-hover: #16A34A;
    --bg-dark: #0F172A;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --border-light: rgba(255, 255, 255, 0.1);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    /* subtle gradient background */
    background: radial-gradient(circle at top right, rgba(6, 182, 212, 0.08), transparent 40%),
        radial-gradient(circle at bottom left, rgba(34, 197, 94, 0.08), transparent 40%),
        var(--bg-dark);
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Header */
header {
    padding: 1rem 1.5rem;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #64748B;
    transition: var(--transition);
}

.status-dot.connected {
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.status-dot.connecting {
    background-color: #EAB308;
    box-shadow: 0 0 8px #EAB308;
}

.status-dot.disconnected {
    background-color: #EF4444;
    box-shadow: 0 0 8px #EF4444;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition);
    color: #fff;
}

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

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

.btn.primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn.secondary:hover:not(:disabled) {
    background-color: rgba(6, 182, 212, 0.1);
}

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

.btn.accent:hover:not(:disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

/* Main Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.span-full {
    grid-column: 1 / -1;
}

.card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.5rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 500;
    word-break: break-all;
}

/* Charts */
.chart-container {
    flex: 1;
    min-height: 160px;
    width: 100%;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.5rem;
}

canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.current-metric {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: right;
}

.current-metric span {
    font-weight: 600;
    color: var(--primary);
    font-size: 1.2rem;
}

/* Lists */
.metric-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.metric-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    font-size: 0.95rem;
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 200px;
    overflow-y: auto;
    padding-right: 0.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.85rem;
}

.timeline::-webkit-scrollbar {
    width: 6px;
}

.timeline::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.timeline-event {
    display: flex;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.timeline-event .time {
    color: var(--text-muted);
    min-width: 90px;
}

.timeline-event.connecting .msg {
    color: #EAB308;
}

.timeline-event.connected .msg {
    color: var(--accent);
}

.timeline-event.disconnected .msg {
    color: #EF4444;
}

.timeline-event.ice .msg {
    color: var(--primary);
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}