/* ═══════════════════════════════════════════════════════
   Guardian Restream — Dark Theme Design System
   ═══════════════════════════════════════════════════════ */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: rgba(22, 27, 34, 0.8);
    --bg-glass: rgba(22, 27, 34, 0.6);
    --border: rgba(48, 54, 61, 0.6);
    --border-bright: rgba(88, 166, 255, 0.3);

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;

    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-orange: #d29922;
    --accent-purple: #bc8cff;

    --gradient-primary: linear-gradient(135deg, #58a6ff 0%, #3fb950 100%);
    --gradient-hero: linear-gradient(135deg, rgba(88, 166, 255, 0.1) 0%, rgba(63, 185, 80, 0.05) 100%);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --sidebar-width: 240px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────────── */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────── */

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

/* ── Sidebar ────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-title {
    font-size: 16px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
}

.nav-links {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-link.active {
    color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
}

.nav-link.active svg {
    stroke: var(--accent-blue);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.server-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: background var(--transition);
}

.badge-dot.online {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
}

.badge-dot.offline {
    background: var(--accent-red);
}

/* ── Main Content ───────────────────────────────────── */

.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    max-width: 1200px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ── Status Grid (Dashboard) ────────────────────────── */

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.status-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    backdrop-filter: blur(12px);
    transition: all var(--transition);
}

.status-card:hover {
    border-color: var(--border-bright);
    box-shadow: var(--shadow-glow);
}

.hero-card {
    grid-column: 1 / -1;
    background: var(--gradient-hero);
    border-color: var(--border-bright);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    gap: 20px;
}

.hero-top {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-indicator {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: background var(--transition);
}

.pulse-ring {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid transparent;
}

.status-indicator.live .pulse-dot {
    background: var(--accent-green);
    box-shadow: 0 0 12px var(--accent-green);
}

.status-indicator.live .pulse-ring {
    border-color: var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.1);
        opacity: 0;
    }
}

.hero-info h2 {
    font-size: 22px;
    font-weight: 600;
}

.hero-info p {
    color: var(--text-secondary);
    font-size: 13px;
}

.card-label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-value.mono {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 24px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Buttons ────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-stream {
    background: var(--gradient-primary);
    color: #fff;
    padding: 12px 28px;
    border-radius: var(--radius-md);
    font-size: 15px;
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.3);
}

.btn-stream:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(88, 166, 255, 0.4);
}

.btn-stream.streaming {
    background: linear-gradient(135deg, var(--accent-red) 0%, #da3633 100%);
    box-shadow: 0 4px 16px rgba(248, 81, 73, 0.3);
}

.btn-stream.streaming:hover {
    box-shadow: 0 6px 24px rgba(248, 81, 73, 0.4);
}

.btn-primary {
    background: var(--accent-blue);
    color: #fff;
}

.btn-primary:hover {
    background: #79c0ff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-sm:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

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

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-danger {
    background: transparent;
    color: var(--accent-red);
    border: 1px solid transparent;
    padding: 4px 10px;
    font-size: 12px;
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.1);
    border-color: rgba(248, 81, 73, 0.3);
}

.btn-success {
    background: transparent;
    color: var(--accent-green);
    border: 1px solid transparent;
    padding: 4px 10px;
    font-size: 12px;
}

.btn-success:hover {
    background: rgba(63, 185, 80, 0.1);
    border-color: rgba(63, 185, 80, 0.3);
}

/* ── Upload Zone ────────────────────────────────────── */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.05);
}

.upload-icon {
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.upload-hint {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.upload-progress {
    margin-top: 16px;
}

.progress-bar {
    width: 100%;
    max-width: 300px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 8px;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Video List ─────────────────────────────────────── */

.video-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.video-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.video-item:hover {
    border-color: var(--border-bright);
}

.video-item.selected {
    border-color: var(--accent-green);
    background: rgba(63, 185, 80, 0.05);
}

.video-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.video-info {
    flex: 1;
    min-width: 0;
}

.video-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    display: flex;
    gap: 12px;
    margin-top: 2px;
}

.video-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.selected-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Dashboard Source Card ──────────────────────────── */

.video-item.dashboard-source {
    border-left: 3px solid var(--accent-blue);
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.06) 0%, rgba(188, 140, 255, 0.03) 100%);
    position: relative;
}

.video-item.dashboard-source:hover {
    border-color: var(--accent-blue);
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.10) 0%, rgba(188, 140, 255, 0.05) 100%);
}

.video-item.dashboard-source.selected {
    border-left-color: var(--accent-green);
    border-color: var(--accent-green);
    background: linear-gradient(135deg, rgba(63, 185, 80, 0.08) 0%, rgba(88, 166, 255, 0.04) 100%);
}

.video-item.dashboard-source .video-icon {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.2), rgba(188, 140, 255, 0.15));
    color: var(--accent-blue);
    font-size: 18px;
}

.dashboard-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
    vertical-align: middle;
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--accent-red);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: pulse-live 1.5s ease-in-out infinite;
}

@keyframes pulse-live {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.8);
    }
}

/* ── Settings ───────────────────────────────────────── */

.settings-section {
    margin-bottom: 32px;
}

.settings-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

.form-hint {
    font-size: 11px;
    color: var(--text-tertiary);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    backdrop-filter: blur(12px);
    margin-bottom: 16px;
}

.glass-panel h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ── Credential List ────────────────────────────────── */

.credential-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cred-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.cred-item:hover {
    border-color: var(--border-bright);
}

.cred-item.active-cred {
    border-color: var(--accent-green);
    background: rgba(63, 185, 80, 0.05);
}

.cred-info {
    flex: 1;
    min-width: 0;
}

.cred-name {
    font-weight: 600;
    font-size: 14px;
}

.cred-detail {
    font-size: 12px;
    color: var(--text-tertiary);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.cred-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Data Table (Logs) ──────────────────────────────── */

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(48, 54, 61, 0.3);
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: rgba(88, 166, 255, 0.03);
}

.empty-state {
    text-align: center;
    padding: 32px !important;
    color: var(--text-tertiary) !important;
    font-style: italic;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.completed {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
}

.status-badge.running {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-blue);
}

.status-badge.stopped {
    background: rgba(210, 153, 34, 0.15);
    color: var(--accent-orange);
}

.status-badge.error,
.status-badge.crashed {
    background: rgba(248, 81, 73, 0.15);
    color: var(--accent-red);
}

/* ── Toast Notifications ────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 3.5s forwards;
    max-width: 360px;
    backdrop-filter: blur(12px);
}

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

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

.toast.info {
    border-left: 3px solid var(--accent-blue);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ── Mobile Menu Toggle ─────────────────────────────── */

.mobile-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
        padding: 20px 16px;
        padding-top: 60px;
    }

    .mobile-toggle {
        display: flex;
    }

    .hero-card {
        flex-direction: column;
        text-align: center;
    }

    .hero-top {
        flex-direction: column;
    }

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

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

@media (max-width: 480px) {
    .status-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Login Screen ──────────────────────────────────── */

.login-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.4s ease;
}

.login-screen::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(88, 166, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 50%, rgba(63, 185, 80, 0.06) 0%, transparent 50%);
    animation: bgShift 15s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(-5%, 3%);
    }
}

.login-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(88, 166, 255, 0.05);
    animation: cardIn 0.5s ease;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo svg {
    margin-bottom: 16px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-title span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
}

.login-field {
    margin-bottom: 20px;
}

.login-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all var(--transition);
}

.login-field input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

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

.login-error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--accent-red);
    font-size: 13px;
    margin-bottom: 16px;
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-6px);
    }

    40%,
    80% {
        transform: translateX(6px);
    }
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.25);
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(88, 166, 255, 0.35);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 480px) {
    .login-card {
        margin: 16px;
        padding: 32px 24px;
    }
}

/* ═══════════════════════════════════════════════════════
   Analytics Intelligence Dashboard
   ═══════════════════════════════════════════════════════ */

/* KPI Cards */
.kpi-card {
    padding: 20px !important;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0.6;
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin: 6px 0 4px;
}

.kpi-delta {
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-delta.positive {
    color: var(--accent-green);
}

.kpi-delta.negative {
    color: var(--accent-red);
}

.kpi-confidence {
    margin-top: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
}

.kpi-confidence.high {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.kpi-confidence.medium {
    background: rgba(234, 179, 8, 0.12);
    color: #eab308;
}

.kpi-confidence.low {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.kpi-delta.neutral {
    color: var(--text-secondary);
}

/* Analytics Sub-Tabs */
.analytics-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    font-family: inherit;
}

.analytics-tab:hover {
    color: var(--text-primary);
    background: rgba(88, 166, 255, 0.05);
}

.analytics-tab.active {
    color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.08);
}

.analytics-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--accent-blue);
    border-radius: 2px 2px 0 0;
}

/* Tab Content */
.analytics-tab-content {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Leader Items */
.leader-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.leader-item:hover {
    background: rgba(88, 166, 255, 0.06);
}

.leader-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-blue);
    flex-shrink: 0;
}

.leader-info {
    flex: 1;
    min-width: 0;
}

.leader-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leader-stats {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
    margin-top: 2px;
}

.leader-overlap-bar {
    width: 60px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}

.leader-overlap-fill {
    height: 100%;
    background: var(--accent-purple);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* Signal Alert Items */
.signal-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    cursor: default;
}

.signal-item:last-child {
    border-bottom: none;
}

.signal-item:hover {
    background: rgba(88, 166, 255, 0.03);
}

.signal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 6px;
}

.signal-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.signal-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.signal-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-line;
}

.signal-meta {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.signal-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.signal-badge.critical {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.signal-badge.warning {
    background: rgba(210, 153, 34, 0.15);
    color: var(--accent-orange);
}

.signal-badge.info {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-blue);
}

/* Horizontal Bar Charts */
.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.bar-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    width: 120px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.bar-value {
    font-size: 0.78rem;
    color: var(--text-primary);
    font-weight: 500;
    width: 60px;
    text-align: right;
    flex-shrink: 0;
}

/* Video Performance Table */
.video-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.video-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    background: rgba(22, 27, 34, 0.5);
    position: sticky;
    top: 0;
}

.video-table td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(48, 54, 61, 0.3);
    color: var(--text-primary);
}

.video-table tr:hover td {
    background: rgba(88, 166, 255, 0.03);
}

.video-table .outlier-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

/* Search Term Items */
.search-term-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    transition: background var(--transition);
}

.search-term-item:hover {
    background: rgba(88, 166, 255, 0.04);
}

.search-term-text {
    flex: 1;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.search-term-views {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.search-term-trend {
    font-size: 0.75rem;
    font-weight: 600;
    width: 18px;
    text-align: center;
}

.search-gap-item {
    padding: 10px 20px;
    border-bottom: 1px solid rgba(48, 54, 61, 0.3);
}

.search-gap-item:last-child {
    border-bottom: none;
}

.search-gap-term {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--accent-orange);
}

.search-gap-views {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Session Depth Chart Bars */
.depth-bar {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.depth-bar-fill {
    width: 100%;
    max-width: 40px;
    border-radius: 3px 3px 0 0;
    transition: height 0.5s ease;
}

.depth-bar-label {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* Responsive: stack 2-col grids on mobile/tablet */
@media (max-width: 900px) {
    #analyticsTopRow {
        grid-template-columns: 1fr !important;
    }

    #analyticsTabTraffic>div:first-child {
        grid-template-columns: 1fr !important;
    }

    #analyticsTabSearch>div:first-child {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 600px) {
    .analytics-tab {
        font-size: 0.78rem;
        padding: 10px 8px;
    }
}