:root {
    --bg: #0f1117;
    --surface: #181a20;
    --panel: #1e2028;
    --border: #2a2d38;
    --text: #e4e6eb;
    --text2: #8b8fa3;
    --accent: #6c5ce7;
    --accent2: #a29bfe;
    --green: #00b894;
    --red: #e17055;
    --orange: #fdcb6e;
    --blue: #74b9ff;
}

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

body {
    font-family: 'Segoe UI', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

header h1 .reddit-brand { color: #FF4500; }
header h1 .tg-brand { color: #2AABEE; }

.routes-group-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

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

.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.online { background: rgba(0,184,148,0.15); color: var(--green); }
.status-badge.offline { background: rgba(225,112,85,0.15); color: var(--red); }

main { padding: 1.5rem 2rem; max-width: 1400px; margin: 0 auto; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem;
}

.card .label { color: var(--text2); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.card .value { font-size: 1.8rem; font-weight: 700; margin-top: 0.3rem; }
.card .value.green { color: var(--green); }
.card .value.red { color: var(--red); }
.card .value.blue { color: var(--blue); }
.card .value.orange { color: var(--orange); }

.section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 { font-size: 1.1rem; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--text2); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); }
td { padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(108,92,231,0.04); }

.tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tag.sub { background: rgba(116,185,255,0.15); color: var(--blue); }
.tag.user { background: rgba(162,155,254,0.15); color: var(--accent2); }
.tag.on { background: rgba(0,184,148,0.15); color: var(--green); }
.tag.off { background: rgba(225,112,85,0.15); color: var(--red); }
.tag.unknown { background: rgba(139,143,163,0.15); color: var(--text2); }

.chan-id { font-family: 'Fira Code', monospace; font-size: 0.78rem; color: var(--text2); }

/* Buttons */
.btn {
    padding: 0.4rem 0.9rem;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
.btn-danger { background: rgba(225,112,85,0.15); color: var(--red); }
.btn-danger:hover { background: rgba(225,112,85,0.3); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent2); }

.actions { display: flex; gap: 0.4rem; }

/* Dialog / Modal */
dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    padding: 2rem;
    min-width: 420px;
    max-width: 90vw;
}

dialog::backdrop { background: rgba(0,0,0,0.6); }

dialog h3 { margin-bottom: 1rem; font-size: 1.1rem; }

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 0.3rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.55rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.88rem;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    main { padding: 1rem; }
    .cards { grid-template-columns: repeat(2, 1fr); }
    table { font-size: 0.8rem; }
    dialog { min-width: auto; width: 95vw; padding: 1.5rem; }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem 1.2rem;
    font-size: 0.85rem;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.8rem;
}

.health-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-dot.online { background: var(--green); }
.health-dot.offline { background: var(--red); }
.health-dot.error { background: var(--orange); }

.health-info { flex: 1; min-width: 0; }
.health-title { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.health-id { font-size: 0.75rem; color: var(--text2); font-family: monospace; }

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text2);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.2rem;
}

.tab {
    padding: 0.6rem 1.2rem;
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-size: 0.88rem;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.tab.active { color: var(--accent2); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

.tab-content { display: none; }
.tab-content.active { display: block; }
