/* =========================================
   PANEL DESIGN SYSTEM
   ========================================= */
:root {
    --bg-color: #08111f;
    --bg-accent-1: rgba(37, 99, 235, 0.22);
    --bg-accent-2: rgba(16, 185, 129, 0.14);
    --bg-accent-3: rgba(244, 114, 182, 0.12);
    --surface: rgba(8, 17, 31, 0.78);
    --surface-strong: rgba(10, 19, 34, 0.92);
    --surface-soft: rgba(255, 255, 255, 0.04);
    --card-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(96, 165, 250, 0.28);
    --accent: #22c55e;
    --accent-strong: #16a34a;
    --primary: #3b82f6;
    --primary-strong: #1d4ed8;
    --danger: #ef4444;
    --danger-strong: #b91c1c;
    --text-main: #f8fafc;
    --text-soft: #dbe6f4;
    --text-dim: #94a3b8;
    --shadow-panel: 0 28px 70px -34px rgba(15, 23, 42, 0.92);
    --shadow-card: 0 18px 42px -28px rgba(15, 23, 42, 0.82);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    background: var(--bg-color);
}

body {
    position: relative;
    margin: 0;
    min-height: 100vh;
    padding: 28px 18px 36px;
    color: var(--text-main);
    background:
        radial-gradient(circle at top left, var(--bg-accent-1), transparent 34%),
        radial-gradient(circle at top right, var(--bg-accent-2), transparent 28%),
        radial-gradient(circle at bottom center, var(--bg-accent-3), transparent 32%),
        linear-gradient(180deg, #07101d 0%, #0b1324 48%, #07101d 100%);
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    pointer-events: none;
    z-index: 0;
    filter: blur(24px);
    opacity: 0.7;
}

body::before {
    top: 90px;
    left: -80px;
    width: 220px;
    height: 220px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
}

body::after {
    right: -70px;
    bottom: 120px;
    width: 260px;
    height: 260px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.08);
}

.app-container,
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
}

/* =========================================
   HEADER
   ========================================= */
.header {
    position: relative;
    z-index: 1;
    margin-bottom: 28px;
}

.header-inner,
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.header h2 {
    margin: 0;
    font-size: clamp(1.15rem, 1rem + 0.5vw, 1.6rem);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-main);
}

.top-actions,
.top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.top-bar form,
.top-actions form {
    margin: 0;
}

/* =========================================
   SHARED PANELS
   ========================================= */
.panel-card,
.filter-section,
.login-card,
.card,
.logo-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
        var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-panel);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.filter-section {
    border-radius: var(--radius-xl);
    padding: 20px;
    margin-bottom: 26px;
}

.panel-title,
.manager-section-title {
    margin: 0 0 14px;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.panel-message {
    margin-bottom: 16px;
    padding: 13px 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 13px;
    box-shadow: var(--shadow-card);
}

.panel-message.success {
    background: rgba(34, 197, 94, 0.12);
    color: #bbf7d0;
}

.panel-message.error {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
}

/* =========================================
   CHIPS / BADGES
   ========================================= */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chip {
    padding: 8px 13px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.chip:hover {
    transform: translateY(-1px);
    border-color: rgba(96, 165, 250, 0.24);
    color: var(--text-soft);
}

.chip.active {
    color: white;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(29, 78, 216, 0.95));
    border-color: rgba(147, 197, 253, 0.25);
}

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.16);
    color: #bbf7d0;
    border: 1px solid rgba(34, 197, 94, 0.18);
    font-size: 11px;
    font-weight: 800;
}

/* =========================================
   LAYOUT / CARDS
   ========================================= */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}

.card {
    border-radius: 22px;
    padding: 18px;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-card);
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(96, 165, 250, 0.24);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.018)),
        var(--surface-strong);
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.cred-label {
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #86efac;
    font-size: 11px;
    font-weight: 700;
}

/* =========================================
   INPUTS
   ========================================= */
.search,
.manual,
.manager-input,
.config-field select {
    width: 100%;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(2, 8, 23, 0.72);
    color: var(--text-main);
    font-size: 13px;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.search::placeholder,
.manual::placeholder,
.manager-input::placeholder {
    color: #64748b;
}

.search:focus,
.manual:focus,
.manager-input:focus,
.config-field select:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.55);
    background: rgba(7, 15, 29, 0.95);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.channel-title {
    width: 100%;
    min-width: 0;
    padding: 3px 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}

.channel-title:focus {
    outline: none;
    border-bottom-color: rgba(96, 165, 250, 0.55);
}

.channel-title:hover {
    border-bottom-color: rgba(148, 163, 184, 0.3);
}

.results {
    max-height: 136px;
    overflow-y: auto;
    padding: 6px;
    background: rgba(2, 8, 23, 0.46);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 12px;
    font-size: 13px;
}

.channel {
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-soft);
    transition: background 0.18s ease, color 0.18s ease;
}

.channel:hover {
    background: rgba(59, 130, 246, 0.12);
    color: white;
}

.creds-box {
    display: none;
    margin-bottom: 4px;
    padding: 13px;
    border-radius: 16px;
    background: rgba(2, 8, 23, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.input-group,
.buttons {
    display: flex;
    gap: 8px;
}

/* =========================================
   BUTTONS
   ========================================= */
button {
    flex: 1;
    padding: 11px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.2s ease, border-color 0.2s ease;
}

button:active {
    transform: scale(0.98);
}

.btn-action,
.btn-refresh,
.btn-toggle,
.btn-danger,
.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn-action:hover,
.btn-refresh:hover,
.btn-toggle:hover,
.btn-danger:hover,
.btn-link:hover,
.icon-btn:hover {
    transform: translateY(-1px);
}

.btn-action,
.update-btn,
.btn-refresh,
.btn-link,
.apply {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    border-color: rgba(147, 197, 253, 0.22);
}

.kill-btn,
.btn-danger,
.stop {
    color: white;
    background: linear-gradient(135deg, var(--danger), var(--danger-strong));
    border-color: rgba(252, 165, 165, 0.16);
}

.start {
    color: #052e16;
    background: linear-gradient(135deg, #4ade80, var(--accent-strong));
    border-color: rgba(134, 239, 172, 0.2);
}

.reset {
    color: var(--text-main);
    background: linear-gradient(135deg, #475569, #334155);
    border-color: rgba(148, 163, 184, 0.16);
}

.btn-toggle.inactive {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    border-color: rgba(148, 163, 184, 0.16);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(96, 165, 250, 0.24);
    color: white;
}

.btn-del {
    width: 34px;
    flex: none;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--danger);
}

/* =========================================
   STATUS / MESSAGES
   ========================================= */
.status {
    padding: 10px 12px;
    font-size: 13px;
    text-align: center;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 14px;
}

.status-mini {
    font-size: 11px;
    color: var(--text-dim);
    margin-left: 8px;
}

.live {
    color: #4ade80;
    font-weight: 800;
}

.error {
    color: #f87171;
}

.message {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    padding: 13px 18px;
    border-radius: 16px;
    color: white;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(96, 165, 250, 0.16);
    border-left: 4px solid var(--accent);
    box-shadow: 0 20px 50px -28px rgba(0, 0, 0, 0.8);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* =========================================
   LOGIN
   ========================================= */
.login-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    border-radius: 28px;
}

.login-title {
    margin-bottom: 2rem;
    color: white;
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 0.04em;
}

.login-error {
    margin-top: 1rem;
    padding: 10px;
    border-radius: 12px;
    text-align: center;
    font-size: 14px;
    color: #fecaca;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.16);
}

/* =========================================
   MOBILE
   ========================================= */
@media (max-width: 760px) {
    body {
        padding: 16px 12px 28px;
    }

    .header-inner,
    .header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .top-bar,
    .top-actions {
        width: 100%;
        justify-content: stretch;
    }

    .top-bar form,
    .top-actions form {
        width: 100%;
    }

    .btn-action,
    .btn-refresh,
    .btn-toggle,
    .btn-danger,
    .btn-link,
    .top-bar a,
    .top-actions a,
    .top-bar button,
    .top-actions button {
        width: 100%;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .input-group,
    .buttons {
        flex-direction: column;
    }

    .channel-title {
        width: 100%;
    }

    .message {
        right: 12px;
        left: 12px;
        bottom: 12px;
    }
}

@media (max-width: 420px) {
    .icon-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .main-actions button {
        font-size: 11px;
    }
}
