:root {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --card: #1e293b;
    --card-2: #273449;
    --border: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --primary-2: #2563eb;
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.icon { vertical-align: middle; }

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 17px;
    color: var(--primary);
}
.brand span { color: var(--text); }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

/* Page head */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 2px; font-size: 22px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; }

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.empty {
    text-align: center;
    color: var(--muted);
    padding: 44px;
}
.empty .icon { color: var(--border); margin-bottom: 10px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }

.btn-icon { padding: 8px; }
.btn-go { color: var(--green); }
.btn-go:hover { border-color: var(--green); }
.btn-warn { color: var(--amber); }
.btn-warn:hover { border-color: var(--amber); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }

/* Forms */
label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}
input[type=text], input[type=password], input[type=number] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    width: 100%;
}
input:focus { outline: none; border-color: var(--primary); }

.form-card h2 { margin: 0 0 16px; font-size: 17px; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* Table */
.table-card { padding: 0; overflow: hidden; }
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--muted);
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
}
.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.ch-name { font-weight: 600; }
.col-actions { width: 1%; white-space: nowrap; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-live { background: rgba(34,197,94,.15); color: var(--green); }
.badge-off { background: rgba(148,163,184,.15); color: var(--muted); }
.dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 1.4s infinite;
}
@keyframes pulse {
    0%,100% { opacity: 1; }
    50% { opacity: .3; }
}

/* URL row */
.url-row { display: flex; gap: 6px; align-items: center; max-width: 360px; }
.url-input {
    font-size: 12px;
    font-family: monospace;
    background: var(--bg);
    color: var(--muted);
}
.actions { display: flex; gap: 6px; }
.actions form { margin: 0; }

/* Alerts */
.alert {
    padding: 11px 14px;
    border-radius: 9px;
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-error { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }

/* Login */
.login-wrap {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card { width: 340px; }
.login-head { text-align: center; margin-bottom: 18px; color: var(--primary); }
.login-head h1 { margin: 8px 0 2px; font-size: 20px; color: var(--text); }
.login-card label { margin-bottom: 12px; }

/* Logs */
.logbox {
    background: #0b1220;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Consolas', monospace;
    font-size: 12.5px;
    line-height: 1.6;
    color: #cbd5e1;
    max-height: 70vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

@media (max-width: 640px) {
    .url-row { max-width: 180px; }
}
