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

:root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #0d0d0d;
    --bg-card-hover: #141414;
    --bg-input: #0a0a0a;
    --border-color: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #666666;
    --accent-primary: #ff1744;
    --accent-glow: #ff1744;
    --accent-blue: #00d4ff;
    --accent-green: #39ff14;
    --accent-orange: #ff6600;
    --accent-red: #ff1744;
    --accent-purple: #bf00ff;
    --accent-yellow: #ccff00;
    --glow-strong: 0 0 20px var(--accent-glow);
    --glow-soft: 0 0 10px rgba(255, 23, 68, 0.3);
    --border-focus: #ff1744;
    --sidebar-width: 220px;
    --header-height: 56px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* ============================================
   SPA Container Layout
   ============================================ */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ============================================
   Sidebar Navigation
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}

.icon-logo {
    width: 28px;
    height: 28px;
    color: var(--accent-red);
    filter: drop-shadow(0 0 6px var(--accent-red));
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(90deg, #fff, var(--accent-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-items {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    text-align: left;
    position: relative;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

.nav-item.active {
    background: rgba(255, 23, 68, 0.15);
    color: var(--accent-red);
    border-left: 3px solid var(--accent-red);
    margin-left: -3px;
}

.nav-badge {
    position: absolute;
    right: 10px;
    background: var(--accent-red);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ============================================
   Mobile Header (hidden on desktop)
   ============================================ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 12px;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 8px;
    cursor: pointer;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

.mobile-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.icon-logo-sm {
    width: 22px;
    height: 22px;
    color: var(--accent-red);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 199;
}

/* ============================================
   Main Content Area
   ============================================ */
.main-content {
    flex: 1;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    padding: 20px 24px;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.content-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.last-update {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Icon Sizes */
.icon-large { width: 64px; height: 64px; stroke-width: 1.5; }
.icon-header { width: 40px; height: 40px; stroke-width: 1.5; }
.icon-stat { width: 32px; height: 32px; stroke-width: 1.5; color: var(--accent-red); }
.icon-section { width: 24px; height: 24px; stroke-width: 2; vertical-align: middle; margin-right: 8px; }
.icon-btn { width: 18px; height: 18px; stroke-width: 2; }
.icon-small { width: 14px; height: 14px; stroke-width: 2; }
.icon-lib { width: 28px; height: 28px; stroke-width: 1.5; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.icon-spin { animation: spin 1s linear infinite; width: 24px; height: 24px; }

/* Setup View */
.setup-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 40px);
}

.setup-card {
    background: var(--bg-card);
    border: 1px solid var(--accent-red);
    border-radius: 16px;
    padding: 48px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 30px rgba(255, 23, 68, 0.15), inset 0 0 60px rgba(255, 23, 68, 0.03);
}

.setup-icon {
    color: var(--accent-red);
    margin-bottom: 24px;
    filter: drop-shadow(0 0 10px var(--accent-red));
}

.setup-card h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.setup-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.setup-form {
    text-align: left;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 15px rgba(255, 23, 68, 0.3);
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.help-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--accent-red);
    text-decoration: none;
}

.help-link:hover {
    text-decoration: underline;
}

.btn-primary {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.4);
}

.btn-primary:hover {
    background: #ff3d5a;
    box-shadow: 0 0 30px rgba(255, 23, 68, 0.6);
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Plex OAuth Button */
.btn-plex {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    background: #e5a00d;
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-bottom: 16px;
}

.btn-plex:hover {
    background: #f5b82e;
}

.btn-plex:active {
    transform: scale(0.98);
}

.plex-icon {
    width: 22px;
    height: 22px;
}

/* OAuth Status */
.oauth-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Server Selection */
.server-selection {
    text-align: left;
    margin-bottom: 24px;
    max-height: 400px;
    overflow-y: auto;
}

.server-selection h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.server-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.server-group {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.server-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-card-hover);
    border-bottom: 1px solid var(--border-color);
}

.server-group-name {
    font-weight: 600;
    flex: 1;
}

.connection-list {
    display: flex;
    flex-direction: column;
}

.server-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input);
    border: none;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.server-option:last-child {
    border-bottom: none;
}

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

.server-option-icon {
    color: var(--accent-green);
}

.server-option-icon.offline {
    color: var(--accent-red);
}

.server-option-info {
    flex: 1;
}

.server-option-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.server-option-url {
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
    overflow-wrap: break-word;
}

.server-option-badge {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--accent-blue);
    color: white;
    text-transform: uppercase;
}

.server-option-badge.local {
    background: var(--accent-green);
}

.server-option-badge.relay {
    background: var(--accent-orange);
}

/* Discord Setup */
.discord-setup {
    text-align: left;
    margin-bottom: 24px;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.step-badge {
    background: var(--accent-purple);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
}

.step-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.setup-instructions {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.setup-instructions p {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.setup-instructions ol {
    margin: 0;
    padding-left: 20px;
    color: var(--text-secondary);
}

.setup-instructions li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.setup-instructions a {
    color: var(--accent-red);
    text-decoration: none;
}

.setup-instructions a:hover {
    text-decoration: underline;
}

.help-text {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.button-group .btn-secondary {
    flex: 1;
}

.button-group .btn-primary {
    flex: 1;
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 12px;
    width: 100%;
    text-align: center;
    margin-top: 8px;
}

.btn-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.test-result {
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.test-result.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.test-result.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

.test-result.loading {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Commands Card */
.commands-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 23, 68, 0.3);
    border-radius: 12px;
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.1);
}

.commands-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-card-hover);
    border-bottom: 1px solid var(--border-color);
}

.commands-header h3 {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.btn-icon.rotated {
    transform: rotate(180deg);
}

.commands-content {
    padding: 16px 20px;
}

.commands-content.collapsed {
    display: none;
}

.command-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.command-item {
    display: flex;
    align-items: center;
    gap: 16px;
}

.command-item code {
    background: var(--bg-input);
    color: var(--accent-red);
    padding: 6px 12px;
    border: 1px solid rgba(255, 23, 68, 0.3);
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    min-width: 160px;
}

.command-item span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.commands-note {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.commands-note .icon-small {
    color: var(--accent-orange);
}

/* Settings Modal */
.modal-large {
    max-width: 600px;
}

.settings-auth {
    text-align: center;
    padding: 40px 20px;
}

.settings-auth p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.settings-content {
    padding: 16px 20px;
    max-height: calc(80vh - 140px);
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-of-type {
    border-bottom: none;
    margin-bottom: 12px;
}

.settings-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.settings-servers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.server-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.server-item-info {
    flex: 1;
}

.server-item-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.server-item-url {
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.server-item .btn-danger {
    background: transparent;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.server-item .btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-full {
    width: 100%;
    margin-top: 8px;
}

.settings-content .form-group {
    margin-bottom: 10px;
}

.settings-content .form-group label {
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.settings-content .form-group input {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.checkbox-group input[type="checkbox"]:checked {
    background: var(--accent-red);
    border-color: var(--accent-red);
    box-shadow: 0 0 10px rgba(255, 23, 68, 0.5);
}

.checkbox-group input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.success-message {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Sync Stats Card */
.sync-stats-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 23, 68, 0.3);
    border-radius: 12px;
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.1);
}

.sync-stats-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-card-hover);
    border-bottom: 1px solid var(--border-color);
}

.sync-stats-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.sync-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border-color);
}

.sync-stats-grid.sync-stats-3 {
    grid-template-columns: repeat(3, 1fr);
}

.sync-stat {
    padding: 16px;
    background: var(--bg-card);
    text-align: center;
}

.sync-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.sync-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-red);
    text-shadow: 0 0 10px rgba(255, 23, 68, 0.5);
}

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

.section-header h2 {
    margin: 0;
}

.btn-icon-small {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s;
}

.btn-icon-small:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.history-item:hover {
    border-color: rgba(255, 23, 68, 0.3);
}

.history-icon {
    padding: 8px;
    border-radius: 8px;
    background: var(--bg-input);
}

.history-icon.command {
    color: var(--accent-red);
}

.history-icon.sync {
    color: var(--accent-green);
}

.history-icon.success {
    color: var(--accent-green);
}

.history-icon.warning {
    color: var(--accent-orange);
}

.history-icon.error {
    color: var(--accent-red);
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-weight: 500;
    margin-bottom: 4px;
}

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

.history-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.history-time {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-duration {
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.no-history {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .sync-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    padding: 0 16px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-red);
    box-shadow: 0 0 15px rgba(255, 23, 68, 0.2);
}

.error-message {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-red);
    border-radius: 8px;
    color: var(--accent-red);
    font-size: 0.875rem;
}

/* Dashboard Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    padding: 24px 32px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid rgba(255, 23, 68, 0.3);
    box-shadow: 0 0 30px rgba(255, 23, 68, 0.1);
}

.header-content {
    text-align: left;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.header-title h1 {
    font-size: 1.75rem;
    font-weight: 600;
    background: linear-gradient(90deg, #fff, #ff1744);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-red);
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.2);
}

.stat-icon {
    margin-bottom: 12px;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--accent-red);
    text-shadow: 0 0 20px rgba(255, 23, 68, 0.5);
}

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

/* Libraries Section */
.section {
    margin-bottom: 40px;
}

.section h2 {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    font-size: 1.25rem;
    font-weight: 600;
}

.libraries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
}

.library-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, background 0.2s;
}

.library-card:hover {
    transform: translateY(-2px);
    background: var(--bg-card-hover);
}

.library-card.movies { border-left: 3px solid var(--accent-red); }
.library-card.shows { border-left: 3px solid var(--accent-purple); }
.library-card.music { border-left: 3px solid var(--accent-green); }
.library-card.photos { border-left: 3px solid var(--accent-orange); }

.library-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.library-icon {
    color: var(--text-secondary);
}

.library-title { flex: 1; }

.library-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.library-type {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.library-meta {
    display: flex;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.meta-item { text-align: center; }

.meta-label {
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.meta-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-red);
}

/* Loading & Messages */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--accent-red);
    border-radius: 16px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(255, 23, 68, 0.2);
}

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

.modal-header h2 {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn-secondary {
    flex: 1;
}

.modal-actions .btn-primary {
    flex: 2;
}

.modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.modal-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.modal-tab.active {
    background: var(--accent-red);
    color: white;
}

.modal-method {
    min-height: 180px;
}

.modal-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.btn-plex {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #e5a00d;
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-plex:hover {
    background: #f5b82e;
}

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

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

/* ============================================
   Dashboard Stats Row
   ============================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.stats-row .stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.2s;
}

.stats-row .stat-card:hover {
    border-color: rgba(255, 23, 68, 0.5);
}

.stats-row .stat-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-red);
    flex-shrink: 0;
}

.stats-row .stat-info {
    display: flex;
    flex-direction: column;
}

.stats-row .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-red);
    line-height: 1;
}

.stats-row .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* ============================================
   Dashboard Grid & Panels
   ============================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card-hover);
    flex-shrink: 0;
}

.panel-header svg {
    width: 18px;
    height: 18px;
    color: var(--accent-red);
}

.panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border-color);
    flex: 1;
}

.status-item {
    padding: 14px;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.status-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-red);
}

.status-online {
    color: var(--accent-green) !important;
}

.activity-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 4px;
}

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

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg {
    width: 16px;
    height: 16px;
    color: var(--accent-red);
}

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

.activity-title {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.loading-small {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ============================================
   Libraries Grid (Tab)
   ============================================ */
#tab-libraries .libraries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    overflow-y: auto;
    flex: 1;
    padding-right: 8px;
}

/* ============================================
   History List (Tab)
   ============================================ */
#tab-activity .history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 8px;
}

/* ============================================
   Commands Grid
   ============================================ */
.commands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    flex: 1;
    overflow-y: auto;
}

.command-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.command-card code {
    display: block;
    background: var(--bg-input);
    color: var(--accent-red);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.85rem;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 23, 68, 0.2);
}

.command-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
}

.commands-note {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 16px;
    flex-shrink: 0;
}

.commands-note svg {
    width: 18px;
    height: 18px;
    color: var(--accent-orange);
    flex-shrink: 0;
}

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

/* ============================================
   Debug Console
   ============================================ */
.debug-actions {
    display: flex;
    gap: 8px;
}

.debug-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.filter-btn {
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-btn:hover {
    border-color: var(--accent-red);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.debug-console {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.8rem;
}

.debug-entry {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.debug-entry:last-child {
    border-bottom: none;
}

.debug-time {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.debug-level {
    width: 50px;
    font-weight: 600;
    flex-shrink: 0;
}

.debug-entry.info .debug-level { color: var(--accent-blue); }
.debug-entry.warn .debug-level { color: var(--accent-orange); }
.debug-entry.error .debug-level { color: var(--accent-red); }
.debug-entry.api .debug-level { color: var(--accent-purple); }

.debug-msg {
    flex: 1;
    word-break: break-all;
}

/* ============================================
   Settings Tab
   ============================================ */
.settings-panels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    flex: 1;
    overflow-y: auto;
    align-content: start;
}

.settings-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
}

.settings-panel h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.settings-panel h3 svg {
    width: 18px;
    height: 18px;
    color: var(--accent-red);
}

.settings-panel .form-group {
    margin-bottom: 12px;
}

.settings-panel .form-group label {
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.settings-panel .form-group input {
    padding: 10px 12px;
    font-size: 0.9rem;
}

.settings-servers {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.server-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

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

.server-item-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.server-item-url {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.checkbox-row {
    margin-bottom: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ============================================
   Button Variants
   ============================================ */
.btn-primary-sm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary-sm:hover {
    background: #ff3d5a;
}

.btn-primary-sm svg {
    width: 16px;
    height: 16px;
}

.btn-secondary-sm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

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

.btn-secondary-sm svg {
    width: 14px;
    height: 14px;
}

.btn-icon-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon-sm:hover {
    border-color: var(--accent-red);
    color: var(--text-primary);
}

.btn-icon-sm svg {
    width: 16px;
    height: 16px;
}

.btn-secondary-full, .btn-primary-full {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

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

.btn-secondary-full:hover {
    border-color: var(--accent-red);
}

.btn-primary-full {
    background: var(--accent-red);
    color: white;
    border: none;
    margin-top: 16px;
}

.btn-primary-full:hover {
    background: #ff3d5a;
}

.settings-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.btn-secondary-full svg, .btn-primary-full svg {
    width: 16px;
    height: 16px;
}

.btn-danger {
    background: transparent;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.15s;
}

.btn-danger:hover {
    background: rgba(255, 23, 68, 0.1);
}

/* ============================================
   Responsive - Mobile
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 200;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        padding-top: var(--header-height);
    }

    .tab-content {
        padding: 16px;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stats-row .stat-card {
        padding: 12px;
    }

    .stats-row .stat-value {
        font-size: 1.2rem;
    }

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

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

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

    #tab-libraries .libraries-grid {
        grid-template-columns: 1fr;
    }

    .content-header h1 {
        font-size: 1.2rem;
    }

    .setup-view {
        padding: 16px;
        min-height: 100vh;
    }

    .setup-card {
        padding: 24px 20px;
    }
}

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

    .stats-row .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .debug-filters {
        flex-wrap: wrap;
    }

    .filter-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}
