* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-card-hover: #1c1c28;
    --border: #252535;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #555570;
    --accent-green: #53fc18;
    --accent-green-dim: rgba(83, 252, 24, 0.15);
    --accent-blue: #4e9af5;
    --accent-blue-dim: rgba(78, 154, 245, 0.15);
    --accent-purple: #b069f5;
    --accent-purple-dim: rgba(176, 105, 245, 0.15);
    --accent-red: #f04747;
    --accent-red-dim: rgba(240, 71, 71, 0.15);
    --accent-orange: #f5a623;
    --accent-orange-dim: rgba(245, 166, 35, 0.15);
    --accent-cyan: #18d4fc;
    --accent-cyan-dim: rgba(24, 212, 252, 0.15);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* --- Header --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.header-left .logo {
    width: 32px;
    height: 32px;
    background: var(--accent-green);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: #0a0a0f;
}
.header h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
}
.header h1 span { color: var(--text-secondary); font-weight: 400; }
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.live-badge.live {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    border: 1px solid rgba(240, 71, 71, 0.3);
}
.live-badge.offline {
    background: rgba(85, 85, 112, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(85, 85, 112, 0.2);
}
.live-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.live-badge.live .dot { animation: pulse 1.5s ease infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}
.btn-logout:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* --- Container --- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* --- Section titles --- */
.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding-left: 2px;
}

/* --- Live Bar --- */
.live-bar {
    background: linear-gradient(135deg, #151525, #1a1530);
    border: 1px solid rgba(83, 252, 24, 0.15);
    border-radius: 14px;
    padding: 22px 28px;
    margin-bottom: 24px;
    display: none;
    position: relative;
    overflow: hidden;
}
.live-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan), var(--accent-purple));
}
.live-bar.visible { display: block; }
.live-bar .stream-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
.live-bar .title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}
.live-bar .meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.live-bar .meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.live-bar .meta-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.live-bar .meta-value {
    font-size: 15px;
    font-weight: 600;
}
.live-bar .viewers-now {
    font-size: 42px;
    font-weight: 800;
    color: var(--accent-green);
    line-height: 1;
    text-shadow: 0 0 30px rgba(83, 252, 24, 0.3);
}
.live-bar .viewers-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: right;
}

/* --- Stat Cards --- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.08);
}
.card .icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-bottom: 12px;
}
.card .icon.green { background: var(--accent-green-dim); color: var(--accent-green); }
.card .icon.blue { background: var(--accent-blue-dim); color: var(--accent-blue); }
.card .icon.purple { background: var(--accent-purple-dim); color: var(--accent-purple); }
.card .icon.red { background: var(--accent-red-dim); color: var(--accent-red); }
.card .icon.orange { background: var(--accent-orange-dim); color: var(--accent-orange); }
.card .icon.cyan { background: var(--accent-cyan-dim); color: var(--accent-cyan); }
.card .label {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 4px;
}
.card .value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.card .sub-value {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- Grid Layout --- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
@media (max-width: 1000px) {
    .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* --- Panel --- */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.panel h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.panel .panel-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--accent-green-dim);
    color: var(--accent-green);
}

/* --- Table --- */
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.session-link {
    color: var(--accent-blue);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s;
}
.session-link:hover { color: var(--accent-cyan); }

/* Sparkline */
.sparkline {
    width: 80px;
    height: 28px;
}

/* --- Chat top users --- */
.chat-user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}
.chat-user-row:last-child { border-bottom: none; }
.chat-user-rank {
    font-size: 12px;
    color: var(--text-muted);
    width: 22px;
    text-align: right;
}
.chat-user-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}
.chat-user-bar-wrap {
    flex: 2;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.chat-user-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue));
    border-radius: 3px;
    transition: width 0.3s;
}
.chat-user-count {
    font-size: 12px;
    color: var(--text-secondary);
    width: 50px;
    text-align: right;
}

/* --- Days of week bars --- */
.day-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}
.day-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    width: 24px;
}
.day-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.day-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}
.day-value {
    font-size: 12px;
    color: var(--text-primary);
    width: 44px;
    text-align: right;
    font-weight: 600;
}

/* --- Category donut legend --- */
.cat-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}
.cat-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cat-name { flex: 1; color: var(--text-secondary); }
.cat-value { color: var(--text-primary); font-weight: 600; }

/* --- Stream Score --- */
.score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.score-row:last-child { border-bottom: none; }
.score-badge {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}
.score-badge.great { background: var(--accent-green-dim); color: var(--accent-green); }
.score-badge.good { background: var(--accent-blue-dim); color: var(--accent-blue); }
.score-badge.ok { background: var(--accent-orange-dim); color: var(--accent-orange); }
.score-badge.low { background: var(--accent-red-dim); color: var(--accent-red); }
.score-info { flex: 1; min-width: 0; }
.score-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.score-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}
.score-bar-wrap {
    width: 80px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}
.score-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* --- Engagement badge in table --- */
.eng-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.eng-badge.high { background: var(--accent-green-dim); color: var(--accent-green); }
.eng-badge.mid { background: var(--accent-blue-dim); color: var(--accent-blue); }
.eng-badge.low { background: var(--accent-orange-dim); color: var(--accent-orange); }

/* --- Loading --- */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
