:root {
    --bg: #0a0b10;
    --card: #12141c;
    --border: rgba(255, 255, 255, 0.07);
    --text: #e7e9f0;
    --muted: #8b8fa3;
    --accent: #7c8cff;
    --accent2: #a78bfa;
    --green: #34d399;
    --red: #f87171;
    --amber: #fbbf24;
}

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

body {
    background: radial-gradient(1200px 600px at 70% -10%, rgba(124, 140, 255, 0.10), transparent 60%),
                radial-gradient(900px 500px at 10% 110%, rgba(167, 139, 250, 0.08), transparent 60%),
                var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.mt { margin-top: 14px; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
    width: 100%; max-width: 380px; background: var(--card);
    border: 1px solid var(--border); border-radius: 18px; padding: 40px 32px;
    text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-logo { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 16px; }
.login-card h1 { font-size: 24px; }
.login-card h1 span, .brand h1 span { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
    background: #0d0f16; border: 1px solid var(--border); border-radius: 10px;
    padding: 12px 14px; color: var(--text); font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
    background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff;
    border: 0; border-radius: 10px; padding: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-card button:disabled { opacity: 0.6; cursor: default; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 12px; }

/* ── Dashboard ── */
.dash { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; }
.brand h1 { font-size: 20px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.btn {
    background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff; border: 0;
    border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }

.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 16px;
}
.card.mini { margin-bottom: 0; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 14px; }

.svc-name { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.svc-status { font-size: 15px; font-weight: 700; }
.svc-status.ok { color: var(--green); }
.svc-status.bad { color: var(--red); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: rgba(255,255,255,0.025); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 800; margin-top: 4px; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* bars */
.bar-row { margin-bottom: 14px; }
.bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.bar-head .lbl { color: var(--muted); }
.bar { height: 8px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.5s ease; }
.bar > div.warn { background: linear-gradient(90deg, var(--amber), #f59e0b); }
.bar > div.danger { background: linear-gradient(90deg, var(--red), #ef4444); }

/* users table */
.search {
    width: 100%; background: #0d0f16; border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 14px; color: var(--text); font-size: 13px; outline: none; margin-bottom: 12px;
}
.search:focus { border-color: var(--accent); }
.user-head, .user-row {
    display: grid;
    grid-template-columns: 10px 32px 1fr 70px 110px 90px;
    align-items: center; gap: 12px; padding: 8px 4px;
}
.user-head {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.user-row { font-size: 14px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: 0; }
.u-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.u-avatar.initial { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.u-nick { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.u-col { text-align: right; font-size: 12px; }
@media (max-width: 640px) {
    .user-head, .user-row { grid-template-columns: 10px 32px 1fr 60px; }
    .user-row .u-col:nth-of-type(3), .user-head span:nth-of-type(5) { display: none; }
}

/* pager + user messages modal */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.pager-info { font-size: 13px; color: var(--muted); }
.pager .btn:disabled { opacity: 0.4; cursor: default; }
.clickable { cursor: pointer; transition: background 0.15s; }
.clickable:hover { background: rgba(255, 255, 255, 0.04); }
.modal {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 16px;
    width: 100%; max-width: 640px; max-height: 82vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-user { display: flex; align-items: center; gap: 10px; }
.modal-name { font-weight: 700; font-size: 15px; }
.modal-list { overflow-y: auto; padding: 14px 18px; }
.msg { padding: 10px 0; border-bottom: 1px solid var(--border); }
.msg:last-child { border-bottom: 0; }
.msg-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; margin-bottom: 4px; }
.msg-room { color: var(--accent); font-weight: 600; }
.msg-text { font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* cluster */
.peer { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.peer:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.bad { background: var(--red); }

/* livekit rooms */
.room-chip {
    display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.03);
    border: 1px solid var(--border); border-radius: 99px; padding: 6px 12px; font-size: 13px; margin: 0 8px 8px 0;
}
.room-chip .mic { color: var(--accent2); }

#updated { white-space: nowrap; }
@media (max-width: 520px) { .top { flex-direction: column; align-items: flex-start; } }
