:root {
    --bg-darkest: #0a0e17;
    --bg-dark: #111827;
    --bg-card: #1a2332;
    --bg-card-hover: #1f2937;
    --bg-input: #0f1620;
    --border: #2a3548;
    --border-light: #374151;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.4);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

html, body {
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-darkest);
    color: var(--text-primary);
    line-height: 1.5;
}

body {
    background:
        radial-gradient(ellipse at top, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
        var(--bg-darkest);
    background-attachment: fixed;
}
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

.navbar {
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky; top: 0; z-index: 100;
}

.navbar-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.logo { display: flex; align-items: center; gap: 0.6rem; font-size: 1.25rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-primary); }

.logo-mark {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
    box-shadow: 0 0 20px var(--accent-glow);
}

.nav-right { display: flex; gap: 1rem; align-items: center; }

.user-pill { background: var(--bg-card); padding: 0.4rem 0.9rem; border-radius: 100px; font-size: 0.85rem; color: var(--text-secondary); border: 1px solid var(--border); }

.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }

.page-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; }

.page-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 2rem; }

.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }

.auth-card { width: 100%; max-width: 420px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; box-shadow: var(--shadow); position: relative; overflow: hidden; }

.auth-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--accent), #8b5cf6, var(--accent)); }

.auth-header { text-align: center; margin-bottom: 2rem; }

.auth-header .logo-mark { width: 56px; height: 56px; margin: 0 auto 1rem; font-size: 1.5rem; }

.auth-header h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }

.auth-header p { color: var(--text-secondary); font-size: 0.9rem; }

.field { margin-bottom: 1.2rem; }

.field label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.4rem; font-weight: 500; }

.field input, .field select {
    width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem; color: var(--text-primary); font-size: 0.95rem; font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.field input::placeholder { color: var(--text-muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.7rem 1.2rem; border: none; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit; text-transform: uppercase; letter-spacing: 0.5px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; box-shadow: 0 2px 8px var(--accent-glow); }

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }

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

.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); border-color: var(--border-light); }

.btn-danger { background: var(--danger); color: white; }

.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-block { width: 100%; }

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

.btn-xs { padding: 0.3rem 0.55rem; font-size: 0.72rem; letter-spacing: 0; text-transform: none; }

.actions { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }

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

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

.card-title { font-size: 1.1rem; font-weight: 600; }

.table-wrapper { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

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

thead { background: var(--bg-darkest); }

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

td .row, td .chips { align-content: flex-start; }

.link-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }

.link-row:last-child { border-bottom: 0; }

.link-row .ltext { min-width: 0; }

.link-row .lname { font-weight: 600; }

.link-row .lurl { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

th { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }

tbody tr { transition: background 0.15s; }

tbody tr:hover { background: var(--bg-card-hover); }

tbody tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 100px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); }

.badge-success { background: var(--success-bg); color: var(--success); }

.badge-danger { background: var(--danger-bg); color: var(--danger); }

.alert { padding: 0.85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; border: 1px solid transparent; }

.alert-error { background: var(--danger-bg); color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }

.alert-info { background: rgba(59, 130, 246, 0.1); color: var(--accent); border-color: rgba(59, 130, 246, 0.3); }

.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.chip { display: inline-flex; gap: 0.35rem; align-items: center; font-size: 0.8rem; background: var(--bg-input); border: 1px solid var(--border); padding: 0.35rem 0.6rem; border-radius: var(--radius-sm); cursor: pointer; }

.text-muted { color: var(--text-muted); }

.hidden { display: none !important; }

#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--bg-card); border: 1px solid var(--border); padding: 0.7rem 1.1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 1100; }

#toast.show { opacity: 1; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 2rem; }

.modal-overlay.show { display: flex; }

.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 480px; box-shadow: var(--shadow); }

.modal h2 { margin-bottom: 1rem; font-size: 1.2rem; }

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

.space { height: 100vh; display: flex; flex-direction: column; }

.toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.5rem 1rem; background: var(--bg-darkest); border-bottom: 1px solid var(--border); font-size: 0.85rem; }

.toolbar .label { color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-size: 0.72rem; }

.dock { height: 100vh; display: flex; flex-direction: column; background: var(--bg-dark); }

.cols { flex: 1; display: flex; min-height: 0; gap: 1px; background: var(--border); }

.col { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-dark); }

.col.narrow { flex: 0 0 320px; }

.col-head { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); padding: 0.75rem 1rem; background: var(--bg-darkest); border-bottom: 1px solid var(--border); }

.list { flex: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 2px; }

.msg { padding: 0.3rem 0.5rem; border-radius: var(--radius-sm); word-wrap: break-word; }

.msg:hover { background: var(--bg-card-hover); }

.msg .u { font-weight: 700; }

.badge-img { width: 18px; height: 18px; vertical-align: middle; margin-right: 3px; border-radius: 3px; }

.act { padding: 0.4rem 0.6rem; border-radius: var(--radius-sm); background: var(--bg-card); border-left: 2px solid var(--accent); color: var(--text-secondary); }

.composer { display: flex; gap: 0.5rem; padding: 0.6rem; border-top: 1px solid var(--border); background: var(--bg-darkest); }

.composer input { flex: 1; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; color: var(--text-primary); font-family: inherit; }

.composer input:focus { outline: none; border-color: var(--accent); }

.control { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; overflow: visible; }

.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 2000; background: var(--danger); color: #fff; text-align: center; padding: 0.45rem; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.5px; }

.stats { padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; overflow-y: auto; }

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

.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }

.stat-value { font-size: 1.4rem; font-weight: 700; }

.stat-value.live { color: var(--success); }

.stat-value.off { color: var(--text-muted); }

.stat-meta { font-size: 0.8rem; color: var(--text-secondary); word-break: break-word; }

.suggest { position: relative; }

.suggest-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: min(70vh, 460px); overflow-y: auto; z-index: 10; }

.suggest-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.8rem; cursor: pointer; }

.suggest-item:hover { background: var(--bg-card-hover); }

.suggest-item img { width: 44px; height: 58px; border-radius: 3px; object-fit: cover; background: var(--bg-input); flex-shrink: 0; }

.suggest-item span { font-size: 0.95rem; }

.picked { font-size: 0.85rem; color: var(--text-secondary); }

.status-line { font-size: 0.8rem; color: var(--text-muted); }

@media (max-width: 760px) {
    .navbar { padding: 1rem; }
    .container { padding: 1rem; }
    .cols { flex-direction: column; }
    .col.narrow { flex: 1 1 auto; }
}
