:root {
    --bg: #0e0e12;
    --bg-elevated: #17171d;
    --bg-card: #1c1c24;
    --border: #2b2b35;
    --text: #eaeaf2;
    --text-muted: #9797a8;
    --accent: #9146ff;
    --accent-hover: #a970ff;
    --accent-soft: rgba(145, 70, 255, 0.15);
    --success: #3fd67a;
    --danger: #ff5c5c;
    --warning: #ffb84d;
    --radius: 10px;
    font-family: 'Segoe UI', Inter, system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

h1, h2, h3, h4 {
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

a {
    color: var(--accent-hover);
}

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

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.5rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
}

.sidebar-brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
    background: var(--bg-card);
    color: var(--text);
}

.nav-links a.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.sidebar-status {
    margin-top: auto;
    padding: 0.75rem;
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
}

.status-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-pill.connected .dot { background: var(--success); }
.status-pill.disconnected .dot { background: var(--danger); }

.sidebar-user {
    padding: 0.75rem;
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-user strong { color: var(--text); }
.sidebar-user form { margin: 0; }
.sidebar-user .btn { width: 100%; justify-content: center; }

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1200px;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header p {
    color: var(--text-muted);
    margin: 0.25rem 0 0 0;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.card h3 {
    margin-bottom: 0.9rem;
    font-size: 1.05rem;
}

.grid {
    display: grid;
    gap: 1.25rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.stat-tile .value {
    font-size: 1.8rem;
    font-weight: 800;
}

.stat-tile .label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0.55rem 1.1rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, opacity 0.15s;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover { background: #24242e; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #ff7a7a; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

input[type=text], input[type=number], input[type=password], input[type=url], textarea, select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
    width: 100%;
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.field { margin-bottom: 0.9rem; }

.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    vertical-align: middle;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    transition: 0.15s;
}

.switch .slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.15s;
}

.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

th {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.badge.gray { background: #2b2b35; color: var(--text-muted); }
.badge.green { background: rgba(63, 214, 122, 0.15); color: var(--success); }
.badge.red { background: rgba(255, 92, 92, 0.15); color: var(--danger); }

.feed {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.4rem;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.feed-item {
    display: flex;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: var(--bg-elevated);
    font-size: 0.87rem;
    align-items: baseline;
}

.feed-item .time { color: var(--text-muted); font-size: 0.72rem; flex-shrink: 0; }
.feed-item .user { font-weight: 700; color: var(--accent-hover); }

.feed-item.follow { border-left: 3px solid #4dc4ff; }
.feed-item.subscribe, .feed-item.giftsub { border-left: 3px solid var(--accent); }
.feed-item.cheer { border-left: 3px solid var(--warning); }
.feed-item.raid { border-left: 3px solid var(--danger); }
.feed-item.redemption { border-left: 3px solid var(--success); }
.feed-item.system { border-left: 3px solid var(--text-muted); color: var(--text-muted); }

.callout {
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
}

.callout.info { background: var(--accent-soft); border: 1px solid rgba(145,70,255,0.35); }
.callout.success { background: rgba(63, 214, 122, 0.12); border: 1px solid rgba(63, 214, 122, 0.35); }
.callout.error { background: rgba(255, 92, 92, 0.12); border: 1px solid rgba(255, 92, 92, 0.35); }

.goal-bar {
    width: 100%;
    height: 22px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    overflow: hidden;
}

.goal-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transition: width 0.4s ease;
}

.chart-wrap { width: 100%; overflow-x: auto; }

.actions-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

h1:focus { outline: none; }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5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4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

#blazor-error-ui {
    background: #1c1c24;
    border-top: 1px solid var(--danger);
    color: var(--text);
    display: none;
    left: 0;
    bottom: 0;
    position: fixed;
    width: 100%;
    z-index: 1000;
    padding: 0.8rem 1.2rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.5rem;
}
